annotate src/track/media.cpp @ 80:825506f0e221

[UNFINISHED]: stuff
author Paper <mrpapersonic@gmail.com>
date Fri, 13 Oct 2023 13:15:19 -0400
parents 1ce00c1c8ddc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "track/media.h"
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
2 #include "animia.h"
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
3 #include "anitomy/anitomy.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include "core/filesystem.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include "core/strings.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <string>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <vector>
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
8 #include <unordered_map>
78
1ce00c1c8ddc dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
9 #include <QDebug>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 namespace Track {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 namespace Media {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 Filesystem::Path GetCurrentPlaying() {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 /* getting all open files */
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 std::vector<int> pids = Animia::get_all_pids();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 return p;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 return Filesystem::Path();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
31 std::unordered_map<std::string, std::string> GetMapFromElements(const anitomy::Elements& elements) {
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
32 /* there are way more than this in anitomy, but we only need basic information
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
33 I also just prefer using maps than using the ".get()" stuff which is why I'm doing this */
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
34 std::unordered_map<std::string, std::string> ret;
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
35
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
36 ret["title"] = Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle));
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
37 ret["filename"] = Strings::ToUtf8String(elements.get(anitomy::kElementFileName));
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
38 ret["language"] = Strings::ToUtf8String(elements.get(anitomy::kElementLanguage));
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
39 ret["group"] = Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup));
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
40 ret["episode"] = Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber));
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
41
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
42 return ret;
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
43 }
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
44
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
45 std::unordered_map<std::string, std::string> GetFileElements(Filesystem::Path path) {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 anitomy::Anitomy anitomy;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 anitomy.Parse(Strings::ToWstring(path.Basename()));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 78
diff changeset
49 return GetMapFromElements(anitomy.elements());
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 } // namespace Media
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 } // namespace Track