Expressions/Rules exchange (1 Viewer)

Chubler

Portal Member
July 14, 2009
46
25
Home Country
Australia Australia
"Staffel N" and "Série N" for German, French/Spanish speakers. Correct previous issue with arbitory characters in front of the filename matching \\.

Code:
(?<series>[^\\$]+)(?:(?:\\(?:Season|Staffel|S[eé]ries?)?[ .-]?[0-9]{1,4})?\\s?(?<season>[0-2]?[0-9])|\\(?:(?:Season|Staffel|S[eé]ries?)[ .-])?(?<season>[0-9]{1,4})\\[^\\]*?)[ex]?(?<episode>\d\d+)(?:[ .+-]e?(?<episode2>\d\d+))?(?:[ -]+(?<title>[\w -.,'!&$][^$]*?))?\.(?<ext>[^.]*)$

Supports:
  • NEW: Foo\Season 2010\s2010e01 - $25K Opening Table.avi
  • root\sub\Foo\Staffel 5\S05E01 Shot title.avi
  • Foo\Série 02\23.avi
  • Foo\Series 02\02x23 - Show title.avi
  • Foo\Season 07\itg-scrubsdb-07x23 - Show title.avi
  • Foo\Season 2\215 Show title.avi
  • Foo\Season 2\02x03 Show title.avi
  • Foo\Season 2\s02e23 Show title.avi
  • Foo\Season 2\02x23-24 Show title.avi
  • Foo\02\02x23 Show title.a
  • Foo\02e23-e24 Show title.av
  • Foo\Season 2\23 Show title.avi
  • Foo\Season 2\23 - Show title.avi
  • Foo\Season 2\e23 Show title.avi
  • Foo\Season 2\23-24 Show title.avi
  • Foo\2\e23+e24 Show title.avi
  • and more combinations that are impossible to list all...

Thanks: dir for 4 digit season numbers and RegEx for special characters in show titles
 
Last edited:

RoChess

Extension Developer
  • Premium Supporter
  • March 10, 2006
    4,434
    1,897
    Current version:

    Code:
    ^(?:.*\\)?(?<series>[^\\]+?)[ _.\-\[]+(?:[s]?(?:eason\s?)?(?<season>\d+)[ _.\-\[\]]*[ex](?:pisode\s?)?(?<episode>\d+)|(?:\#|\-\s)(?<season>(?!(?:\d{4}.\d{2}.\d{2}|\d{2}.\d{2}.\d{4}))\d+)\.(?<episode>\d+))(?:[ _.+-]+(?:[s]?(?:eason\s?)?\k<season>[ _.\-\[\]]*[ex](?:pisode\s?)?(?<episode2>\d+)|(?:\#|\-\s)\k<season>\.(?<episode2>\d+))|(?:[ _.+-]*[ex+-]+(?:pisode\s?)?(?<episode2>\d+)))*[ _.\-\[\]]*(?<title>(?![^\\].*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$


    Supports:
    • foo season 1 episode 01 - *
    • foo season 1 episode 01 + episode 02 - *
    • foo.s01_e01.*
    • foo_[s01]_[e01]_*
    • foo_[s01]_[e01-02]_*
    • foo.1x01.1x02.*
    • foo #1.01 + #1.02.*
    • foo.1x01.1x02.*
    • foo s01e01 - e02*
    • foo s01e01 + s01e02*
    • foo - s01e01 - s01e02 - *
    • foo.2009x101.*
    • foo.S18E203.2010.08.27.*
    • 24.S08E01.04.00.PM-05.00.PM.*
    • and more combinations that are impossible to list all...
    Which is in line with what XBMC supports. Also fixed filenames that contain a '$' sign in the episode title.

    Fixes:
    • NEW: Added support for full text 'Season' and 'Episode' in filename
    • NEW: Prevent false positives when filename contains 'date' that uses dots as seperators.
    • NEW: "Foo.S01E01.Bar\Foo.S01E02.Bar.avi" was seen as S01E01, this also caused 'Samples' to be picked up.
    • "Series S01E01 - 2010.08.07.avi" was seen as S01E01 + S01E08 from the new XBMC support
    • "Ben.10.1x23.episode.title" was seen as S10E1 with "x23.episode.title" as Episode title, this removes support for "Show.1.10.Episode.Title" scheme, but just use "Show.#1.10.Episode.Title" then (or "Show - 1.10 - Episode.Title"), which you can do via String Replacement instead of renaming all your files
    • Support added for S01E01E02 and S01E01-E02 pattern
    • New changes should allow for 'The Sample' to be part of episode title without ignoring it as a sample
     
    Last edited:

    RoChess

    Extension Developer
  • Premium Supporter
  • March 10, 2006
    4,434
    1,897
    Expression to support double digit seasons without a seperator:

    Code:
    ^(?:.*\\)?(?<series>[^\\]+?)[ _.\-\[]+(?:(?<season>\d{2})(?<episode>\d{2})[ _.+\-\[\]]*(?<episode2>\d{2})*)[ _.\-\[\]]*(?<title>(?![^\\].*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$

    Supports:
    • foo.1201.* = foo 12x01
    • foo.2212+13.* = episode 12 + 13
    • and more combinations that are impossible to list all...

    Positioning of this expression is important. If your current "foo.1201.bar.ext" series are failing your existing expressions for a match, then you can place it at the bottom of the list. However the odds are that some other expression is trying to make a match and causing a false positive, for example thinking it is 1x201. In that case make sure this expression is moved up in the list.
     

    Marvman

    Retired Team Member
  • Premium Supporter
  • November 14, 2007
    1,163
    735
    Bavaria
    Home Country
    Germany Germany
    Type: Parsing - Regex

    Description:

    Those 3 simple regex expressions, will match most series correctly. They ignore "Sample" files and folders.
    They search only for the Name, Season and Episode. With these three information only, the grabber finds all my series perfectly.

    Requirements:
    The series folder is named correctly and can be found by the grabber of TVSeries.
    Add those expressions before all other rules. (I disabled all other rules.)
    The pattern season and episode patterns SnnEnn or NNxNN must be anywhere in the file path. (Nn = Number)

    Folder structure should be

    C:\Series\<Series Name>\<-- copy all into this folder (sub folder, single files, no matter)

    Example:

    D:\series\Grey`s Anatomy\Greys.Anatomy.S07E19.Ein.langer.Weg.zurueck.GERMAN.DUBBED.DL.WS.720p.HDTV.x264-euHD\euhd-greys-s07e19-720p.rar

    D:\series\Desperate Housewives\Desperate.Housewives.S07E15.Zuhause.GERMAN.DUBBED.DL.WS.720p.HDTV.x264-euHD\euhd-desperate-s07e15-720p.mkv
    D:\series\Desperate Housewives\sof-desperate.housewives.s07e16.avi

    D:\series\oc\O.C. California - Staffel 1\O.C. California - 1x01 - Fremde Welten.avi

    D:\series\Veronica Mars\Veronica.Mars.S01.COMPLETE.GERMAN.DL.DUBBED.720p.WEB-DL.H.264-TvR\Veronica.Mars.S01E01.Freundschaftsdienste.GERMAN.DL.DUBBED.720p.WEB-DL.H.264-TvR\tvr-veronica-mars-s01e01-720p.mkv

    Expression:
    Code:
    ^(?<series>[a-z-A-Z0-9_\s.´`]+)\\(?:(?!Sample|sample).)*[sS](?<season>\d+)[.]*[eE](?<episode>\d+)(?:(?!Sample|sample).)*$
    
    ^(?<series>[a-z-A-Z0-9_\s.´`]+)\\(?:(?!Sample|sample).)*(?<season>[\d]+)[xX](?<episode>[\d]+)(?:(?!Sample|sample).)*$
    
    ^(?<series>[a-z-A-Z0-9_\s.´`]+)\\(?:(?!Sample|sample).)*[eE](?<episode>\d+)(?:(?!Sample|sample).)*$
     

    wangtastic

    Portal Member
    November 24, 2006
    17
    0
    36
    Type:
    Parsing - Regex

    Description:
    I have my set up as follows:

    "E:\My Documents\Videos\TV\Showname\Season XX\SXXEXX - Episode Title.ext"

    e.g

    "E:\My Documents\Videos\TV\Bleach\Season 01\S01E01 - Pilot.avi"


    This code works for me :)

    Expression
    Code:
    (?<series>[^\\$]+)(?:(?:\\(?:Season|Staffel|S[eé]ries?)?[ .-]?[0-2]?[0-9])?\\s?(?<season>[0-2]?[1-9])|\\(?:(?:Season|Staffel|S[eé]ries?)[ .-])?(?<season>[0-2]?[1-9])\\[^\\]*?)[ex]?(?<episode>\d\d+)(?:[ .+-]e?(?<episode2>\d\d+))?(?:[ -]+(?<title>(?![^\\]*?sample)[^$]*?))?\.(?<ext>[^.]*)$
     

    pgjensen

    Portal Pro
    May 1, 2008
    186
    7
    Type:
    Parsing - Regex

    Description:
    I download shows from all over the place and rarely rename them. This is perfect for people that are fine with leaving filenames as they originally were (I.e. to continue to share with torrents and only having to worry about directory structure changes). All "scene" naming conventions are supported here, and more added. I ignore any season numbers from the filenames themselves and grab the season from the 2nd directory. Sample files currently are not ignored since I use MKV/AVI ReSample to .srs files on them, but if they're in a Sample folder within the season folder the regex's could be setup to ignore those easily.

    I hope this helps others out there. I probably won't have time to tweak these for anyone, so just take these and run with them if changes are needed. I just ask that you post your changes if they help.

    I have my series setup as follows:

    Series.Name\*S01*\blah.s01e01.avi
    Series.Name\*S1*\blah.s01X01.avi
    Series.Name\*S10*\blah.s10.e01.avi
    Series.Name\*Season 01*\blah.e01.avi
    Series.Name\*Season 1*\blah.101.avi
    Series.Name\*S01*\blah.1x01.avi
    Series.Name\*S01*\blah.part1.avi
    Series.Name\*S01*\blah.01.avi
    - and a ton more to boot

    - Series.Name\EXTRAS\* will be ignored allowing you to place all extras into the series subfolder and not have it parsed.
    - Episode Titles will not be parsed. There are other ones here for people that rename their episodes and have titles.

    Regex:
    These are not the most efficient, but I did it this way to give priority to the higher regex's that i can trust better. I could probably move these all into 1, but I don't care enough to. I would enable each of these 7 in a row as ordered here and uncheck any others.

    Code:
    ^(?<series>[^\\$]+?)\\(?:[^\\$]+?)?(?:[Ss](?i:eason\s?)?(?<season>\d\d?).*\\)(?:EXTRAS\\){0}(?:e7)?.*?(?:(?:[Ss]\d{1,2}[Ee]p?(?<episode>\d{1,3})(?:\-[Ee]?(?<episode2>\d{1,3}))?)|\d{1,2}[Xx](?<episode>\d{1,3})).*\.(?<ext>\w{3,4})$
    
    ^(?<series>[^\\$]+?)\\(?:[^\\$]+?)?(?:[Ss](?i:eason\s?)?(?<season>\d\d?).*\\)(?:EXTRAS\\){0}(?:e7)?.*?(?:[Ee]p?(?<episode>\d{1,2})(?:\-[Ee]?(?<episode2>\d{1,2}))?).*\.(?<ext>\w{3,4})$
    
    ^(?<series>[^\\$]+?)\\(?:[^\\$]+?)?(?:[Ss](?i:eason\s?)?(?<season>\d\d?).*\\)(?:EXTRAS\\){0}(?<episode>\d{2})(?:\-(?<episode2>\d{2}))?[^\d].*\.(?<ext>\w{3,4})$
    
    ^(?<series>[^\\$]+?)\\(?:[^\\$]+?)?(?:[Ss](?i:eason\s?)?(?<season>\d\d?).*\\)(?:EXTRAS\\){0}(?:e7)?.*(?:\d{1,2}(?<episode>\d{2})(?:\-(?<episode2>\d{2}))?).*\.(?<ext>\w{3,4})$
    
    ^(?<series>[^\\$]+?)\\(?:[^\\$]+?)?(?:[Ss](?i:eason\s?)?(?<season>\d\d?).*\\)(?:EXTRAS\\){0}.*?(?:(?i:part|episode)\.?\s?(?<episode>\d\d?)(?:\-(?<episode2>\d\d?))?).*\.(?<ext>\w{3,4})$
    
    ^(?<series>[^\\$]+?)\\(?:[^\\$]+?)?(?:[Ss](?i:eason\s?)?(?<season>\d\d?).*\\)(?:EXTRAS\\){0}.*?(?<episode>(\d\d))(?:\-(?<episode2>(\d\d)))?.*?\.(?<ext>\w{3,4})$
    
    ^(?<series>[^\\$]+?)\\(?:[^\\$]+?)?(?:[Ss](?i:eason\s?)?(?<season>\d\d?).*\\)(?:EXTRAS\\){0}.*?(?<episode>(\d)).*?\.(?<ext>\w{3,4})$
     

    dir

    MP Donator
  • Premium Supporter
  • August 30, 2006
    408
    36
    Home Country
    Afghanistan Afghanistan
    Type: Parsing -RegEx
    Description:
    Handles format Cheers\Season 01\s01e01 - blah.avi but also handles:
    seasons greater than 9 (e.g. s32e01)
    4-digit seasons (e.g. s2010e01)
    dollar values in the title (e.g. $25K Final Table)
    So any of the following are valid:
    Expected Filename:
    Aussie Millions\Season 01\s01e01 - Opening Table.avi
    Aussie Millions\Season 01\s01e01-02 - Opening Tables.avi
    Aussie Millions\Season 10\s10e01 - Opening Table.avi
    Aussie Millions\Season 2010\s2010e01 - Opening Table.avi
    Aussie Millions\Season 2010\s2010e01 - $25K Opening Table.avi
    Rule:
    Code:
    (?<series>[^\\$]+)(?:(?:\\(?:Season?)?[ .-]?[0-9]?[0-9])?\\s?(?<season>[0-9]?[0-9]?[0-9]?[0-9])|\\(?:(?:Season?)[ .-])?(?<season>[0-9]?[0-9]?[0-9]?[0-9])\\[^\\]*?)[ex]?(?<episode>\d\d+)(?:[ .+-]e?(?<episode2>\d\d+))?(?:[ -]+(?<title>[\w -.,'!&$][^$]*?))?\.(?<ext>[^.]*)$
     

    RoChess

    Extension Developer
  • Premium Supporter
  • March 10, 2006
    4,434
    1,897
    Variation of default parsing expression for filename processing:

    Code:
    ^(?:.*\\)?(?<series>[^\\]+?)[ _.\-\[]+(?:\(.{3,}\)[ _.\-]*)?(?:[s]?(?:eason\s?)?(?<season>\d+)[ _.\-\[\]]*[ex](?:pisode\s?)?(?<episode>\d+)|(?:\#|\-\s)(?<season>(?!(?:\d{4}.\d{2}.\d{2}|\d{2}.\d{2}.\d{4}))\d+)\.(?<episode>\d+))(?:[ _.+-]+(?:[s]?(?:eason\s?)?\k<season>[ _.\-\[\]]*[ex](?:pisode\s?)?(?<episode2>\d+)|(?:\#|\-\s)\k<season>\.(?<episode2>\d+))|(?:[ _.+-]*[ex+-]+(?:pisode\s?)?(?<episode2>\d+)))*[ _.\-\[\]]*(?<title>(?![^\\].*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$

    This matches all the default expression files (as stated in: https://forum.team-mediaportal.com/threads/expressions-rules-exchange.21977/page-3#post-701043), but it adds the following twist:

    "Show name example (Epsiode title) - S01E01 - BlaBla.ext"

    Is stripped from the "(Episode Title) - " part, so that the "Show name example" can result in a proper match with TheTVdB.

    I do not know of any TheTVdB series that uses parenthesis in their title, but I can not risk that, so this will not become part of the default parsing expression, but a simple manual effort for users who have such a crazy filename scheme.

    PS: Figures, just as I post it I am reminded of "The Office (US)" which would cause a conflict if "(US)" is removed. The only variations I am aware of at TheTVdB is UK and US, which are both 2 letters, so I've modified the expression to only remove "(...)" if the "..." are 3 or more characters (so if you run into an episode title of 2 chars you are screwed). I guess I could look for UK/US specifically, but there might be other country codes in use with TheTVdB that I'm not aware off, so please reply if that's the case or not.
     
    Last edited:

    Users who are viewing this thread

    Top Bottom