Separate out WEBRip from WEB-DL

All about user-defined episode / movie / file name format expressions
Post Reply
jwl
Posts: 2
Joined: 15 Aug 2022, 16:04

Separate out WEBRip from WEB-DL

Post by jwl »

Is there an easy way to separate out WEBRip from WEB-DL? I'd like to keep WEBRip as it's own source and not bundle it together with WEB-DL.
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Separate out WEBRip from WEB-DL

Post by rednoah »

e.g. if the file says WEBRip yield WEBRip otherwise yield whatever value vs has:

Code: Select all

{ f =~ /WEBRip/ ? 'WEBRip' : vs }

:idea: You would use this as part of the folder structure to separate different sources into different folders like so:

Code: Select all

{ drive }/Media/{ f =~ /WEBRip/ ? 'WEBRip' : vs }/{ ny }/{ plex.name }
:idea: Please read the FAQ and How to Request Help.
jwl
Posts: 2
Joined: 15 Aug 2022, 16:04

Re: Separate out WEBRip from WEB-DL

Post by jwl »

Sorry, I should have be more clear. I don't want them in separate folders, I want to rename them using the vs value but instead of grouping WEBRip and WEB-DL together, I want to keep WEBRip as is.

But using your example above, I think I was able to come up with something that should work for me.

Code: Select all

{ source.lower() =~ /webrip/ ? 'WEBRip' : vs }
Thanks!
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Separate out WEBRip from WEB-DL

Post by rednoah »

e.g. you can do a case-insensitive match on the file name like so:

Code: Select all

{ fn =~ /(?i)WEBRip/ ? 'WEBRip' : vs }
or so:

Code: Select all

{ any{ fn.match(/WEBRip/) }{ vs } }
:idea: Please read the FAQ and How to Request Help.
iKUd
Posts: 14
Joined: 25 Jan 2024, 18:32

Re: Separate out WEBRip from WEB-DL

Post by iKUd »

How can I add more eg WebHD and so on?

Tried around with the

Shell: Select all

{ any{ fn.match(/WEBRip/) }{ vs } }
but didnt get it to work.
Last edited by iKUd on 25 Jan 2024, 18:50, edited 3 times in total.
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Separate out WEBRip from WEB-DL

Post by rednoah »

If you want to match WebHD then you need to use /WebHD/ and not /WEBRip/ as custom regex pattern:

Format: Select all

{ any{ fn.match(/WebHD/) }{ vs } }
:idea: fn refers to the file name. If the file name contain WebHD then the snippet above will yield WebHD as a result.
:idea: Please read the FAQ and How to Request Help.
iKUd
Posts: 14
Joined: 25 Jan 2024, 18:32

Re: Separate out WEBRip from WEB-DL

Post by iKUd »

ok maybe I wasnt precise enough. I want to add WebHD in additional to the existing WebRip. And perhaps also Webxx and so on.
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Separate out WEBRip from WEB-DL

Post by rednoah »

e.g.

Format: Select all

{ fn.match(/Web[A-Z]{2}/) }
If the file name contains Web<two upper-case letters> then add that to the target file path.
:idea: Please read the FAQ and How to Request Help.
iKUd
Posts: 14
Joined: 25 Jan 2024, 18:32

Re: Separate out WEBRip from WEB-DL

Post by iKUd »

First of all thank you for your patience 8-)
With this I get the WebHD done but the WebRip turns into WebRi.
But my question was to add more excludes in additional to WebRip so it doesnt touch WebRip, xy, zy, and so on
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Separate out WEBRip from WEB-DL

Post by rednoah »

:?: Can you list a few file paths with corresponding desired output path?



:idea: The code above is an example. You can modify the regex pattern to match your target patterns more specifically. You can write the code yourself and test it against your file paths, but if you need help our with that then we need your sample file paths as text so that we can prototype and test the code against something.
:idea: Please read the FAQ and How to Request Help.
iKUd
Posts: 14
Joined: 25 Jan 2024, 18:32

Re: Separate out WEBRip from WEB-DL

Post by iKUd »

I want not only to separate out WEBRip from WEB-DL but also WebHD and maybe even more
like

Shell: Select all

{ any{ fn.match(/WEBRip AND WebHD AND xxx AND yyy AND zzz/) }{ vs } }
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Separate out WEBRip from WEB-DL

Post by rednoah »

rednoah wrote: 27 Jan 2024, 14:03 :?: Can you list a few file paths with corresponding desired output path?



:idea: The code above is an example. You can modify the regex pattern to match your target patterns more specifically. You can write the code yourself and test it against your file paths, but if you need help our with that then we need your sample file paths as text so that we can prototype and test the code against something.
Yes, please post sample file paths as text for each case. If we write code, then we need to create a test case first. Presumably, you are looking at the test case and can easily copy & paste it so that we don't have to randomly conjure something up.



e.g.

Format: Select all

{ any{ fn.match(/WebHD/) }{ source } }

Console Output: Select all

$ ls
Alias.1x01.WEB-DL.mp4
Alias.1x01.WebHD.mp4
Alias.1x01.WebHD.WEB-DL.mp4
Alias.1x01.WEBRip.mp4
$ filebot -mediainfo . --format "{fn} => { any{ fn.match(/WebHD/) }{ source } }"
Alias.1x01.WEB-DL => WEB-DL
Alias.1x01.WebHD => WebHD
Alias.1x01.WebHD.WEB-DL => WebHD
Alias.1x01.WEBRip => WEBRip
Notably, the {source} binding already does what you're asking for in the title. {source} doesn't match WebHD though so we use Match information from the file path to grab that or any other keyword from the file name to cover that case as well.
:idea: Please read the FAQ and How to Request Help.
iKUd
Posts: 14
Joined: 25 Jan 2024, 18:32

Re: Separate out WEBRip from WEB-DL

Post by iKUd »

Wow great - so far that looks exactly what I was looking for!
I do some more tests but atm it looks great.
Thanks alot :!:
Post Reply