Quantcast
Channel: configuration - Forum - FlexGet
Viewing all articles
Browse latest Browse all 716

Renaming files based on the presence of certain strings in the name

$
0
0

@amanmore wrote:

I have a fair amount of Anime I keep downloading, mostly through an RSS feed and deluge on my Raspi 4B. I have a task set up to automatically sort the files in appropriate folders based on name and removing the extra fluff that comes in square brackets at either end of the filename. This works most of the time, but it seems to struggle with some of the naming conventions in anime websites, and I was looking for ways to automate that.

To get to the point, I get the files with names in the format out from deluge:

[Group] (Show Name) - (Episode) [Quality]
for example
[HorribleSubs] Assassins Pride - 05 [720p]

The square brackets are present in the filename, while the parentheses here were added by me for the purpose of making things clearer for the next part of this issue.

I am able to remove the [Group] and [Quality] parts using rename while moving the files, and then it puts the files in folders based on the series name. However, when an anime has multiple seasons, the file name becomes:

[Group] (Show Name) (SX) - (Episode) [Quality]
Where X is the season number.
for example
[HorribleSubs] Shokugeki No Soma - 01 [720p] 
in its second season becomes
[HorribleSubs] Shokugeki No Soma S2 - 01 [720p]

It seems the FlexGet series name identifier doesnt like this at all, and the file ends up unsorted. It used to cause the task to abort completely, so I had added a require_field: series_name to the task to allow it to safely ignore those files.

Before setting up everything on Flexget, I used to manually run advanced renamer on these files to remove the fluff, and manually add "s0Xe" with the approprate "X" in the filename so it becomes something like

Shokugeki No Soma - s02e01

Is there any way I can automate this process in Flexget?

The effect I'm trying to achieve is:

For every new accepted file:
- Parse the filename, and split it using " " as the delimiter
- Check for instances of [HorribleSubs], [480p], [720p], or [1080p] (or just any text with square brackets)
    If Present, remove them and any extra " "s they leave behind from the filename
    If Absent, continue to the next step
- Check for a string in the format s##e## after the "-"
    if Present, exit, and move to the next file
    if Absent, check if the string right before the "-" is in the format "S#"
        If it is, remove the "S#" part, and add the string "s0#e" to the start of the episode number (aka the string right after the "-"), and move to the next file
        If it isnt, add the string "s01e" to the start of the episode number, and move to the next file

Is this something feasible in Flexget, or is it something I could do through a python script that I can run through flexget? In either case, what would be the best way to implement it?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 716

Trending Articles