Mercurial > minori
annotate src/track/media.cc @ 113:32afe0e940bf
window: remove tiny little debug thing
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 06 Nov 2023 13:48:11 -0500 |
parents | 2004b41d4a59 |
children | ab191e28e69d |
rev | line source |
---|---|
64 | 1 #include "track/media.h" |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
2 #include "track/constants.h" |
76 | 3 #include "animia.h" |
4 #include "anitomy/anitomy.h" | |
64 | 5 #include "core/filesystem.h" |
6 #include "core/strings.h" | |
7 #include <string> | |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
8 #include <unordered_map> |
64 | 9 #include <vector> |
10 | |
11 namespace Track { | |
12 namespace Media { | |
13 | |
14 Filesystem::Path GetCurrentPlaying() { | |
15 /* getting all open files */ | |
16 std::vector<int> pids = Animia::get_all_pids(); | |
17 for (int i : pids) { | |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
18 for (const std::string& player : media_players) { |
108 | 19 if (Animia::get_process_name(i) != player) |
20 continue; | |
21 for (const std::string& f : Animia::filter_system_files(Animia::get_open_files(i))) { | |
22 Filesystem::Path p(f); | |
23 for (const std::string& ext : media_extensions) { | |
24 if (p.Extension() == ext) | |
25 return p; | |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
26 } |
64 | 27 } |
28 } | |
29 } | |
30 return Filesystem::Path(); | |
31 } | |
32 | |
80 | 33 std::unordered_map<std::string, std::string> GetMapFromElements(const anitomy::Elements& elements) { |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
34 /* there are way more than this in anitomy, but we only need basic information |
80 | 35 I also just prefer using maps than using the ".get()" stuff which is why I'm doing this */ |
36 std::unordered_map<std::string, std::string> ret; | |
37 | |
38 ret["title"] = Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle)); | |
39 ret["filename"] = Strings::ToUtf8String(elements.get(anitomy::kElementFileName)); | |
40 ret["language"] = Strings::ToUtf8String(elements.get(anitomy::kElementLanguage)); | |
41 ret["group"] = Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup)); | |
42 ret["episode"] = Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)); | |
43 | |
44 return ret; | |
45 } | |
46 | |
47 std::unordered_map<std::string, std::string> GetFileElements(Filesystem::Path path) { | |
64 | 48 anitomy::Anitomy anitomy; |
49 anitomy.Parse(Strings::ToWstring(path.Basename())); | |
50 | |
80 | 51 return GetMapFromElements(anitomy.elements()); |
64 | 52 } |
53 | |
54 } // namespace Media | |
55 } // namespace Track |