diff src/track/media.cc @ 82:8b65c417c225

*: fix old stuff, make video players and extensions constants
author Paper <mrpapersonic@gmail.com>
date Mon, 23 Oct 2023 13:37:42 -0400
parents 9b2b41f83a5e
children 2004b41d4a59
line wrap: on
line diff
--- a/src/track/media.cc	Mon Oct 23 12:07:27 2023 -0400
+++ b/src/track/media.cc	Mon Oct 23 13:37:42 2023 -0400
@@ -1,12 +1,13 @@
 #include "track/media.h"
+#include "track/constants.h"
 #include "animia.h"
 #include "anitomy/anitomy.h"
 #include "core/filesystem.h"
 #include "core/strings.h"
+#include <QDebug>
 #include <string>
+#include <unordered_map>
 #include <vector>
-#include <unordered_map>
-#include <QDebug>
 
 namespace Track {
 namespace Media {
@@ -15,13 +16,16 @@
 	/* getting all open files */
 	std::vector<int> pids = Animia::get_all_pids();
 	for (int i : pids) {
-		if (Animia::get_process_name(i) == "vlc") {
-			std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i));
-			for (std::string s : files) {
-				qDebug() << Strings::ToQString(s);
-				Filesystem::Path p(s);
-				if (p.Extension() == "mp4")
-					return p;
+		for (const std::string& player : media_players) {
+			if (Animia::get_process_name(i) == player) {
+				std::vector<std::string> files = Animia::filter_system_files(Animia::get_open_files(i));
+				for (const std::string& f : files) {
+					Filesystem::Path p(f);
+					for (const std::string& ext : media_extensions) {
+						if (p.Extension() == ext)
+							return p;
+					}
+				}
 			}
 		}
 	}
@@ -29,7 +33,7 @@
 }
 
 std::unordered_map<std::string, std::string> GetMapFromElements(const anitomy::Elements& elements) {
-	/* there are way more than this in anitomy, but we only need basic information 
+	/* there are way more than this in anitomy, but we only need basic information
 	   I also just prefer using maps than using the ".get()" stuff which is why I'm doing this */
 	std::unordered_map<std::string, std::string> ret;