Package: animethemes-dl
animethemes-dlwhat's this projectThis project allows you to automaticaly download opening and ending songs from all of your favorite anime without the need of downloading everything yourself. Since almost every weeb uses MAL to track the anime he's watching, this tool is really useful, as every information you need to give it has been written down already. All you need to do is to enter yourMALorAniListusername.reminderAll videos are downloaded fromanimethemes.moe. If you plan on using this program just for looking at openings, I recommend usingthemes.moeor theirown siteinstead. This program is made for creating your own playlist and such.what's this project forThis project was made for batch downloading themes from anime you have watched, but is programmed so it's easily improved, making it possible to add very easily. It's made with both command line usage and with python as a module.how to installclone this repository fromgithub.comor download it from pip withpip install animethemes-dlif you cloned, dopip install -r requirements.txtto install all required modulesinstall ffmpeg into the same folder or in PATHusage in command linemake sure you have ffmpeg and python installed
To run in console useanimethemes-dlif installed with pip.python -m animethemes-dlif you have cloned the repository.These commands will be reffered to asanimethemes-dlin the documentation.command line documentationThe script should raise errors in case you pass in an improper arg, but sometimes an error won't be raised if the error is not obvious, therefore make sure you read the documentation before running it.You must set a username and a save folder.animelistYou must set a username. By default usernames are assumed to be a MAL user, you can use a different site with--site.--animelist-argscan be:url args for MAL ``queryandvariablesfor POST request for AniList--animelist-argsare passed as a<key>=<value>pairs, for example:sort1=1,sort2=14animelist filtersThere are filters for minimum score and priority.--minscoreis the minimum score between 0 and 10.--minpriorityis the minimum priority. For mal, useLow=0,Medium=1,High=2--range <start> <end>only gets a slice of the animelist.tag filtersTo download only openings or only endings, use--OPor--EDBy default, you can just use a--smartfilter, that takes out all the dialogue. This works by removing all themes that contains a part of the episode and spoilers at the same time. This works 95% of the time.Since animethemes can have a single song bound to multiple anime,--no-copyfilters them.You can set--banned-tagsor--required-tags. These will take multiple tags, possible tags are:TagMeaningspoilerVideo contains spoilers.nsfwVideo is NSFW.ncNo captions/no credits.subbedVideo includes English subtitles of dialogue.lyricsVideo includes English lyrics as subtitles.uncenVideo does not have censorship.You can set a--min-resolution, they show up in420,720,1080.You can set the required--source, possible sources are:SourceMeaningBDVideo is sourced from a Blu-ray disc.DVDVideo is sourced from a DVD.Video is sourced from a TV release.Some themes contain a part of the episode. You can set a--overlapto show only some overlaps.OverlapMeaningOverPart of episode is over the video.TransitionPart of episode transitions into the video.NoneNo dialogue in video.If you're only looking to remove dialogue, transitions are fairly fine. They don't even have dialogue most of the time, I recommend just banningOverdownloadDownloads are by default disabled for both video and audio.
You can enable it by setting a save folder. Save folders are set with-a(audio) and-v(video).The filename format can be changed with--filename.The possible formats are defined in this table:FormatMeaninganime_idAnimethemes' id of anime.anime_nameName of Anime.anime_slugAnimethemes' slug of anime.anime_yearYear the anime came out.anime_seasonSeason the anime came out.theme_idAnimethemes' id of theme.theme_typeType of theme (OP/ED).theme_sequenceSequence of theme.theme_groupGroup of theme (e.g. language).theme_slugAnimethemes' slug of theme (type+sequence).entry_idAnimethemes' id of entry.entry_versionVersion of entry ("" or 1+).entry_notesNotes of entry (e.g. SFX version).video_idAnimethemes' id of video.video_basenameAnimethemes' basename of video.video_filenameBasename without the filetype.video_sizeSize of file in bytes.video_resolutionResolution of video.video_sourceWhere the video was sourced from.video_overlapEpisode overlap over video.song_idAnimethemes' id of song.song_titleTitle of song.video_filetypeFiletype of video.anime_filenameName of anime used in filenames.formats should be used as a python format string, meaning that it will be put as%(format)s.
For example%(anime_filename)s-%(theme_slug)s.%(video_filetype)s.Windows and Linux banned characters will be removed by default, to remove those and also unicode characters use--asciiYou can disable redownloading with-r. This is highly recommended. If you have downloaded video you can--updatetheme, this will check file validity by looking at the filesize. It will also update audio files if the video is downloaded.You can add a coverart to audio files with--coverart,--coverarttakes in a resolution, if set, image will be fetched from anilist.co, with high resolutions it's recommended to save them in--coverart-folder.Downloader timeout can be changed with--timeoutand max amount of retries with--retries.Sometimes when using filters a video that you wanted gets filtered out. you can--force-videosand keep them this way.re:zero for example has lots of unique EDs, but they often have an overlay, meaning smart filter will remove them.Data from animethemes is sending a lot of requests at the same time, so to reduce stress on the servers, the data is saved in a temp folder. You can change it's max age with--max-cache-age.statusesYou can download anime that you have--on-hold,--droppedor--planned.compressionDownloaded files can be compressed in case you want to save them.It will be enabled by setting a directory you want to compress with--compress-dir, this should be the same directory as you chosen one. The destination file is set with--compress-name, set it without the extension.
You can choose the--compress-format, this must be a format allowed byshutils.make_archive.Additionally you can set the--compress-base.printingYou can set the loglevel with--loglevel. This will set thelogger.setLevel(...).
There are quick commands--quiet(print none) and--verbose(print all). To restrict download and ffmpeg messages, you MUST use--quiet.You can disable color with--no-color.utilitiesIn case you haven't added ffmpeg to path, you can set the path with--ffmpeg.In case the mp3 tags are not showing, you can specify to--use-id3v23, that will allow support for older systems.You can--repairin case the script made some errors or you picked wrong options. This will delete unexpected files and readd metadata.settingsYou can load options from a file with--options, the file is in json format.The default options are:{"animelist":{"username":"","site":"MyAnimeList","animelist_args":{},"minpriority":0,"minscore":0,"range":[0,0]},"filter":{"smart":false,"no_copy":false,"type":null,"spoiler":null,"nsfw":null,"resolution":0,"nc":null,"subbed":null,"lyrics":null,"uncen":null,"source":null,"overlap":null},"download":{"filename":"%(anime_filename)s-%(theme_slug)s.%(video_filetype)s","audio_folder":null,"video_folder":null,"no_redownload":false,"update":false,"ascii":false,"timeout":5,"retries":3,"max_cache_age":10368000,"force_videos":[]},"coverart":{"resolution":0,"folder":null},"compression":{"root_dir":null,"base_name":"animethemes","format":"tar","base_dir":null},"statuses":[1,2],"quiet":false,"no_colors":false,"ffmpeg":"ffmpeg","id3v2_version":4,"ignore_prompts":false}You can generate the options withpython -m animethemes_dl.options.code documentationThe code uses the modulemodelsthat contains models oftyping.TypedDict.
Meaning python 3.8 is required.
Moduleparserscontains all parsers for MAL, Anilist and themes.moe.
Module tools contains extra tools foranimethemes-dl.examples:# parsers module uses API's to get dataimportanimethemes_dl.parsersasparsersparsers.fetch_animethemes(username)# fetchess raw dataparsers.get_download_data(username)# gets download data# models module uses typedDict to help lintersimportanimethemes_dl.modelsasmodelsanimelist:AnimeThemeAnime=_myanimefunc()metadata:Metadata=_mymetadatafunc()# tools have multiple tools used for several stuffimportanimethemes_dl.toolsastoolstools.ffmpeg_convert(webm_file,mp3_file)# converts a webm filetools.COLORS['progress']=Fore.CYAN# changes colorstools.compress_files(base,'zip',root)# compresses a direcotorytools.update_metadata(parsers.get_download_data(username),False)# updates metadata of all audio files# you can implement your own batch dlimportanimethemes_dldata=parsers.get_download_data(username)forthemeindata:animethemes_dl.download_theme(theme,True)# you can directly change optionsanimethemes_dl.setOptions(options)# you can make special catchersimportanimethemes_dl.errorsaserrorstry:animethemes_dl.batch_download(data)exceptFfmpegException:print('oh no')how does it work?parserget data from MAL/AniListget data from themes.moecombine datafilter out unwanted themescreate download datadownloaddownload video fileconvert video to audioconvert with ffmpegadd mp3 metadataoptionalcompress filesTODOcode optimizationsimprove code documentationmake a better README (too complicated rn)concurrent downloads, since animethemes disabled multithreaded dl.support for aria2c