Skip to content
Commits on Source (2)
#!/usr/bin/env python
"""LICENSE
Copyright 2015 Hermann Krumrey <hermann@krumreyh.com>
This file is part of toktokkie.
toktokkie is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
toktokkie is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with toktokkie. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import os
import shutil
import argparse
from subprocess import Popen
from puffotter.os import listdir
def main():
parser = argparse.ArgumentParser()
parser.add_argument("files", nargs="+")
args = parser.parse_args()
fill = len(str(len(args.files)))
dest_dir = args.files[0] + "_combined_dir"
dest_file = args.files[0] + "_combined.cbz"
src_images = []
if os.path.isdir(dest_dir):
shutil.rmtree(dest_dir)
os.makedirs(dest_dir)
for i, cbz in enumerate(args.files):
tempdir = "combine_temp"
if os.path.isdir(tempdir):
shutil.rmtree(tempdir)
Popen(["unzip", cbz, "-d", tempdir]).wait()
for name, path in listdir(tempdir):
new_name = str(i).zfill(fill) + " - " + name
new_path = os.path.join(dest_dir, new_name)
src_images.append(new_path)
os.rename(path, new_path)
shutil.rmtree(tempdir)
Popen(["zip", "-j", dest_file] + src_images).wait()
shutil.rmtree(dest_dir)
if __name__ == "__main__":
main()
#!/usr/bin/env python
"""LICENSE
Copyright 2015 Hermann Krumrey <hermann@krumreyh.com>
This file is part of toktokkie.
toktokkie is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
toktokkie is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with toktokkie. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import json
import argparse
import requests
from colorama import Fore, Style
def main():
parser = argparse.ArgumentParser()
parser.add_argument("anilist_username")
parser.add_argument("custom_list", default=None)
args = parser.parse_args()
query = """
query ($username: String) {
MediaListCollection(userName: $username, type: MANGA) {
lists {
name
entries {
status
progress
progressVolumes
media {
id
status
chapters
volumes
title {
english
romaji
}
}
}
}
}
}
"""
user_lists = json.loads(requests.post(
"https://graphql.anilist.co",
json={"query": query, "variables": {"username": args.anilist_username}}
).text)["data"]["MediaListCollection"]["lists"]
entries = []
for _list in user_lists:
if args.custom_list is None or _list["name"] == args.custom_list:
entries += _list["entries"]
for entry in entries:
name = entry["media"]["title"]["english"]
if name is None:
name = entry["media"]["title"]["romaji"]
user_progress = entry["progress"]
list_chapters = entry["media"]["chapters"]
if list_chapters is None:
list_chapters = guess_latest_chapter(entry["media"]["id"])
if user_progress != list_chapters:
print(Fore.LIGHTRED_EX, end="")
print("{}: ({}/{})".format(name, user_progress, list_chapters))
print(Style.RESET_ALL, end="")
def guess_latest_chapter(anilist_id: int) -> int:
"""
Guesses the latest chapter number based on anilist user activity
:param anilist_id: The anilist ID to check
:return: The latest chapter number
"""
query = """
query ($id: Int) {
Page(page: 1) {
activities(mediaId: $id, sort: ID_DESC) {
... on ListActivity {
progress
userId
}
}
}
}
"""
resp = requests.post(
"https://graphql.anilist.co",
json={"query": query, "variables": {"id": anilist_id}}
)
data = json.loads(resp.text)["data"]["Page"]["activities"]
progresses = []
for entry in data:
progress = entry["progress"]
if progress is not None:
progress = entry["progress"].split(" - ")[-1]
progresses.append(int(progress))
progresses.sort()
return progresses[-1]
if __name__ == "__main__":
main()
......@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
along with toktokkie. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import os
import argparse
from toktokkie import Directory
from toktokkie.metadata.components.enums import MediaType
......@@ -33,14 +34,20 @@ def main():
media_types = list(map(lambda x: x.value, list(MediaType)))
parser = argparse.ArgumentParser()
parser.add_argument("directory",
help="The directory for which to generate "
"a metadata file for")
parser.add_argument("media_type", choices=set(media_types),
help="The media type of the metadata")
parser.add_argument("directories", nargs="+",
help="The directories for which to generate "
"a metadata file for")
args = parser.parse_args()
directory = args.directory
for directory in args.directories:
if not os.path.isdir(directory):
print("{} is not a directory, skipping.".format(directory))
continue
if directory.endswith("/"):
directory = directory.rsplit("/", 1)[0]
......