annotate src/library/library.cc @ 337:a7d4e5107531

dep/animone: REFACTOR ALL THE THINGS 1: animone now has its own syntax divergent from anisthesia, making different platforms actually have their own sections 2: process names in animone are now called `comm' (this will probably break things). this is what its called in bsd/linux so I'm just going to use it everywhere 3: the X11 code now checks for the existence of a UTF-8 window title and passes it if available 4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK! I still actually need to test the bsd code. to be honest I'm probably going to move all of the bsds into separate files because they're all essentially different operating systems at this point
author Paper <paper@paper.us.eu.org>
date Wed, 19 Jun 2024 12:51:15 -0400
parents 71396ecb6f7e
children a0aa8c8c4307
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
1 #include "library/library.h"
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
2 #include "core/anime_db.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
3 #include "core/session.h"
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
4 #include "core/strings.h"
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
5
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
6 #include "anitomy/anitomy.h"
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
7
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
8 #include <filesystem>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
9 #include <string>
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
10 #include <unordered_map>
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
11
223
84e0a3c4737a library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents: 222
diff changeset
12 #include <iostream>
84e0a3c4737a library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents: 222
diff changeset
13
84e0a3c4737a library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents: 222
diff changeset
14 namespace Library {
84e0a3c4737a library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents: 222
diff changeset
15
328
71396ecb6f7e library: convert to class + database
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
16 void Database::Refresh() {
71396ecb6f7e library: convert to class + database
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
17 items.clear();
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
18
228
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 227
diff changeset
19 for (const auto& folder : session.config.library.paths) {
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 227
diff changeset
20 for (const auto& entry : std::filesystem::recursive_directory_iterator(folder)) {
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 227
diff changeset
21 const std::filesystem::path path = entry.path();
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 227
diff changeset
22 if (!std::filesystem::is_regular_file(path))
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
23 continue;
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
24
228
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 227
diff changeset
25 const std::string basename = path.filename().u8string();
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
26
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
27 anitomy::Anitomy anitomy;
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
28 anitomy.Parse(Strings::ToWstring(basename));
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
29
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
30 const auto& elements = anitomy.elements();
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
31
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
32 const std::string title = Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle));
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
33
319
d928ec7b6a0d services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
34 const int id = Anime::db.LookupAnimeTitle(title);
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
35 if (id <= 0)
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
36 continue;
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
37
328
71396ecb6f7e library: convert to class + database
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
38 const int episode = Strings::ToInt<int>(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)));
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
39
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
40 // we have an ID now!
328
71396ecb6f7e library: convert to class + database
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
41 items[id][episode] = path;
222
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
42 }
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
43 }
b9f111d84d95 *: move to semver, remove old macos build, add library files
Paper <paper@paper.us.eu.org>
parents:
diff changeset
44 }
223
84e0a3c4737a library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents: 222
diff changeset
45
328
71396ecb6f7e library: convert to class + database
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
46 Database db;
71396ecb6f7e library: convert to class + database
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
47
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
48 } // namespace Library