Mercurial > minori
comparison src/track/media.cpp @ 64:fe719c109dbc
*: update
1. add media tracking ability, and it displays info on the `now playing` page
2. the `now playing` page now actually shows something
3. renamed every page class to be more accurate to what it is
4. ...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 01 Oct 2023 23:15:43 -0400 |
parents | |
children | 3364fadc8a36 |
comparison
equal
deleted
inserted
replaced
63:3d2decf093bb | 64:fe719c109dbc |
---|---|
1 #include "track/media.h" | |
2 #include "core/filesystem.h" | |
3 #include "core/strings.h" | |
4 #include "animia.h" | |
5 #include "anitomy/anitomy.h" | |
6 #include <string> | |
7 #include <vector> | |
8 | |
9 namespace Track { | |
10 namespace Media { | |
11 | |
12 Filesystem::Path GetCurrentPlaying() { | |
13 /* getting all open files */ | |
14 std::vector<int> pids = Animia::get_all_pids(); | |
15 for (int i : pids) { | |
16 if (Animia::get_process_name(i) == "mpc-hc64.exe") { | |
17 std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i)); | |
18 for (std::string s : files) { | |
19 Filesystem::Path p(s); | |
20 if (p.Extension() == "mkv") | |
21 return p; | |
22 } | |
23 } | |
24 } | |
25 return Filesystem::Path(); | |
26 } | |
27 | |
28 std::string GetFileTitle(Filesystem::Path path) { | |
29 anitomy::Anitomy anitomy; | |
30 anitomy.Parse(Strings::ToWstring(path.Basename())); | |
31 | |
32 const auto& elements = anitomy.elements(); | |
33 | |
34 return Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle)); | |
35 } | |
36 | |
37 } // namespace Media | |
38 } // namespace Track |