justfoolingaround / animdl

A highly efficient, fast, powerful and light-weight anime downloader and streamer for your favorite anime.
GNU General Public License v3.0
1.33k stars 109 forks source link

Option to rename files #143

Open Florian-Mahlberg opened 2 years ago

Florian-Mahlberg commented 2 years ago

Hey,

I want to download a couple of animes and after a while it takes a lot of effort to rename everything. So I think there should be an option, so you can choose your own format ex: animdl download "One Piece" -o "C:\Anime\%%(title)s\%%(title)s%%(episode)s.%%(ext)s". I alredy tried some bat scripting, but was too much work.

I hope you consider this feature and I'd like to hear your feedback!

justfoolingaround commented 2 years ago

Okay so, there are a number of reasons that'd make this difficult with how the current scraping mechanisms of the project works.

The projects just doesn't make metadata fetch requests to the internet. All the metadata seen in the cases where the metadata and the stream are in the same places in a particular request.

Hence this feature would be difficult to add for each and every provider at least for the current architecture of the project.

BogdanTheGeek commented 2 years ago

@justfoolingaround Why not check if the --download-dir is a filename extension, download the stream to /tmp or the Windows equivalent and then move/copy it there with the new name? I know it would cause some issues if your --range is more than 1, so not sure how you would get around that.

BogdanTheGeek commented 2 years ago

@Florian-Mahlberg here is a script I use for the same reason, more or less:

#!/usr/bin/env sh

cd ../
SHOW=${PWD##*/}
cd - > /dev/null 2>&1
LAST_EPISODE=$(ls | sort -t'E' -k2n | tail -n1 | sed 's/.*E//; s/\..*//')
PREFIX=$(ls | sort -t'E' -k2n | tail -n1 | sed 's/E.*/E/')
echo "Last episode of $SHOW: $LAST_EPISODE"
LATEST_EPISODE=$(($LAST_EPISODE + 1))
echo "Downloading: $PREFIX$LATEST_EPISODE.mkv"
animdl download "$SHOW" --range $LATEST_EPISODE --index 2 --download-dir /tmp &&
   mv "/tmp/${SHOW}"/*.ts "./$PREFIX$LATEST_EPISODE.mkv"

If you run this in you (title)/(season) folder, it will download the latest episode (that you don't have, aka next episode) of the show.

justfoolingaround commented 2 years ago

justfoolingaround Why not check if the --download-dir is a filename extension, download the stream to /tmp or the Windows equivalent and then move/copy it there with the new name? I know it would cause some issues if your --range is more than 1, so not sure how you would get around that.

This cannot be implemented because it would create behavioral inconsistencies and is not a robust solution. Please wait for the planned metadata fetching. Then after you may format the file names as {!|season:02d}{episode:02d}{!|" - {title}"} and download to root directory . to obtain similar if not same results.