Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/src/track/media.cc Tue Nov 07 16:06:17 2023 -0500 +++ b/src/track/media.cc Tue Nov 07 23:40:54 2023 -0500 @@ -4,29 +4,43 @@ #include "anitomy/anitomy.h" #include "core/filesystem.h" #include "core/strings.h" +#include "core/session.h" #include <string> #include <unordered_map> #include <vector> +#include <iostream> namespace Track { namespace Media { -Filesystem::Path GetCurrentPlaying() { +std::vector<Filesystem::Path> GetCurrentlyPlayingFiles() { /* getting all open files */ + std::vector<Filesystem::Path> ret; + std::vector<int> pids = Animia::get_all_pids(); - for (int i : pids) { - for (const std::string& player : media_players) { - if (Animia::get_process_name(i) != player) + for (int pid : pids) { + for (const Types::MediaPlayer& player : session.recognition.players) { + if (!player.GetEnabled() || Animia::get_process_name(pid) != player.GetExecutable()) continue; - for (const std::string& f : Animia::filter_system_files(Animia::get_open_files(i))) { - Filesystem::Path p(f); - for (const std::string& ext : media_extensions) { - if (p.Extension() == ext) - return p; - } + + for (const std::string& file : Animia::filter_system_files(Animia::get_open_files(pid))) { + const Filesystem::Path path(file); + + for (const Types::MediaExtension& ext : session.recognition.extensions) + if (path.Extension() == ext.GetExtension()) + ret.push_back(path); } } } + + return ret; +} + +Filesystem::Path GetCurrentPlaying() { + /* getting all open files */ + std::vector<Filesystem::Path> paths = GetCurrentlyPlayingFiles(); + if (paths.size()) + return paths.at(0); return Filesystem::Path(); }