64
|
1 #include "track/media.h"
|
76
|
2 #include "animia.h"
|
|
3 #include "anitomy/anitomy.h"
|
64
|
4 #include "core/filesystem.h"
|
|
5 #include "core/strings.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
|