More robust post processing. #215
Replies: 7 comments 2 replies
-
Something to note if anyone tries to use my code, I assumed I wouldn't be downloading something with more than 99 episodes, so I made it so it only appends 2 digits to the episode number to make sure that I get a nice 01, 02... naming scheme. I apologize in advance to all the Detective Conan fans that find this. |
Beta Was this translation helpful? Give feedback.
-
We could add an config option to specify a script to be executed (with relevant parameters) after a download is complete. I do not think it makes sense to implement this very specific use case, if we can just add an catch-em-all option for a script that gets parameters such as name, episode, provider etc. etc., which then processes the files itself. We could even open a discussion section for people to post their own scripts to share or something like that. |
Beta Was this translation helpful? Give feedback.
-
I admit something like what I made would be overkill. Since anipy knows what the anime that it's downloading is, it should be possible to just add an English title toggle on the user end and handle the rest on the back end, like gathering the English title and season number to append to the file name. From there the file name format options that already exist should be enough. That would give a good {English_Title}S01E01 format. As for having the option to trigger another script, I don't see why that would be a bad thing. More options are always better. In my case I would use that to move the files from the host computer to my Jellyfin server. Then it can download and rename everything to the host computer using just anipy, and then move to my server once it's downloaded to eliminate failing the download due to a local networking issue. |
Beta Was this translation helpful? Give feedback.
-
The problem is more that not every site, necessarily provides us with an English title, also even if the site has aditional names for a show, more often then not they are not labeled and we can not distinguish between english title or any other language. curl --silent "https://api.jikan.moe/v4/anime?q=<anime name here>" | jq -r '.data[0].titles[] | select(.type == "English")'.title
# For Example
curl --silent "https://api.jikan.moe/v4/anime?q=Hibike%21%20Euphonium" | jq -r '.data[0].titles[] | select(.type == "English")'.title Edit: The script above accesses the jikan api (mal api wrapper of sorts), searches for the anime name and uses jq to process the json. The jq command picks the first search result and then picks the English name from the titles. Note that there may be no english name (especially if the name is already english, e.g. Girls Band Cry) which would make this command fail. You would have to build a conditional statement that uses the provider name if it can not find anything from the api. |
Beta Was this translation helpful? Give feedback.
-
I'm not expert in this field, but if that's possible that sounds perfectly fine. Not everything has an English name, so it makes sense to just have it fall back on the default name otherwise. Another alternative solution could be to just ask the user to input whatever name they want and just have anipy append the episode number to the file name. For example, after selecting the anime to add to the seasonal list, or even just the normal download, it asks you to type in how you want it to name the files before or after selecting the episodes. It can have the default already in place so just clicking through would leave it as is. And if I want to change it I can type in whatever I want, so I can put "English_Title S01E" as the name and it just adds the 01, 02... to the end. Then to not interrupt users who aren't interested, have the option to edit file names as a true/false in the config. False by default should function as it always has, and true adds the edit option. Also with that function, it should list the default name and the edited name in the list, with one set in parentheses or something, so if you name it something else by accident you can still see what it's set to download. If you want to make it fancy, there could be an option to edit them from the main options selection, so if there's a mistype I wouldn't have to remove and readd the series, I can just list what I have tracked, select the series I want to edit, and type in what to change it to. |
Beta Was this translation helpful? Give feedback.
-
All right the option for executing scripts after download is added now (version 3.3.4). About your comment above, you can do all of that in a script, even prompt the user, here an example. You would have to extend it of course with your example script you sent at the beginning of the discussion for moving the files: #!/usr/bin/env bash
# $1 Path to the file
# $2 Name of series
# $3 Episode
# $4 Provider
# $5 Quality
# $6 Language profile
response=$(\
curl -G --silent --show-error --fail \
--data-urlencode "q=$2" \
"https://api.jikan.moe/v4/anime" \
2>&1 \
)
status=$?
if [ $status -ne 0 ]; then
# If request fails, prompt the user for the name
read -p "English Name ($2): " name
else
name=$(jq -r '.data[0].titles[] | select(.type == "English")'.title <<< "$response")
if [ -z "${name}" ]; then
# If the english name is not found in response, prompt the user
read -p "English Name ($2): " name
fi
fi
echo "$name" |
Beta Was this translation helpful? Give feedback.
-
Something I'd like to see implemented is a better way to structure file names for downloads. I know there's some options in the config, but those are just general structure and don't significantly change it. Mostly I want a built in way to ensure English titles on the files. I wrote my own script to do this and you can have it if it'll help add the feature.
Essentially how it works is when I first download an episode, I copy the name of the folder created into the first field, then I put the new name into the 2nd. 3rd is for season number. 4th I put in for cases like Mushoku Tensei where they did a Season 2 Cour 2 and restarted the episode numbers, but when I add them to my Jellyfin server I needed to number them from the start of S2. It offsets the episode number from what is given in the original file name. I just made a different script to first call the auto-update and then this script, which also moved the files to my server. I hope I have comments well enough to follow along if anything was unclear.
Beta Was this translation helpful? Give feedback.
All reactions