Mercurial > minori
annotate src/track/media.cc @ 255:fe702c8f161f
*: whatever
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 07 Feb 2024 17:04:06 -0500 |
parents | 4d461ef7d424 |
children | 862d0d8619f6 |
rev | line source |
---|---|
64 | 1 #include "track/media.h" |
2 #include "core/filesystem.h" | |
3 #include "core/strings.h" | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
4 #include "core/session.h" |
189 | 5 |
6 #include <QFile> | |
7 #include <QTextStream> | |
8 | |
64 | 9 #include <string> |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
10 #include <unordered_map> |
64 | 11 #include <vector> |
154 | 12 #include <filesystem> |
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 |
189 | 16 #include "animia.h" |
64 | 17 |
18 namespace Track { | |
19 namespace Media { | |
20 | |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
21 static bool GetCurrentlyPlayingResults(std::vector<animia::Result>& results) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
22 std::vector<animia::Player> players; |
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) |
149
e41505d24733
players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents:
147
diff
changeset
|
26 if (enabled && player.type == animia::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 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
29 if (!animia::GetResults(players, results)) |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
30 return false; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
31 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
32 return true; |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
33 } |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
34 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
35 /* meh */ |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
36 bool GetCurrentlyPlaying(std::vector<std::string>& vec) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
37 std::vector<animia::Result> results; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
38 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
39 if (!GetCurrentlyPlayingResults(results)) |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
40 return false; |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
41 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
42 bool success = false; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
43 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
44 for (const auto& result : results) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
45 for (const auto& media : result.media) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
46 for (const auto& info : media.information) { |
153
bd439dd6ffc5
*: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents:
152
diff
changeset
|
47 switch (info.type) { |
154 | 48 case animia::MediaInfoType::File: |
228
d030b30526d5
config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents:
189
diff
changeset
|
49 vec.push_back(std::filesystem::path(info.value).filename().u8string()); |
154 | 50 success |= true; |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
51 break; |
154 | 52 case animia::MediaInfoType::Title: |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
53 vec.push_back(info.value); |
154 | 54 success |= true; |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
55 break; |
171
03b444cbe55f
graph: improve? drawing the text
Paper <mrpapersonic@gmail.com>
parents:
154
diff
changeset
|
56 default: |
03b444cbe55f
graph: improve? drawing the text
Paper <mrpapersonic@gmail.com>
parents:
154
diff
changeset
|
57 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 |