annotate src/track/media.cpp @ 78:1ce00c1c8ddc

dep/animia: update to upstream
author Paper <mrpapersonic@gmail.com>
date Wed, 11 Oct 2023 12:16:15 -0400
parents 3364fadc8a36
children 825506f0e221
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>
78
1ce00c1c8ddc dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
8 #include <QDebug>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 namespace Track {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 namespace Media {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 Filesystem::Path GetCurrentPlaying() {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 /* getting all open files */
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 std::vector<int> pids = Animia::get_all_pids();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 for (int i : pids) {
78
1ce00c1c8ddc dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
17 if (Animia::get_process_name(i) == "vlc") {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 for (std::string s : files) {
78
1ce00c1c8ddc dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
20 qDebug() << Strings::ToQString(s);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 Filesystem::Path p(s);
78
1ce00c1c8ddc dep/animia: update to upstream
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
22 if (p.Extension() == "mp4")
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 return p;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 }
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 return Filesystem::Path();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 std::string GetFileTitle(Filesystem::Path path) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 anitomy::Anitomy anitomy;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 anitomy.Parse(Strings::ToWstring(path.Basename()));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 const auto& elements = anitomy.elements();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 return Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 } // namespace Media
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 } // namespace Track