Created
November 11, 2025 03:36
-
-
Save DT3264/40b28c42eb6b09db5c88c338fc0609eb to your computer and use it in GitHub Desktop.
Remove downloaded and already read rakuyomi chapters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import base64 | |
| import hashlib | |
| import os | |
| import sqlite3 | |
| # Customize so that it points to both the db file and the downloads folder | |
| dbfile = 'D:\\.adds\\koreader\\rakuyomi\\database.db' | |
| download_path = "D:\\.adds\\koreader\\rakuyomi\\downloads" | |
| def generate_filename(source, manga, chapter): | |
| hasher = hashlib.sha256() | |
| hasher.update(source.encode('utf-8')) | |
| hasher.update(manga.encode('utf-8')) | |
| hasher.update(chapter.encode('utf-8')) | |
| hash_result = hasher.digest() | |
| encoded_hash_bytes = base64.urlsafe_b64encode(hash_result) | |
| encoded_hash = encoded_hash_bytes.rstrip(b'=').decode('utf-8') | |
| output_filename = f"{encoded_hash}" | |
| return output_filename | |
| con = sqlite3.connect(dbfile) | |
| cur = con.cursor() | |
| manga_chapters_read = [a for a in cur.execute("select * from chapter_state where read=1")] | |
| con.close() | |
| for chapter in manga_chapters_read: | |
| file_name = generate_filename(chapter[0], chapter[1], chapter[2]) | |
| chapter_file = f"{download_path}\\{file_name}.cbz" | |
| if os.path.exists(chapter_file): | |
| os.remove(chapter_file) | |
| print("Done") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment