Renaming Anime and Movies in CLI and GUI

Any questions? Need some help?
Post Reply
ferndq
Posts: 1
Joined: 18 Sep 2018, 02:54

Renaming Anime and Movies in CLI and GUI

Post by ferndq »

I'm trying to write a renaming script in groovy to process my media, but I can't get filebot to reliably rename my stuff.

Here is an example of what I mean in the GUI:

Image
Image

The file already contains the title "Overlord II" in a consistent format, is there any way I can force filebot to search a specific title?

This happens frequently in my groovy script as well:

Code: Select all

Post processing /media/movies/Jurassic World: Fallen Kingdom (2018)/.torrent/Jurassic.World.Fallen.Kingdom.2018.1080p.WEB-DL.DD5.1.H264-FGT
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/media/movies/Jurassic World: Fallen Kingdom (2018)/.torrent/Jurassic.World.Fallen.Kingdom.2018.1080p.WEB-DL.DD5.1.H264-FGT/Jurassic.World.Fallen.Kingdom.2018.1080p.WEB-DL.DD5.1.H264-FGT.mkv]
Apply filter [ext == "mkv" || ext == "avi" || ext == "mp4"] on [1] items
CmdlineException: Failed to identify or process any files
Done ヾ(@⌒ー⌒@)ノ
Post processing /media/animu/series/Overlord/.torrent/[HorribleSubs] Overlord II - 04 [1080p].mkv
Rename episodes using [AniDB]
Auto-detected query: [Overlord, overlord ii]
Fetching episode data for [Overlord]
Fetching episode data for [Overlord II]
Fetching episode data for [Overlord III]
Fetching episode data for [Ple Ple Pleiades]
Fetching episode data for [Gekijouban Soushuuhen Overlord]
Apply filter [ext == "mkv" || ext == "avi" || ext == "mp4"] on [77] items
No matching episode: [HorribleSubs] Overlord II - 04 [1080p].mkv
CmdlineException: Failed to match files to episode data
Done ヾ(@⌒ー⌒@)ノ
Post processing /media/animu/series/Overlord/.torrent/[HorribleSubs] Overlord II - 01 [1080p].mkv
Rename episodes using [AniDB]
Auto-detected query: [Overlord, overlord ii]
Fetching episode data for [Overlord]
Fetching episode data for [Overlord II]
Fetching episode data for [Overlord III]
Fetching episode data for [Ple Ple Pleiades]
Fetching episode data for [Gekijouban Soushuuhen Overlord]
Apply filter [ext == "mkv" || ext == "avi" || ext == "mp4"] on [77] items
No matching episode: [HorribleSubs] Overlord II - 01 [1080p].mkv
CmdlineException: Failed to match files to episode data
Done ヾ(@⌒ー⌒@)ノ
Post processing /media/animu/series/Overlord/.torrent/[HorribleSubs] Overlord II - 02 [1080p].mkv
Rename episodes using [AniDB]
Auto-detected query: [Overlord, overlord ii]
Fetching episode data for [Overlord]
Fetching episode data for [Overlord II]
Fetching episode data for [Overlord III]
Fetching episode data for [Ple Ple Pleiades]
Fetching episode data for [Gekijouban Soushuuhen Overlord]
Apply filter [ext == "mkv" || ext == "avi" || ext == "mp4"] on [77] items
No matching episode: [HorribleSubs] Overlord II - 02 [1080p].mkv
CmdlineException: Failed to match files to episode data
Done ヾ(@⌒ー⌒@)ノ
Post processing /media/animu/series/Overlord/.torrent/[HorribleSubs] Overlord II - 03 [1080p].mkv
Rename episodes using [AniDB]
Auto-detected query: [Overlord, overlord ii]
Fetching episode data for [Overlord]
Fetching episode data for [Overlord II]
Fetching episode data for [Overlord III]
Fetching episode data for [Ple Ple Pleiades]
Fetching episode data for [Gekijouban Soushuuhen Overlord]
Apply filter [ext == "mkv" || ext == "avi" || ext == "mp4"] on [77] items
No matching episode: [HorribleSubs] Overlord II - 03 [1080p].mkv
CmdlineException: Failed to match files to episode data
Done ヾ(@⌒ー⌒@)ノ
As you can see it gets painfully close to recognizing the title, but it somehow trips itself up by putting the query in lowercase and then it fails to match the uppercase letters? What is causing this to fail? Why does "overlord ii" not match "Overlord II"?

