Request for supporting user-specified rules for episode match in command line
Request for supporting user-specified rules for episode match in command line
I hope that user-specified matching rules can be supported.
For some anime series, the naming conventions for different seasons can be inconsistent. Episodes in each season may be numbered separately starting from 01, or all seasons' episodes may be numbered continuously from 01 without resetting. This discrepancy can lead to mismatches between the actual files and TMDb data.
For example, https://www.themoviedb.org/tv/107371 uses a unified numbering system across all seasons, but the files I downloaded from PT use season-based numbering. For instance, a file might be named `S03E39`, but TMDb does not recognize this because the corresponding episode is actually listed as `S01E145` on TMDb.
Therefore, I would like the ability to specify matching rules via the command line to handle such cases. These rules should include mappings between `SxxExx` from the downloaded files and the correct `SxxExx` numbers from TMDb, as well as the directories where these rules should be applied.
Additionally, it would be best to support a list of mapping rules, where each entry defines a specific matching adjustment for different shows that require special handling.
For some anime series, the naming conventions for different seasons can be inconsistent. Episodes in each season may be numbered separately starting from 01, or all seasons' episodes may be numbered continuously from 01 without resetting. This discrepancy can lead to mismatches between the actual files and TMDb data.
For example, https://www.themoviedb.org/tv/107371 uses a unified numbering system across all seasons, but the files I downloaded from PT use season-based numbering. For instance, a file might be named `S03E39`, but TMDb does not recognize this because the corresponding episode is actually listed as `S01E145` on TMDb.
Therefore, I would like the ability to specify matching rules via the command line to handle such cases. These rules should include mappings between `SxxExx` from the downloaded files and the correct `SxxExx` numbers from TMDb, as well as the directories where these rules should be applied.
Additionally, it would be best to support a list of mapping rules, where each entry defines a specific matching adjustment for different shows that require special handling.
Re: Request for supporting user-specified rules for episode match in command line



