comparison src/library/library.cc @ 223:84e0a3c4737a

library: implement menu bar buttons I also went ahead and put the links from Taiga in so I don't have to worry about it later...
author Paper <mrpapersonic@gmail.com>
date Mon, 08 Jan 2024 16:54:16 -0500
parents b9f111d84d95
children c4f03f83b252
comparison
equal deleted inserted replaced
222:b9f111d84d95 223:84e0a3c4737a
6 #include "anitomy/anitomy.h" 6 #include "anitomy/anitomy.h"
7 7
8 #include <filesystem> 8 #include <filesystem>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <string> 10 #include <string>
11
12 #include <iostream>
13
14 namespace Library {
11 15
12 // int = anime id, map = episode, paths 16 // int = anime id, map = episode, paths
13 std::unordered_map<int, std::unordered_map<int, std::string>> library; 17 std::unordered_map<int, std::unordered_map<int, std::string>> library;
14 18
15 void SearchLibraryFolders() { 19 void SearchLibraryFolders() {
19 const std::filesystem::path path(spath); 23 const std::filesystem::path path(spath);
20 for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) { 24 for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) {
21 if (!std::filesystem::is_regular_file(entry.path())) 25 if (!std::filesystem::is_regular_file(entry.path()))
22 continue; 26 continue;
23 27
24 const std::string basename = path.filename(); 28 const std::string basename = entry.path().filename();
25 29
26 anitomy::Anitomy anitomy; 30 anitomy::Anitomy anitomy;
27 anitomy.Parse(Strings::ToWstring(basename)); 31 anitomy.Parse(Strings::ToWstring(basename));
28 32
29 const auto& elements = anitomy.elements(); 33 const auto& elements = anitomy.elements();
32 36
33 const int id = Anime::db.GetAnimeFromTitle(title); 37 const int id = Anime::db.GetAnimeFromTitle(title);
34 if (id <= 0) 38 if (id <= 0)
35 continue; 39 continue;
36 40
37 const int episode = Strings::ToInt(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle))); 41 const int episode = Strings::ToInt(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)));
38 42
39 // we have an ID now! 43 // we have an ID now!
40 library[id][episode] = entry.path(); 44 library[id][episode] = entry.path();
41 } 45 }
42 } 46 }
43 } 47 }
48
49 }