and the script that produces these logs for context:

Code: Select all

#!/usr/bin filebot -script
//parameters torrentDir and torrentName from transmission

//default formats
series_format = "{n} - {s00e00} - {t}"
ani_series_db = "AniDB"

movie_format = "{n} ({y})"
movie_db = "TheMovieDB"

video_filter = /ext == "mkv" || ext == "avi" || ext == "mp4"/

// log input parameters
log.fine("Post processing $torrentDir/$torrentName")

directory = torrentDir.split("/")

if(torrentName ==~ /.*\.(mkv|avi|mp4)/) {
    file = "$torrentDir/$torrentName"
    if(directory[1] == "media") {
        if(directory[2] == "animu") {
            if(directory[3] == "series") {
                rename_anime_series(directory[4]);
            }
        }
        if(directory[2] == "movies") {
            words = directory[3].split(" ")
            rename_movie(directory[3]);
        }
    }
}
else if(directory[1] == "media") {
    folder = "$torrentDir/$torrentName"
    if(directory[2] == "animu"){
        if(directory[3] == "series") {
            rename_anime_series_folder(directory[4]);
        }
    }
    else if(directory[2] == "movies") {
        rename_movie_folder(directory[3])
    }
}

def rename_anime_series(series_title) {
    results = rename(file: file, output: "/media/animu/series/$series_title/", action: "symlink", format: series_format, db: ani_series_db, filter: video_filter, strict: false)
}

def rename_anime_series_folder(series_title) {
    results = rename(folder: folder, output: "/media/animu/series/$series_title/", action: "symlink", format: series_format, db: ani_series_db, filter: video_filter, strict: false)
}

def rename_movie(movie_title) {
    results = rename(file: file, output: "/media/movies/$movie_title/", action: "symlink", format: movie_format, db: movie_db, filter: video_filter, strict: false)
}

def rename_movie_folder(movie_title) {
    results = rename(folder: folder, output: "/media/movies/$movie_title/", action: "symlink", format: movie_format, db: movie_db, filter: video_filter, strict: false)
}
For extra context, this anime uses different titles for each season 1-3.

Excuse me if this comes off as venting I'm just frustrated with the CLI being so sensitive.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Anime and Movies in CLI and GUI

Post by rednoah »

1.
Your files look good and it seem that auto-detection works out of the box. Specifying --q will make things faster and more reliable, but it looks like it'll already work out of the box.


2.
You seem to misunderstand the --filter option though:

Code: Select all

Apply filter [ext == "mkv" || ext == "avi" || ext == "mp4"] on [77] items
No matching episode: [HorribleSubs] Overlord II - 01 [1080p].mkv
CmdlineException: Failed to match files to episode data
:arrow: viewtopic.php?f=3&t=2127

--filter is used to include / exclude Episode objects that are considered for matching. By using ext (which is undefined for Episode objects, since Episodes don't have file extensions, only files have file extensions) you are effectively excluding all possible Episode at all times (i.e. you're effectively passing in --filter false). So your custom filter makes sure that it can never work.


3.
If you only want to select mkv / avi / mp4 files, then you need to select them in the groovy script, and then pass the list of files you want as file: selectedFiles argument.

e.g.

Code: Select all

def folder = "path/to/files" as File
def files = folder.getFiles()
def videoFiles = files.findAll{ it.isVideo() }
rename(file: videoFiles, ...)
:idea: FileBot has a built-in File.isVideo() extension method, but you can of course specifically check for certain extensions in the file path via Groovy regex matching.
:idea: Please read the FAQ and How to Request Help.
Post Reply