Page 1 of 1
If TV show not found, BUT there exist a folder, use that folder
Posted: 19 Mar 2018, 09:30
by znerken
If the Filebot AMC script doesn't find a TV show, it puts it in "unsorted". Each time that one particular TV SHOW X is ran through the AMC script, I have to move /Unsorted/TV SHOW X sxxexx to /Sorted/TV SHOW X/. I suggest a feature that does the following:
AMC scan started
Show not found
Check if there is a folder with the name of the show in /Sorted/
If yes, move it there
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 19 Mar 2018, 10:15
by rednoah
If you sort files based on filename alone, then you can use
--def unsortedFormat to organize unsorted files however you please.

Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 19 Mar 2018, 12:33
by znerken
If you sort files based on filename alone
I am sorry , but I didn't fully understand that. I use the AMC python script called utorrent-postprocess.pyw, downloaded from this forum.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 19 Mar 2018, 12:44
by rednoah
You're asking FileBot to process files without any movie/episode information. That means that the only information that is available for processing files and putting them into the desired folder is the filename itself.
This means that what you're asking for is effectively the same as Plain File Mode:
viewtopic.php?f=3&t=2072
e.g. Let's assume we have a file "Alias.S01E01.avi", we use the format to us the "Alias" part as folder:
Code: Select all
/path/to/Sorted/{fn.before(/S\d{2}E\d{2}/)}/{fn}

This is just an example. You need to understand how it works, and then think about how you can apply it to your use case. You'll also need to understand how to call the amc script from command-line so you can test your solution, and then you need to modify the python script to call FileBot with the new command-line options.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 19 Mar 2018, 12:53
by znerken
rednoah wrote: ↑19 Mar 2018, 12:44
You're asking FileBot to process files without any movie/episode information. That means that the only information that is available for processing files and putting them into the desired folder is the filename itself.
This means that what you're asking for is effectively the same as Plain File Mode:
viewtopic.php?f=3&t=2072
e.g. Let's assume we have a file "Alias.S01E01.avi", we use the format to us the "Alias" part as folder:
Code: Select all
/path/to/Sorted/{fn.before(/S\d{2}E\d{2}/)}/{fn}

This is just an example. You need to understand how it works, and then think about how you can apply it to your use case. You'll also need to understand how to call the amc script from command-line so you can test your solution, and then you need to modify the python script to call FileBot with the new command-line options.
I was more thinking in the line of:
amc script did not find Alias S01E01
amc does not know what Alias S01E01 is
amc checks /Sorted/TV Shows/ if there already is something called Alias there
amc found a folder named Alias
Placing AliasS01E01.avi in /Sorted/Tv Shows/Alias/Season 1/
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 19 Mar 2018, 16:53
by rednoah
You can express that logic in your custom format expression.
1. Find folder where the file you're processing contains the name of that folder:
Code: Select all
'/path/to/TV Shows'.toFile().listFiles().find{ fn =~ it.name }
2. Match the S01 part from the filename:
You can use these to generate the file path you want.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 21 Mar 2018, 08:37
by znerken
rednoah wrote: ↑19 Mar 2018, 16:53
You can express that logic in your custom format expression.
1. Find folder where the file you're processing contains the name of that folder:
Code: Select all
'/path/to/TV Shows'.toFile().listFiles().find{ fn =~ it.name }
2. Match the S01 part from the filename:
You can use these to generate the file path you want.
So is it possible to add that to the custom format expression in AMC? And also, to only use that custom format expression, if the show is not found?
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 21 Mar 2018, 09:43
by rednoah
Yes. The default unsorted format is Unsorted/{file.structurePathTail} but you can override that by passing in your own --def unsortedFormat.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 21 Mar 2018, 10:18
by rednoah

I do not respond to PM messages unless there's a good reason to send PM messages.
1.
Prepare a few files for testing.
2.
Prototype your Plain File Format / Unsorted Format in the Format Editor with your test files.
3.
Do simple amc script calls on your test files with
--def ut_label=other to force every file to be processed with your Unsorted format.
4.
At this point, it'll be fairly straight-forward to add your custom options to the python script. If you start at the final step, then you'll have a very hard time.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 21 Mar 2018, 11:56
by znerken
Okay, so I am at the last step now. Could you provide an example for the amc python script WITH unsorted format? Or link to where I can read how to add it.
Something like this?
Code: Select all
unsortedFormat = '''{plex.dir}toFile().listFiles().find{ fn =~ it.name }/fn.match(/S\d{2}/)/{n} - {s00e00}'''
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 22 Mar 2018, 17:51
by rednoah
How did you test your format? Please link a screenshot that shows your format working.

If I were to Prototype a Plain File Format / Unsorted Format in the Format Editor, then it'd look something like this:
viewtopic.php?f=3&t=2072
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 25 Mar 2018, 18:52
by znerken
I tried something easy like this. My problem is as I said how I take my format expression and add all of this to the utorrent python script.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 26 Mar 2018, 11:51
by rednoah
1.
Please follow the instructions here:
viewtopic.php?f=3&t=2072
This will allow you to test format expressions for
Plain File information.
2.
You're testing formats with
Episode information. Episode information such as
{s00e00} is not available in the Unsorted / Plain File format and yield no value.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 27 Mar 2018, 08:57
by znerken
My bad! Will do. Still, it stands unclear how one would add it to the python script.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 27 Mar 2018, 09:20
by rednoah
e.g. as command-line option:
Code: Select all
--def unsortedFormat="Unsorted/{file.structurePathTail}"
e.g. as String values in a Python String array:
Code: Select all
'--def', 'unsortedFormat=Unsorted/{file.structurePathTail}',
You can learn everything you need to know by looking at and understanding the
utorrent-postprocess.pyw script and then modifying it to your needs.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 27 Mar 2018, 19:03
by znerken
I am sorry if I am slow now, how would I add the functionality of putting it in the existing folder?
Also, I don't quite understand why I can't use {S00}. The file I tested that on, was a file that Filebot was not able to identify. It is a file from the "unsorted" folder. Season and episode info is available in the filename.
Re: If TV show not found, BUT there exist a folder, use that folder
Posted: 28 Mar 2018, 02:08
by rednoah
1.
{s00e00} isn't parsed from the filename. If the
{episode} binding doesn't work because FileBot doesn't have an episode match for that file, then neither does
{s00e00} or anything that requires episode information.
You
CAN of course do that yourself, in your plain file format, and that's exactly what this piece of code mentioned above does:
2.
If you want to put a file into any specific destination folder, then you just have to write your format to come up with an absolute path to that exact folder. The
{folder} binding will give you the current location, so you could try something like this:
Where folder is the current folder path, and fn is the current file name.
3.
If you want to put the file into the folder that FileBot would use if FileBot could identify the file, then it's tricky, because you just don't know, and FileBot doesn't know.
This piece of code checks all the folder name that you have in a specific folder, and then checks if any of those folder names match your filename
(e.g. Alias.1x01.mp4 contains Alias) and then yields that folder path:
Code: Select all
'/path/to/TV Shows'.toFile().listFiles().find{ fn =~ it.name }
4.
I've given you lots of pieces of code. Please provide screenshots, so I can see how you're prototyping and testing things. Please include at least one screenshot of your current progress in every subsequent post.
