annotate src/track/media.cc @ 282:19eb6c4dca78

autotools: ax_have_qt sucks, use pkgconf instead this is particularly useful because m4_ax_have_qt really sucked when cross compiling because of qmake
author Paper <paper@paper.us.eu.org>
date Wed, 08 May 2024 15:54:10 -0400
parents 657fda1b9cac
children b1f625b0227c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "track/media.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/filesystem.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
3 #include "core/session.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include "core/strings.h"
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
5
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
6 #include <QFile>
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
7 #include <QTextStream>
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
8
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
9 #include <filesystem>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 #include <vector>
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
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
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
16 #include "animone.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 namespace Track {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 namespace Media {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
21 static bool GetCurrentlyPlayingResults(std::vector<animone::Result>& results) {
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
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
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
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
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
34 std::vector<animone::Result> results;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
35
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 266
diff changeset
36 if (!GetCurrentlyPlayingResults(results))
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
37 return false;
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
38
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
39 bool success = false;
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 for (const auto& result : results) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
42 for (const auto& media : result.media) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
43 for (const auto& info : media.information) {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
44 std::cout << info.value << std::endl;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
45
153
bd439dd6ffc5 *: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents: 152
diff changeset
46 switch (info.type) {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
47 case animone::MediaInfoType::File:
228
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
48 vec.push_back(std::filesystem::path(info.value).filename().u8string());
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
49 success |= true;
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 189
diff changeset
50 break;
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
51 case animone::MediaInfoType::Title:
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 189
diff changeset
52 vec.push_back(info.value);
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
53 success |= true;
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 189
diff changeset
54 break;
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
55 default: break;
153
bd439dd6ffc5 *: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents: 152
diff changeset
56 }
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 }
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
60
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
61 return success;
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 } // namespace Media
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 } // namespace Track