Mercurial > minori
annotate src/track/media.cc @ 81:9b2b41f83a5e
boring: mass rename to cc
because this is a very unix-y project, it makes more sense to use the
'cc' extension
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 23 Oct 2023 12:07:27 -0400 |
parents | src/track/media.cpp@825506f0e221 |
children | 8b65c417c225 |
rev | line source |
---|---|
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> | |
80 | 8 #include <unordered_map> |
78
1ce00c1c8ddc
dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents:
76
diff
changeset
|
9 #include <QDebug> |
64 | 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) { | |
78
1ce00c1c8ddc
dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents:
76
diff
changeset
|
18 if (Animia::get_process_name(i) == "vlc") { |
64 | 19 std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i)); |
20 for (std::string s : files) { | |
78
1ce00c1c8ddc
dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents:
76
diff
changeset
|
21 qDebug() << Strings::ToQString(s); |
64 | 22 Filesystem::Path p(s); |
78
1ce00c1c8ddc
dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents:
76
diff
changeset
|
23 if (p.Extension() == "mp4") |
64 | 24 return p; |
25 } | |
26 } | |
27 } | |
28 return Filesystem::Path(); | |
29 } | |
30 | |
80 | 31 std::unordered_map<std::string, std::string> GetMapFromElements(const anitomy::Elements& elements) { |
32 /* there are way more than this in anitomy, but we only need basic information | |
33 I also just prefer using maps than using the ".get()" stuff which is why I'm doing this */ | |
34 std::unordered_map<std::string, std::string> ret; | |
35 | |
36 ret["title"] = Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle)); | |
37 ret["filename"] = Strings::ToUtf8String(elements.get(anitomy::kElementFileName)); | |
38 ret["language"] = Strings::ToUtf8String(elements.get(anitomy::kElementLanguage)); | |
39 ret["group"] = Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup)); | |
40 ret["episode"] = Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)); | |
41 | |
42 return ret; | |
43 } | |
44 | |
45 std::unordered_map<std::string, std::string> GetFileElements(Filesystem::Path path) { | |
64 | 46 anitomy::Anitomy anitomy; |
47 anitomy.Parse(Strings::ToWstring(path.Basename())); | |
48 | |
80 | 49 return GetMapFromElements(anitomy.elements()); |
64 | 50 } |
51 | |
52 } // namespace Media | |
53 } // namespace Track |