Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 80:825506f0e221 | 81:9b2b41f83a5e |
|---|---|
| 1 #include "track/media.h" | |
| 2 #include "animia.h" | |
| 3 #include "anitomy/anitomy.h" | |
| 4 #include "core/filesystem.h" | |
| 5 #include "core/strings.h" | |
| 6 #include <string> | |
| 7 #include <vector> | |
| 8 #include <unordered_map> | |
| 9 #include <QDebug> | |
| 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) { | |
| 18 if (Animia::get_process_name(i) == "vlc") { | |
| 19 std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i)); | |
| 20 for (std::string s : files) { | |
| 21 qDebug() << Strings::ToQString(s); | |
| 22 Filesystem::Path p(s); | |
| 23 if (p.Extension() == "mp4") | |
| 24 return p; | |
| 25 } | |
| 26 } | |
| 27 } | |
| 28 return Filesystem::Path(); | |
| 29 } | |
| 30 | |
| 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) { | |
| 46 anitomy::Anitomy anitomy; | |
| 47 anitomy.Parse(Strings::ToWstring(path.Basename())); | |
| 48 | |
| 49 return GetMapFromElements(anitomy.elements()); | |
| 50 } | |
| 51 | |
| 52 } // namespace Media | |
| 53 } // namespace Track |
