Mercurial > minori
comparison src/track/media.cc @ 118:39521c47c7a3
*: another huge megacommit, SORRY
The torrents page works a lot better now
Added the edit option to the anime list right click menu
Vectorized currently playing files
Available player and extensions are now loaded at runtime
from files in (dotpath)/players.json and (dotpath)/extensions.json
These paths are not permanent and will likely be moved to
(dotpath)/recognition
...
...
...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 23:40:54 -0500 |
parents | ab191e28e69d |
children | 0a458cb26ff4 |
comparison
equal
deleted
inserted
replaced
117:2c1b6782e1d0 | 118:39521c47c7a3 |
---|---|
2 #include "track/constants.h" | 2 #include "track/constants.h" |
3 #include "animia.h" | 3 #include "animia.h" |
4 #include "anitomy/anitomy.h" | 4 #include "anitomy/anitomy.h" |
5 #include "core/filesystem.h" | 5 #include "core/filesystem.h" |
6 #include "core/strings.h" | 6 #include "core/strings.h" |
7 #include "core/session.h" | |
7 #include <string> | 8 #include <string> |
8 #include <unordered_map> | 9 #include <unordered_map> |
9 #include <vector> | 10 #include <vector> |
11 #include <iostream> | |
10 | 12 |
11 namespace Track { | 13 namespace Track { |
12 namespace Media { | 14 namespace Media { |
13 | 15 |
14 Filesystem::Path GetCurrentPlaying() { | 16 std::vector<Filesystem::Path> GetCurrentlyPlayingFiles() { |
15 /* getting all open files */ | 17 /* getting all open files */ |
18 std::vector<Filesystem::Path> ret; | |
19 | |
16 std::vector<int> pids = Animia::get_all_pids(); | 20 std::vector<int> pids = Animia::get_all_pids(); |
17 for (int i : pids) { | 21 for (int pid : pids) { |
18 for (const std::string& player : media_players) { | 22 for (const Types::MediaPlayer& player : session.recognition.players) { |
19 if (Animia::get_process_name(i) != player) | 23 if (!player.GetEnabled() || Animia::get_process_name(pid) != player.GetExecutable()) |
20 continue; | 24 continue; |
21 for (const std::string& f : Animia::filter_system_files(Animia::get_open_files(i))) { | 25 |
22 Filesystem::Path p(f); | 26 for (const std::string& file : Animia::filter_system_files(Animia::get_open_files(pid))) { |
23 for (const std::string& ext : media_extensions) { | 27 const Filesystem::Path path(file); |
24 if (p.Extension() == ext) | 28 |
25 return p; | 29 for (const Types::MediaExtension& ext : session.recognition.extensions) |
26 } | 30 if (path.Extension() == ext.GetExtension()) |
31 ret.push_back(path); | |
27 } | 32 } |
28 } | 33 } |
29 } | 34 } |
35 | |
36 return ret; | |
37 } | |
38 | |
39 Filesystem::Path GetCurrentPlaying() { | |
40 /* getting all open files */ | |
41 std::vector<Filesystem::Path> paths = GetCurrentlyPlayingFiles(); | |
42 if (paths.size()) | |
43 return paths.at(0); | |
30 return Filesystem::Path(); | 44 return Filesystem::Path(); |
31 } | 45 } |
32 | 46 |
33 std::unordered_map<std::string, std::string> GetMapFromElements(const anitomy::Elements& elements) { | 47 std::unordered_map<std::string, std::string> GetMapFromElements(const anitomy::Elements& elements) { |
34 /* there are way more than this in anitomy, but we only need basic information | 48 /* there are way more than this in anitomy, but we only need basic information |