annotate src/track/media.cpp @ 76:3364fadc8a36

*: format source code
author Paper <mrpapersonic@gmail.com>
date Wed, 04 Oct 2023 01:46:33 -0400
parents fe719c109dbc
children 1ce00c1c8ddc
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>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 namespace Track {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 namespace Media {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 Filesystem::Path GetCurrentPlaying() {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 /* getting all open files */
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 std::vector<int> pids = Animia::get_all_pids();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 for (int i : pids) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 if (Animia::get_process_name(i) == "mpc-hc64.exe") {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 for (std::string s : files) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 Filesystem::Path p(s);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 if (p.Extension() == "mkv")
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 return p;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 return Filesystem::Path();
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 std::string GetFileTitle(Filesystem::Path path) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 anitomy::Anitomy anitomy;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 anitomy.Parse(Strings::ToWstring(path.Basename()));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 const auto& elements = anitomy.elements();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 return Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 } // namespace Media
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 } // namespace Track