changeset 100:f5940a575d83

track/constants: add many more video formats
author Paper <mrpapersonic@gmail.com>
date Fri, 03 Nov 2023 09:43:04 -0400
parents 503bc1547d49
children c537996cf67b
files dep/animia/src/bsd.cpp include/core/http.h include/core/strings.h src/core/http.cc src/core/strings.cc src/track/constants.cc
diffstat 6 files changed, 49 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/dep/animia/src/bsd.cpp	Fri Nov 03 09:00:46 2023 -0400
+++ b/dep/animia/src/bsd.cpp	Fri Nov 03 09:43:04 2023 -0400
@@ -105,8 +105,9 @@
 			if (sz != PROC_PIDFDVNODEPATHINFO_SIZE)
 				continue;
 
-			/* I *think* this is correct. For some reason, with VLC on macOS this thinks files are read/write,
-			   which is totally unnecessary and even harmful. */
+			/* I'm 99.9% sure this is incorrect. We can't pick up QuickTime files with this :(
+
+			   Actually, we can't pick up QuickTime files regardless. WTF? */
 			if ((vnodeInfo.pfi.fi_status & O_ACCMODE) == O_WRONLY)
 				continue;
 
--- a/include/core/http.h	Fri Nov 03 09:00:46 2023 -0400
+++ b/include/core/http.h	Fri Nov 03 09:43:04 2023 -0400
@@ -7,8 +7,8 @@
 
 namespace HTTP {
 
-QByteArray Get(std::string url, std::vector<std::string> headers = {});
-QByteArray Post(std::string url, std::string data, std::vector<std::string> headers = {});
+QByteArray Get(const std::string& url, const std::vector<std::string>& headers = {});
+QByteArray Post(const std::string& url, const std::string& data, const std::vector<std::string>& headers = {});
 
 } // namespace HTTP
 
--- a/include/core/strings.h	Fri Nov 03 09:00:46 2023 -0400
+++ b/include/core/strings.h	Fri Nov 03 09:43:04 2023 -0400
@@ -15,8 +15,8 @@
 /* Substring removal functions */
 std::string ReplaceAll(std::string string, const std::string& find, const std::string& replace);
 std::string SanitizeLineEndings(const std::string& string);
-std::string RemoveHtmlTags(const std::string& string);
-std::string ParseHtmlEntities(const std::string& string);
+std::string RemoveHtmlTags(std::string string);
+std::string ParseHtmlEntities(std::string string);
 
 /* stupid HTML bullshit */
 std::string TextifySynopsis(const std::string& string);
--- a/src/core/http.cc	Fri Nov 03 09:00:46 2023 -0400
+++ b/src/core/http.cc	Fri Nov 03 09:43:04 2023 -0400
@@ -13,7 +13,7 @@
 	return size * nmemb;
 }
 
-QByteArray Get(std::string url, std::vector<std::string> headers) {
+QByteArray Get(const std::string& url, const std::vector<std::string>& headers) {
 	struct curl_slist* list = NULL;
 	QByteArray userdata;
 
@@ -40,7 +40,7 @@
 	return userdata;
 }
 
-QByteArray Post(std::string url, std::string data, std::vector<std::string> headers) {
+QByteArray Post(const std::string& url, const std::string& data, const std::vector<std::string>& headers) {
 	struct curl_slist* list = NULL;
 	QByteArray userdata;
 
--- a/src/core/strings.cc	Fri Nov 03 09:00:46 2023 -0400
+++ b/src/core/strings.cc	Fri Nov 03 09:43:04 2023 -0400
@@ -76,8 +76,7 @@
 	};
 
 	for (const auto& item : map)
-		if (string.find(item.first) != std::string::npos)
-			string = ReplaceAll(string, item.first, item.second);
+		string = ReplaceAll(string, item.first, item.second);
 	return string;
 }
 
--- a/src/track/constants.cc	Fri Nov 03 09:00:46 2023 -0400
+++ b/src/track/constants.cc	Fri Nov 03 09:43:04 2023 -0400
@@ -2,12 +2,48 @@
 
 // clang-format off
 // https://github.com/llvm/llvm-project/issues/62676
+
+/* right now, these are just const vectors, but eventually
+   I'll make a class to manage these and make them disableable */
 const std::vector<std::string> media_extensions = {
+    "mkv",
+    "mp4",
+    "m4v", /* apple's stupid DRM thing */
     "avi",
+    "webm", /* matroska's retarded inbred cousin */
+    /* QuickTime */
+    "mov",
+    "qt",
+    /* MPEG transport stream */
+    "mts",
+    "m2ts",
+    "ts",
+    /* MPEG-1, typically not used for anime */
+    "mpg",
+    "mp2",
+    "mpeg",
+    "mpe",
+    "mpv",
+    /* MPEG-2 */
+    "m2v"
+    /* 3GPP */
+    "3gp",
+    "3g2",
+    /* Windows Media */
     "asf",
-    "mp4",
-    "mkv",
-    "wmv"
+    "wmv",
+    /* Adobe Flash */
+    "flv",
+    "swf", /* not exactly a video format */
+    /* Ogg Video */
+    "ogv",
+    /* RealPlayer (who tf uses this?) */
+    "rm",
+    "rmvb",
+    /* Nullsoft Streaming Video (Winamp) */
+    "nsv",
+    /* Material Exchange Format (Sony?) */
+    "mxf"
 };
 
 const std::vector<std::string> media_players = {