Mercurial > minori
annotate src/track/media.cc @ 259:0362f3c4534c
widgets/graph: improve drawing code
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 01 Apr 2024 18:11:15 -0400 |
parents | 862d0d8619f6 |
children | ff0b2052b234 |
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 |
258 | 29 if (!animone::GetResults(players, results)) { |
30 std::cout << "FAIL!" << std::endl; | |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
31 return false; |
258 | 32 } |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
33 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
34 return true; |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
35 } |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
36 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
37 /* meh */ |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
38 bool GetCurrentlyPlaying(std::vector<std::string>& vec) { |
258 | 39 std::vector<animone::Result> results; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
40 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
41 if (!GetCurrentlyPlayingResults(results)) |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
42 return false; |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
43 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
44 bool success = false; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
45 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
46 for (const auto& result : results) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
47 for (const auto& media : result.media) { |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
48 for (const auto& info : media.information) { |
258 | 49 std::cout << info.value << std::endl; |
50 | |
153
bd439dd6ffc5
*: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents:
152
diff
changeset
|
51 switch (info.type) { |
258 | 52 case animone::MediaInfoType::File: |
228
d030b30526d5
config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents:
189
diff
changeset
|
53 vec.push_back(std::filesystem::path(info.value).filename().u8string()); |
154 | 54 success |= true; |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
55 break; |
258 | 56 case animone::MediaInfoType::Title: |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
57 vec.push_back(info.value); |
154 | 58 success |= true; |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
189
diff
changeset
|
59 break; |
258 | 60 default: break; |
153
bd439dd6ffc5
*: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents:
152
diff
changeset
|
61 } |
64 | 62 } |
63 } | |
64 } | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
65 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
66 return success; |
64 | 67 } |
68 | |
69 } // namespace Media | |
70 } // namespace Track |