mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-07 16:17:38 +03:00
Added folder structure for books downloaded via Calibre
This commit is contained in:
parent
da3abbacd5
commit
15727935fd
@ -261,7 +261,9 @@ void OpdsBookBrowserActivity::fetchFeed(const std::string& path) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string url = UrlUtils::buildUrl(serverUrl, path);
|
std::string url = UrlUtils::buildUrlWithAuth(serverUrl, path,
|
||||||
|
SETTINGS.calibreUsername,
|
||||||
|
SETTINGS.calibrePassword);
|
||||||
Serial.printf("[%lu] [OPDS] Fetching: %s\n", millis(), url.c_str());
|
Serial.printf("[%lu] [OPDS] Fetching: %s\n", millis(), url.c_str());
|
||||||
|
|
||||||
std::string content;
|
std::string content;
|
||||||
@ -335,14 +337,20 @@ void OpdsBookBrowserActivity::downloadBook(const OpdsEntry& book) {
|
|||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
|
|
||||||
// Build full download URL
|
// Build full download URL
|
||||||
std::string downloadUrl = UrlUtils::buildUrl(SETTINGS.opdsServerUrl, book.href);
|
std::string downloadUrl = UrlUtils::buildUrlWithAuth(SETTINGS.opdsServerUrl, book.href,
|
||||||
|
SETTINGS.calibreUsername,
|
||||||
|
SETTINGS.calibrePassword);
|
||||||
|
|
||||||
// Create sanitized filename: "Title - Author.epub" or just "Title.epub" if no author
|
// Create Calibre-style folder structure: /Books/AuthorName/BookName/BookFile.epub
|
||||||
std::string baseName = book.title;
|
std::string authorFolder = book.author.empty() ? "Unknown Author" : StringUtils::sanitizeFilename(book.author);
|
||||||
if (!book.author.empty()) {
|
std::string bookFolder = StringUtils::sanitizeFilename(book.title);
|
||||||
baseName += " - " + book.author;
|
std::string bookFile = StringUtils::sanitizeFilename(book.title) + ".epub";
|
||||||
}
|
std::string filename = "/Books/" + authorFolder + "/" + bookFolder + "/" + bookFile;
|
||||||
std::string filename = "/" + StringUtils::sanitizeFilename(baseName) + ".epub";
|
|
||||||
|
// Create the directory structure
|
||||||
|
SdMan.mkdir("/Books");
|
||||||
|
SdMan.mkdir(("/Books/" + authorFolder).c_str());
|
||||||
|
SdMan.mkdir(("/Books/" + authorFolder + "/" + bookFolder).c_str());
|
||||||
|
|
||||||
Serial.printf("[%lu] [OPDS] Downloading: %s -> %s\n", millis(), downloadUrl.c_str(), filename.c_str());
|
Serial.printf("[%lu] [OPDS] Downloading: %s -> %s\n", millis(), downloadUrl.c_str(), filename.c_str());
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user