Re: Request for supporting user-specified rules for episode match in command line
Input episodes: S03E38 - S03E40
Output episodes: S01E38-S01E40
Output I want: S01E144 - S01E146
The two episodes S03E38 and S03E39 were manually renamed by me.
The S03E40 is an episode newly added.
How can I do this using --mapper ?
My command is
Output is:
Output episodes: S01E38-S01E40
Output I want: S01E144 - S01E146
The two episodes S03E38 and S03E39 were manually renamed by me.
The S03E40 is an episode newly added.
How can I do this using --mapper ?
My command is
Shell: Select all
filebot -script fn:amc --lang=Chinese -non-strict --conflict skip \
--action test\
--apply nfo cover artwork metadata \
--def excludeList=/data/exclude.txt \
--def movieDB=TheMovieDB seriesDB=TheMovieDB::TV animeDB=TheMovieDB::TV \
--def seriesFormat="{~emby.id} - {allOf{allOf{source}{vc.length()>5?vcf:vc}{vf}{hdr}{ac}.join('.').replace('Dolby Vision','DV')}{group}.join('-')}" \
--output "/mnt/media/DongMan" \
--q 107371 \
/Download/video/anim/YiNianYH/\[一念永恒第三季\].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/*E13[7-9]*
Console Output: Select all
Run script [fn:amc] at [Thu Mar 13 01:37:13 CST 2025]
Parameter: excludeList = /data/exclude.txt
Parameter: movieDB = TheMovieDB
Parameter: seriesDB = TheMovieDB::TV
Parameter: animeDB = TheMovieDB::TV
Parameter: movieFormat = {~emby.id} {allOf{allOf{source}{vc.length()>5?vcf:vc}{vf}{hdr}{ac}.join('.').replace('Dolby Vision','DV')}{group}.join('-')}
Parameter: seriesFormat = {~emby.id} - {allOf{allOf{source}{vc.length()>5?vcf:vc}{vf}{hdr}{ac}.join('.').replace('Dolby Vision','DV')}{group}.join('-')}
Parameter: animeFormat = {~emby.id} - {allOf{allOf{source}{vc.length()>5?vcf:vc}{vf}{hdr}{ac}.join('.').replace('Dolby Vision','DV')}{group}.join('-')}
Parameter: jellyfin = *****
Parameter: emby = *****
Argument[0]: /Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4
Argument[1]: /Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4
Argument[2]: /Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4
Use excludes: /data/exclude.txt (14)
Input: /Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4
└─ xattr metadata: 一念永恒 - 1x144 - 叛乱惊起
Input: /Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4
└─ xattr metadata: 一念永恒 - 1x145 - 险象环生
Input: /Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4
Group files by movie or series
Group: {Series=一念永恒} => [[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4, [一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4]
Group: {Series=Will (2017)} => [[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4]
Rename episodes using [TheMovieDB] with [Airdate Order]
Lookup via [] [107371]
Fetching episode data for [107371]
* 一念永恒 [107371] | 200 episodes | 1x01-200
[TEST] from [/Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [/mnt/media/DongMan/一念永恒 (2020) [tmdbid=107371]/Season 01/一念永恒 (2020) - S01E38 - 罚你出宗 - WEB-DL.o264.1080p.AAC-OurTV.mp4]
[TEST] from [/Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [/mnt/media/DongMan/一念永恒 (2020) [tmdbid=107371]/Season 01/一念永恒 (2020) - S01E39 - 潜入血溪宗 - WEB-DL.o264.1080p.AAC-OurTV.mp4]
Processed 2 files
Rename episodes using [TheMovieDB] with [Airdate Order]
Lookup via [] [107371]
Fetching episode data for [107371]
* 一念永恒 [107371] | 200 episodes | 1x01-200
[TEST] from [/Download/video/anim/YiNianYH/[一念永恒第三季].A.Will.Eternal.S03.2024.1080p.WEB-DL.H264.AAC-OurTV/[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [/mnt/media/DongMan/一念永恒 (2020) [tmdbid=107371]/Season 01/一念永恒 (2020) - S01E40 - 人才的光环 - WEB-DL.o264.1080p.AAC-OurTV.mp4]
Processed 1 file
Finished without processing any files
Done ¯\_(ツ)_/¯
Re: Request for supporting user-specified rules for episode match in command line

Console Output: Select all
$ filebot -list --q 107371 --db TheMovieDB::TV --format "{plex.id}" --filter "e >= 144" -rename *.mp4 --log INFO
[MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E144 - Episode 144.mp4]
[MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E145 - Episode 145.mp4]
[MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E146 - Episode 146.mp4]

Console Output: Select all
$ filebot -rename *.mp4 --db TheTVDB -non-strict --log INFO
[MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [A Will Eternal - 3x38 - 第144集.mp4]
[MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [A Will Eternal - 3x39 - 第145集.mp4]
[MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [A Will Eternal - 3x40 - 第146集.mp4]

EDIT:

* https://www.themoviedb.org/tv/107371
* https://www.themoviedb.org/tv/285779

Re: Request for supporting user-specified rules for episode match in command line
Thanks for your reply!
For example, get the input episode number 38, store it in a variable, say in, and then use
--filter "e >= in+106" .
The question is how can I get the number 38 and use it in --filter?
--filter "e >= e00 + 106" does not work as my will.
By the way, I can not access tvdb in China. And another reason I use tmdb is that only tmdb supports Chinese the best.
Can I automate the correspondance?rednoah wrote: ↑12 Mar 2025, 19:50In this case I'd use the Linear Rename approach:
Console Output: Select all
$ filebot -list --q 107371 --db TheMovieDB::TV --format "{plex.id}" --filter "e >= 144" -rename *.mp4 --log INFO [MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E144 - Episode 144.mp4] [MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E145 - Episode 145.mp4] [MOVE] from [[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E146 - Episode 146.mp4]
For example, get the input episode number 38, store it in a variable, say in, and then use
--filter "e >= in+106" .
The question is how can I get the number 38 and use it in --filter?
--filter "e >= e00 + 106" does not work as my will.
By the way, I can not access tvdb in China. And another reason I use tmdb is that only tmdb supports Chinese the best.
Re: Request for supporting user-specified rules for episode match in command line
That is a good question. How does FileBot know the episode number? Remember that FileBot does not know anything until the file has already been matched to an episode. You could probably have your own bash code guess that part though, and then generate a --filter option accordingly:
Console Output: Select all
$ ls | egrep -o 'S[0-9]+E[0-9]+' | egrep -o '[0-9]+$'
38

Console Output: Select all
$ filebot -rename *.mp4 --output . --format "{plex.id}" --db TheMovieDB::TV -non-strict --q 107371 --filter "e > 106" --mapper "episode.derive(1, e - 106)" --action TEST --log INFO
[TEST] from [[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E144 - Episode 144.mp4]
[TEST] from [[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E145 - Episode 145.mp4]
[TEST] from [[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E146 - Episode 146.mp4]

Console Output: Select all
$ filebot -rename *.mp4 --output . --format "{plex.id}" --db TheMovieDB::TV -non-strict --q 107371 --filter "age < 7" --action TEST --log INFO
[TEST] from [[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E146 - Episode 146.mp4]
I'm sure there's a way around the GFW. That said, I would generally recommend using TheMovieDB for everything, and contributing if you find something missing.
Re: Request for supporting user-specified rules for episode match in command line
Thank you very much!
This method can solve my problem.
This method can solve my problem.
I do not have to use age, because I only pass the latest file to filebot.rednoah wrote: ↑13 Mar 2025, 05:47Console Output: Select all
$ filebot -rename *.mp4 --output . --format "{plex.id}" --db TheMovieDB::TV -non-strict --q 107371 --filter "e > 106" --mapper "episode.derive(1, e - 106)" --action TEST --log INFO [TEST] from [[一念永恒第三季].A.Will.Eternal.S03E38.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E144 - Episode 144.mp4] [TEST] from [[一念永恒第三季].A.Will.Eternal.S03E39.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E145 - Episode 145.mp4] [TEST] from [[一念永恒第三季].A.Will.Eternal.S03E40.2024.1080p.WEB-DL.H264.AAC-OurTV.mp4] to [TV Shows/A Will Eternal {tmdb-107371}/Season 01/A Will Eternal - S01E146 - Episode 146.mp4]