diff src/library/library.cc @ 231:69f4768a820c

chore: merge divergent branches
author Paper <paper@paper.us.eu.org>
date Sat, 13 Jan 2024 09:43:41 -0500
parents d030b30526d5
children 862d0d8619f6
line wrap: on
line diff
--- a/src/library/library.cc	Sat Jan 13 09:42:02 2024 -0500
+++ b/src/library/library.cc	Sat Jan 13 09:43:41 2024 -0500
@@ -9,19 +9,23 @@
 #include <unordered_map>
 #include <string>
 
+#include <iostream>
+
+namespace Library {
+
 // int = anime id, map = episode, paths
 std::unordered_map<int, std::unordered_map<int, std::string>> library;
 
 void SearchLibraryFolders() {
 	library.clear();
 
-	for (const auto& spath : session.config.library.paths) {
-		const std::filesystem::path path(spath);
-		for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) {
-			if (!std::filesystem::is_regular_file(entry.path()))
+	for (const auto& folder : session.config.library.paths) {
+		for (const auto& entry : std::filesystem::recursive_directory_iterator(folder)) {
+			const std::filesystem::path path = entry.path();
+			if (!std::filesystem::is_regular_file(path))
 				continue;
 
-			const std::string basename = path.filename();
+			const std::string basename = path.filename().u8string();
 
 			anitomy::Anitomy anitomy;
 			anitomy.Parse(Strings::ToWstring(basename));
@@ -34,10 +38,12 @@
 			if (id <= 0)
 				continue;
 
-			const int episode = Strings::ToInt(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle)));
+			const int episode = Strings::ToInt(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)));
 
 			// we have an ID now!
-			library[id][episode] = entry.path();
+			library[id][episode] = path.u8string();
 		}
 	}
 }
+
+}