Mercurial > minori
comparison src/library/library.cc @ 328:71396ecb6f7e
library: convert to class + database
it also stores std::filesystem::paths now...
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 14 Jun 2024 00:37:45 -0400 |
parents | d928ec7b6a0d |
children | a0aa8c8c4307 |
comparison
equal
deleted
inserted
replaced
327:b5d6c27c308f | 328:71396ecb6f7e |
---|---|
11 | 11 |
12 #include <iostream> | 12 #include <iostream> |
13 | 13 |
14 namespace Library { | 14 namespace Library { |
15 | 15 |
16 // int = anime id, map = episode, paths | 16 void Database::Refresh() { |
17 std::unordered_map<int, std::unordered_map<int, std::string>> library; | 17 items.clear(); |
18 | |
19 void SearchLibraryFolders() { | |
20 library.clear(); | |
21 | 18 |
22 for (const auto& folder : session.config.library.paths) { | 19 for (const auto& folder : session.config.library.paths) { |
23 for (const auto& entry : std::filesystem::recursive_directory_iterator(folder)) { | 20 for (const auto& entry : std::filesystem::recursive_directory_iterator(folder)) { |
24 const std::filesystem::path path = entry.path(); | 21 const std::filesystem::path path = entry.path(); |
25 if (!std::filesystem::is_regular_file(path)) | 22 if (!std::filesystem::is_regular_file(path)) |
36 | 33 |
37 const int id = Anime::db.LookupAnimeTitle(title); | 34 const int id = Anime::db.LookupAnimeTitle(title); |
38 if (id <= 0) | 35 if (id <= 0) |
39 continue; | 36 continue; |
40 | 37 |
41 const int episode = Strings::ToInt(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber))); | 38 const int episode = Strings::ToInt<int>(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber))); |
42 | 39 |
43 // we have an ID now! | 40 // we have an ID now! |
44 library[id][episode] = path.u8string(); | 41 items[id][episode] = path; |
45 } | 42 } |
46 } | 43 } |
47 } | 44 } |
48 | 45 |
46 Database db; | |
47 | |
49 } // namespace Library | 48 } // namespace Library |