Mercurial > minori
annotate src/track/media.cc @ 267:09c5bd74fe93
win32: make builds work again
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 11 Apr 2024 23:39:18 -0400 |
parents | 1a6a5d3a94cd |
children | 657fda1b9cac |
rev | line source |
---|---|
64 | 1 #include "track/media.h" |
2 #include "core/filesystem.h" | |
258 | 3 #include "core/session.h" |
64 | 4 #include "core/strings.h" |
189 | 5 |
6 #include <QFile> | |
7 #include <QTextStream> | |
8 | |
258 | 9 #include <filesystem> |
64 | 10 #include <string> |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
11 #include <unordered_map> |
64 | 12 #include <vector> |
189 | 13 |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
231
diff
changeset
|
14 #include <iostream> |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
231
diff
changeset
|
15 |
258 | 16 #include "animone.h" |
64 | 17 |
18 namespace Track { | |
19 namespace Media { | |
20 | |
258 | 21 static bool GetCurrentlyPlayingResults(std::vector<animone::Result>& results) { |
22 std::vector<animone::Player> players; | |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
23 |
147
6fdf0632c003
track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents:
139
diff
changeset
|
24 players.reserve(session.config.recognition.players.size()); |
6fdf0632c003
track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents:
139
diff
changeset
|
25 for (const auto& [enabled, player] : session.config.recognition.players) |
258 | 26 if (enabled && player.type == animone::PlayerType::Default) |
147
6fdf0632c003
track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents:
139
diff
changeset
|
27 players.push_back(player); |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
28 |
265
ff0b2052b234
*: add missing utf8proc files
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
29 return animone::GetResults(players, results); |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
30 } |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
31 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
32 /* meh */ |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
33 bool GetCurrentlyPlaying(std::vector<std::string>& vec) { |
258 | 34 std::vector<animone::Result> results; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
35 |
266
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
Paper <paper@paper.us.eu.org>
parents:
265
diff
changeset
|
36 if (!GetCurrentlyPlayingResults(results)) { |
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
Paper <paper@paper.us.eu.org>
parents:
265
diff
changeset
|
37 std::cout << "whoooops!" << std::endl; |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
38 return false; |
266
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
Paper <paper@paper.us.eu.org>
parents:
265
diff
changeset
|
39 } |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
40 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
41 bool success = false; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
42 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
43 for (const auto& result : results) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
44 for (const auto& media : result.media) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
45 for (const auto& info : media.information) { |
258 | 46 std::cout << info.value << std::endl; |
47 | |
153
bd439dd6ffc5
*: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents:
152
diff
changeset
|
48 switch (info.type) { |
258 | 49 case animone::MediaInfoType::File: |
228
d030b30526d5
config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents:
189
diff
changeset
|
50 vec.push_back(std::filesystem::path(info.value).filename().u8string()); |
154 | 51 success |= true; |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
52 break; |
258 | 53 case animone::MediaInfoType::Title: |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
54 vec.push_back(info.value); |
154 | 55 success |= true; |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
56 break; |
258 | 57 default: break; |
153
bd439dd6ffc5
*: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents:
152
diff
changeset
|
58 } |
64 | 59 } |
60 } | |
61 } | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
62 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
63 return success; |
64 | 64 } |
65 | |
66 } // namespace Media | |
67 } // namespace Track |