Kodi Community Forum
Extra REGEX for TV Show Episode matching - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Tips, tricks, and step by step guides (https://forum.kodi.tv/forumdisplay.php?fid=110)
+--- Thread: Extra REGEX for TV Show Episode matching (/showthread.php?tid=51614)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26


RE: Extra REGEX for TV Show Episode matching - Kinematics - 2017-02-11

Been a while since I checked in on this. Just did the update to version 17.

Noticed that @crazygambit put up a new set of regexes and wanted to check how his worked, since mine were having some issues during the update. Unfortunately, I found that it failed almost immediately. For example:

Anime/[SHiN-gx] Fight Ippatsu! Juuden-chan!! - Special 1 [DVD][720x480 AR h.264 FLAC][v2][FF09021F].mkv

will get matched as episode 264. The problem is that it searches for the last number in the filename, but doesn't exclude areas that are bracketed, and likely to have meta-info instead.

On the other hand, I've also found that my own regexes can work without needing two separate sets — one for those with checksum tags, and one for those without. Making it an optional match seems to work just fine, as far as I can tell. I also pulled a little from crazygambit's regex to better ensure that the last number is used. (EG: "KoiKoi 7 - 01" should be episode 1, not episode 7) I also made use of the defaultseason attribute for the regex for "season 0" specials and such.

Here's the new version. It's huge because I put in tons of comments to explain what's being done, and why.

Code:
<tvshowmatching action="prepend">
        <!-- Regex info: -->
        <!-- (?i) turns on case-insensitive matching -->
        
        <!-- If there is only one capture group, kodi will assume that it refers to the episode number, and use the default season. -->

        <!-- Capture group 1: The season.  Season 0 for specials/OVAs/etc. -->
        <!-- Capture group 2: The episode number. -->
        <!-- Capture group 3: The 'part' for a multi-part episode.  EG: Episode 01.1, Episode 01.2, where episode 1 is in two parts. May use numbers 1-9, or letters a-i. -->

        <!-- (?:stuff) is a non-capturing group for 'stuff', so as not to interfere with the above capture groups. -->

        <!-- Anime specific matching. -->
        
        <!--
        Building the regex conceptually from back to front:
        
        Closing checksum (optionally followed by random text, but we don't have to match that) contained in (), {} or [].
        Preceded by any number of bracketed items of any sort of content, with possible spacing, dashes or underscores in between
        Possibly preceded by unbracketed text. Make sure it doesn't find episode numbers inside brackets.
        Preceded by the episode number (optionally labelled), with possible version number
        Preceded by various combinations of dash, dot, underscore or space, to separate the title from the episode number
        Possibly preceded by a season number, or 'Special' or 'OVA'
        -->
        
        <!-- Regexes listed in order of match preference -->
        <!-- The regexes in the prepend set are anchored to checksums, so should be checked before normal Kodi defaults. -->
        
        <!-- Check for explicit S01E01 values -->
        <regexp>S(\d{1,3})E(\d{1,3})(?:[^\\/]*$)</regexp>
        
        <!--
        The regex components.
        
        (?i) -- Always case-insensitive
        
        Normal:
        (?:\bS(?:eason ?)?(\d{1,3})[\s_.-]*)?
          -- Season number identification.
        (?:(?:\b|_)(?:ep?[ .]?)?(\d{1,3})(-\d{1,3})?(?:[_ ]?v\d)?[\s_.-]+)
          -- An episode number (captured) (and possible number range), with optional version. Requires word break beforehand.
        (?![^([{]*\b\d{1,3}(?:[_\s]?v\d+)?\b)
          -- Negative lookahead, so that the matched episode number is the last number in the name prior to any bracketed content.
        (?:\w+[\s_.-]*)*?
          -- Any number of unbracketed words with separators.
        (?:(?:\[[^]]+\]|\([^)]+\)|\{[^}]+\})(?:[\s_]*))*
          -- Any number of bracketed data, such as (DVD), [720p], {FLAC}, etc, with 0 or more spaces or underscores in between.  Brackets have to match.
        (?:[[({][\da-f]{8}[])}])?
          -- Closing checksum.
        (?:[^\\/]*$)
          -- Make sure this is not part of a directory.
        
        OVAs/Specials/Etc:
        (Special|SP|OVA|OAV|Picture Drama)[\s_.-]*
          -- For season 0 instances.
        (?:(?:\b|_)(?:[ .]?)?(\d{1,3})(-\d{1,3})?(?:[_ ]?v\d)?[\s_.-]+)
          -- Episode number for season 0 instances.
        
        Seasons defined in the directory path:
        S(?:eason ?)?(\d{1,3})[\\/](?:[^\\/]+[\\/])+.+?
        -->


        <!-- Anything with the filename marked as Special/OVA/OAV/etc goes to season 0, regardless of what the directory may say. -->
        <!-- Examples:
            [SHiN-gx] Fight Ippatsu! Juuden-chan!! - Special 1 [DVD][720x480 AR h.264 FLAC][v2][FF09021F].mkv
            [gleam] Kurenai OVA - 01 [OAD][0e73f000].mkv
            [Jarzka] Saki Picture Drama 1 [480p 10bit DVD FLAC] [BA3CE364].mp4
            [MaverickSubs] Third Aerial Girls Squad - OVA 2 (Shirobako Vol.7 OVA) [1080p].mkv
            [MaverickSubs] Third Aerial Girls Squad - 02 - OVA (Shirobako Vol.7 OVA) [1080p].mkv
         -->
        
        <regexp defaultseason="0">(?i)(?:Special|SP|OVA|OAV|Picture Drama)(?:(?:\b|[\s_.-]*)(\d{1,3})(?:[_ ]?v\d)?[\s_.-]+)(?![^([{]*\b\d{1,3}(?:[_\s]?v\d+)?\b)(?:\w+[\s_.-]*)*?(?:(?:\[[^]]+\]|\([^)]+\)|\{[^}]+\})(?:[\s_]*))*(?:[[({][\da-f]{8}[])}])?(?:[^\\/]*$)</regexp>

        <regexp defaultseason="0">(?i)(?:(?:\b|[\s_.-]*)(\d{1,3})(?:[_ ]?v\d)?[\s_.-]+)(?:Special|SP|OVA|OAV|Picture Drama)(?![^([{]*\b\d{1,3}(?:[_\s]?v\d+)?\b)(?:\w+[\s_.-]*)*?(?:(?:\[[^]]+\]|\([^)]+\)|\{[^}]+\})(?:[\s_]*))*(?:[[({][\da-f]{8}[])}])?(?:[^\\/]*$)</regexp>
        

        <!-- Then check if we have an explicit season directory. -->
        
        <!-- Inside a directory that specifies the season.  May include any number of subdirectories.  Doesn't try to find season markers in the file name. -->
        <!-- Examples:
            Saki/Season 1/Saki [Jarzka]/[Jarzka] Saki 01 - Encounter [480p 10bit DVD FLAC] [9EED32CB].mkv
            Saki/Season 3/[Underwater-FFF] Saki Zenkoku-hen - The Nationals - 01 (720p) [AF65724D].mkv
            No checksum:
            Saki/Season 2/[HorribleSubs] Saki Episode of Side A - 14 [720p].mp4
         -->
        
         <regexp>(?i)S(?:eason ?)?(\d{1,3})[\\/](?:[^\\/]+[\\/])+.+?(?:(?:\b|_)(?:ep?[ .]?)?(\d{1,3})(-\d{1,3})?(?:[_ ]?v\d)?[\s_.-]+)(?![^([{]*\b\d{1,3}(?:[_\s]?v\d+)?\b)(?:\w+[\s_.-]*)*?(?:(?:\[[^]]+\]|\([^)]+\)|\{[^}]+\})(?:[\s_]*))*(?:[[({][\da-f]{8}[])}])?(?:[^\\/]*$)</regexp>

        
        <!-- Include season marker in the filename. -->
        <!-- Examples:
            [CoalGuys] K-ON!! S2 - 05 [4B19B10F]
            No checksum:
            [DeadFish] Toaru Kagaku no Railgun S - S2 - 01 [720p][AAC].mp4
         -->
        
        <regexp>(?i)(?:\bS(?:eason ?)?(\d{1,3})[\s_.-]*)?(?:(?:\b|_)(?:ep?[ .]?)?(\d{1,3})(-\d{1,3})?(?:[_ ]?v\d)?[\s_.-]+)(?![^([{]*\b\d{1,3}(?:[_\s]?v\d+)?\b)(?:\w+[\s_.-]*)*?(?:(?:\[[^]]+\]|\([^)]+\)|\{[^}]+\})(?:[\s_]*))*(?:[[({][\da-f]{8}[])}])?(?:[^\\/]*$)</regexp>


        <!-- Anything else gets the blank first capture to cause a default season of 1. -->
        
        <!-- Examples:
            [avatar-nyanko] Koikoi 7 - 01 (DVD) [5E95FA4A]
            [gg]_Chuunibyou_Demo_Koi_ga_Shitai!_-_01_[5B6EFD1F]
            [Eclipse] Akane-iro ni Somaru Saka - 01 (1024x576 h264) [39920E63].mkv
            [gg]_Bakemonogatari_-_01_[CC0CF5D2].mkv
            [Doki]_Asobi_ni_Iku_yo!_-_03v2_(1280x720_h264_AAC)_[B5B9C6F3].mkv
            [Coalgirls]_Yuru_Yuri_02_(1280x720_Blu-Ray_FLAC)_[43E5A6B4]
            Touch 01(DVD) - (112ceb61) Central Anime
            Cross Game 02 - Central Anime (1280x720) [BF23052D].mp4
            [Taka]_Naruto_Shippuuden_135_[480p][9073B8C2]
            Multipart:
            [Triad]_Dokuro-chan_-_01.02v2 [12345678].mkv
            No checksum:
            [a.f.k.] Lucky Star - 01.avi
            Air Master - 04 [HQA&N!].avi
            [ANE] Yosuga no Sora - Ep01v2 [BDRip 1080p x264 FLAC]
            [DeadFish] Jinrui wa Suitai Shimashita - 01 [BD][720p][AAC].mp4
         -->

        <regexp>(?i)()(?:(?:\b|_)(?:ep?[ .]?)?(\d{1,3})(?:\.(0?[a-i1-9]))?(?:[_ ]?v\d)?[\s_.-]+)(?![^([{]*\b\d{1,3}(?:[_\s]?v\d+)?\b)(?:\w+[\s_.-]*)*?(?:(?:\[[^]]+\]|\([^)]+\)|\{[^}]+\})(?:[\s_]*))*(?:[[({][\da-f]{8}[])}])?(?:[^\\/]*$)</regexp>
        
    </tvshowmatching>

The last regex should work fine for "absolute ordering" (ie: pure sequential numbering, all under season 1). It puts everything in season 1, and can match anything up to episode 999 (might need to extend that to four digits for One Piece soon, though). It also has no trouble with his example of "Eyeshield 21 124.avi".


RE: Extra REGEX for TV Show Episode matching - poul_l322 - 2017-05-03

ive been searching for this for too long thanks!


RE: Extra REGEX for TV Show Episode matching - Momin - 2017-05-10

What Is Extra Regex? Actually I m Using An Automatic Plugin For wordpress And There Is An Option for Extra Regex So Kindly If Someone Plz Guide Me.....

This Is Link For One oF My Site

@Karellen- Spam link removed


RE: Extra REGEX for TV Show Episode matching - Karellen - 2017-05-15

(2017-05-10, 18:32)Momin Wrote: What Is Extra Regex? Actually I m Using An Automatic Plugin For wordpress And There Is An Option for Extra Regex So Kindly If Someone Plz Guide Me.....

This Is Link For One oF My Site

@Karellen- Spam link removed

Hello Momin,

I am not understanding your links. I believe you are trying to redirect traffic to a site that hosts a large number of Indian movies.

I have deleted references in both your posts.

If I am in error, please post and explain.


RE: Extra REGEX for TV Show Episode matching - Nicolii - 2017-07-08

Hi,

Need some help with my naming scheme it goes:

ShowName\Season SeasonNumber\EpisodeNumber - EpisodeName [Resolution].FileType

For example:

The Wire\Season 01\01 - The Target [1080p].mkv
The Newsroom\Season 02\04 - Unintended Consequences [720p].mp4
Westworld\Season 01\06 - The Adversary [720p].mkv
etc

And also shows without more than one season:

ShowName\EpisodeNumber - EpisodeName [Resolution].FileType

Example:

American Gods\02 - The Secret of Spoons [720p].mkv

But if that's too much trouble I can just sort those into a Season 01 folder.

Thank you


RE: Extra REGEX for TV Show Episode matching - Karellen - 2017-07-08

The Season folders are ignored by Kodi. You would be better off just naming them correctly

The Wire\S01E01 - The Target [1080p].mkv
American Gods\S01E02 - The Secret of Spoons [720p].mkv


RE: Extra REGEX for TV Show Episode matching - TRIROG - 2018-01-24

(2016-03-26, 23:41)rexo Wrote: Hello after some debugging I found way to scan TV Shows all placed in one folder.
With this there is no need to move each show to separate folders:
xml:
<advancedsettings>
<video>
<cleanstrings>
<regexp>[ _\\,\\.\\(\\)\\[\\]\\-](ac3|dts|custom|dc|remastered|divx|divx5|dsr|dsrip|dutch|dvd|dvd5|dvd9|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|r3|r5|bd5|se|svcd|swedish|german|read.nfo|nfofix|unrated|extended|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|3d|hrhd|hrhdtv|hddvd|bluray|x264|h264|xvid|xvidvd|xxx|www.www|cd[1-9]|\\[.*\\])([ _\\,\\.\\(\\)\\[\\]\\-]|$)</regexp>
<regexp>[ _.]?[Ss][0-9]+[ _.x]?[Ee][0-9]+.*</regexp>
<regexp>(\[.*\])</regexp>
</cleanstrings>
</video>
</advancedsettings>

I added this second regex, first and last are copied from Kodi source code.
This second one removes season and episode numbers from name while sending request to info provider.    
 This has finally enabled me to have all the TV Shows in a single folder. TBH the scan can miss some shows especially if there are meny different versions with the same name (e.g. The grand tour a 1997 show and 2016 show) but hey, as far as i'm concerned, this solution beats the hell out of having to run bunch pof different software, just to be able to import into Kodi.

EDIT:
Here are the expressions used by the MPTvseries plugin which worked very well in MP.
xml:

1;regexp;^.*?\\?(?<series>[^\\$]+?)[ _.\-\[]+(?:[s]?(?<season>\d+)[ _.\-\[\]]*[ex](?<episode>\d+)|(?:\#|\-\s)(?<season>\d+)\.(?<episode>\d+))(?:[ _.+-]+(?:[s]?\k<season>[ _.\-\[\]]*[ex](?<episode2>\d+)|(?:\#|\-\s)\k<season>\.(?<episode2>\d+))|(?:[ _.+-]*[ex+-]+(?<episode2>\d+)))*[ _.\-\[\]]*(?<title>(?![^\\]*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$
1;regexp;^.*?\\?(?<series>[^\\$]+?)(?Confused(?<season>[0-3]?\d)\s?ep?(?<episode>\d\d)|(?<season>(?:[0-1]\d|(?<!\d)\d))x?(?<episode>\d\d))(?!\d)(?:[ .-]?(?Confused\k<season>e?(?<episode2>\d{2}(?!\d))|\k<season>x?(?<episode2>\d{2}(?!\d))|(?<episode2>\d\d(?!\d))|E(?<episode2>\d\d))|)[ -.]*(?<title>(?![^\\]*?sample)[^\\]*?[^\\]*?)\.(?<ext>[^.]*)$
1;regexp;^(?<series>[^\\$]+)\\[^\\$]*?(?Confused(?<season>[0-1]?\d)ep?(?<episode>\d\d)|(?<season>(?:[0-1]\d|(?<!\d)\d))x?(?<episode>\d\d))(?!\d)(?:[ .-]?(?Confused\k<season>e?(?<episode2>\d{2}(?!\d))|\k<season>x?(?<episode2>\d{2}(?!\d))|(?<episode2>\d\d(?!\d))|E(?<episode2>\d\d))|)[ -.]*(?<title>(?!.*sample)[^\\]*?[^\\]*?)\.(?<ext>[^.]*)$
1;regexp;(?<series>[^\\\[]*) - \[(?<season>[0-9]{1,2})x(?<episode>[0-9\W]+)\](( |)(-( |)|))(?<title>(?![^\\]*?sample)[^$]*?)\.(?<ext>[^.]*)
1;regexp;(?<series>[^\\$]*) - season (?<season>[0-9]{1,2}) - (?<title>(?![^\\]*?sample)[^$]*?)\.(?<ext>[^.]*)
1;simple;<series> - <season>x<episode> - <title>.<ext>
1;simple;<series>\Season <season>\Episode <episode> - <title>.<ext>
1;simple;<series>\<season>x<episode> - <title>.<ext>
1;regexp;(^.*?\\?(?<series>[^\\$]+?)[ .-]+(?<firstaired>\d{2,4}[.-]\d{2}[.-]\d{2,4})[ .-]*(?<title>(?![^\\]*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$)


They are used together with string replacements:
xml:
1;1;0;-1;(?<=(\s?\.?P[ar]*t\s?)) (X)?(IX|IV|V?I{0,3});<RomanToArabic>
1;1;0;-1;(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+.*))P[ar]*t\s?(\d+)(\s?of\s\d{1,2})?; S01E${1}
1;1;0;1;(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+\s.*))(\d{1,2})\s?of\s\d{1,2}; S01E${1}
1;1;0;1;(?-i)([A-Z])\.(?=[A-Z]);${1}



RE: Extra REGEX for TV Show Episode matching - vc4u - 2018-11-10

Can someone suggest a Regex for support of a 3 episode file? I'm having trouble keeping names in sync with "TV Rename" application and Kodi. Specifically for a show "Justice League", Season 1, Episode 1 to 3. The trouble is, TV Rename application wants to rename the Episode file like "Justice League - S01E01-E03 - Secret Origins" but, when it does then Kodi loses Episode 2, since default regex of kodi needs to support all episodes in file name.

So is there a way I can keep my file name "Justice League - S01E01-E03 - Secret Origins" and Kodi also sees it as a 3 Episode file (Episodes 1, 2 and 3), not just Episode 1 & 3.


RE: Extra REGEX for TV Show Episode matching - picadilly - 2018-12-30

Thanks a lot, I've been searching this for a while ! Big Grin


RE: Extra REGEX for TV Show Episode matching - rexo - 2019-01-23

Hi for current Kodi version I use this:
xml:
    <tvshowmatching>
        <regexp>s([0-9]+)[ ._x-]*e([0-9]+(?Sad?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$</regexp>  <!-- foo.s01.e01, foo.s01_e01, S01E02 foo, S01 - E02, S01xE02 -->
        <regexp>[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$</regexp>  <!-- foo.ep01, foo.EP_01 -->
        <regexp>([0-9]{4})[\.-]([0-9]{2})[\.-]([0-9]{2})</regexp>  <!-- foo.yyyy.mm.dd.* (byDate=true) -->
        <regexp>([0-9]{2})[\.-]([0-9]{2})[\.-]([0-9]{4})</regexp>  <!-- foo.mm.dd.yyyy.* (byDate=true) -->
        <regexp>[\\/\._ \[\(-]([0-9]+)x([0-9]+)([^\\/]*)$</regexp>  <!-- foo.1x09* or just /1x09* -->
        <regexp>[\\/\._ -]([0-9]+)([0-9][0-9])([\._ -][^\\/]*)$</regexp>  <!-- foo.103*, 103 foo -->
        <regexp>[\/._ -]p(?:ar)?t[_. -]()([ivx]+)([._ -][^\/]*)$</regexp>  <!-- Part I, Pt.VI -->
        <regexp>[ _.]?[Ss][0-9]+[ _.x]?[Ee][0-9]+.*</regexp>
    </tvshowmatching>
Last line was added (<regexp>[ _.]?[Ss][0-9]+[ _.x]?[Ee][0-9]+.*</regexp>), and it helps to search tv shows, even placed in few folders deep.
The rest comes from https://kodi.wiki/view/Advancedsettings.xml
Hope it helps.


RE: Extra REGEX for TV Show Episode matching - greenroyd - 2019-02-06

Do you know I have lost all faith in this site because trying to find the right site almost impossible. So I may be and probably am in the wrong place.I have never know a place that is so difficult to reach to explain a problem.If read this and can help then I will listed to advice. I watch quite a lot of films from all years from 1930 to today. If I watch a film then Kodi will not let me watch another film for at least 72 hours. I get a message saying "no thread available) no matter the film. Yesterday Itried to watch 11 different films on 5 different addons with a variety of choices ranging from 9 to 18 and every time I get "ho thread available"


Greenroyd


RE: Extra REGEX for TV Show Episode matching - DarrenHill - 2019-04-26

Well judging by your other thread plus the comments above, you're watching them on banned addons (wiki) so I don't think we particularly care to be honest...

Perhaps if you actually read the forum rules (wiki) that you accepted and agreed to when you signed up here (and also used media that you legitimately have the right to access and view) then things might go more smoothly?


RE: Extra REGEX for TV Show Episode matching - genuinefafa - 2020-04-16

(2015-01-08, 22:50)Kinematics Wrote: The episodes are probably workable as-is (including the parent folder for the rar), but I'm pretty sure that the show name will fail in that format. For it to find the show name, the folder has to be the show name itself, with possible year or origin markers (eg: Castle (2009), Being Human (US), etc). Putting the season information in that folder name probably breaks it. You can put the season number in a subfolder, though (eg: TV/How I Met Your Mother/Season 1/etc). That info can be extracted when you parse the filename, but since you have the SxxExx in the filename itself, it's a bit redundant for that purpose (but still handy for organization).

If there's not a specific need to have the season number in the folder name of the show itself, that's what I'd change.

As for how to parse it without making any changes, I don't know. I haven't been able to find the part of the code that handles extracting the show name, and the wiki just glosses over things, basically telling you what I said above.
is there a way to strip the ending of the fold to scrape? I mean, If I'ld like to have something like - following the example.

tv show title season 01\episode.s01e01...
tv show title season 01\episode.s01e02...
​​​​​​​tv show title season 01\episode.s01e03...
tv show title season 02\episode.s02e01...
​​​​​​​tv show title season 02\episode.s02e02...
​​​​​​​tv show title season 02\episode.s02e03...

it feels right and easy to look around when accessing files directly, off course.

maybe a regex that Kodi passes before doing title recognition... something like "take out last 'season xx' from directory name to get the title...


RE: Extra REGEX for TV Show Episode matching - fletcher1 - 2021-02-01

(2009-05-24, 11:36)xexe Wrote:
In simple terms adding this to your Kodi configuration will match more TV shows than Kodi will by default.

After several months assisting users via IRC I decided to create a generic set of additional REGEX expressions to catch TV episodes Kodi does not and will not by default (e.g. Topaz etc) for fun. Quite a bit of offline testing has been completed, and whilst I am confident I cannot guarantee this REGEX will not produce some false positives.

The method used in this REGEX differs from Kodi default methodology in SOME places by extracting the season number from folder names rather than the file name. By doing this we can match stuff that otherwise could never be matched.


Examples:

13.show.dvd.avi only has the ep number but "MyShow/season 2/13.show.dvd.avi" has both.
"MyShow/season 5/4400513.show.dvd.avi has a show name that includes numbers making matching very difficult.

Installation

Adding additional TV episode matching is simply a matter of inserting the code listed later to the a file called advancedsettings.xml.
To locate and understand this XML file read the first part of this link Advancedsettings (wiki)
Remember by default advancedsettings.xml will NOT exist. Also note the name of this file IS CASE SENSITIVE and will require a Kodi restart to be applied.
End to end installation should take no more than 2 minutes.

Required Folder Structure

Approximately 50% of this REGEX requires you to have a sensible folder structure for your TV shows as follows:

/showname/season x/episodes e.g. The Unit/season 2/the.unit.203.avi

=2Note: Case is irrelevant
=2Note: This is "Season 1" and NOT "Season 01"

If you do not have this structure 50% of these REGEX's will NOT work for you.

I have had some requests to support different structures. Whilst I am happy to accommodate some slight differences I cannot support multiple languages or weird ass structures. In the end trying to support this would make the REGEX ridiculously complicated for the majority of users whilst only helping a minority.

The chosen structure was decided on after months of seeing what users had developed on their own. Most came to this structure independently and I am happy with it.

Feedback

You are welcome to experiment with this REGEX and report back if you need help or have some suggestions.

I will maintain these first few post. I will happily add new REGEX under a few small conditions:

1. The format you are trying to match allows for a good chance of no false positives i.e. its not my intention to try and deal with absolute rubbish naming dredged from the bowels of the internet.
2. The format you are trying to match will be useful to other people. If the matches will only ever be of use to you alone then this set is not the place for it.
3. If you are suggesting REGEX please supply a couple of examples of the full path you are matching against so I/we can test it.
4. I wont be adding REGEX or updating the existing ones with über complex/1337 REGEX just because it can be done more cleverly. Or put another way we need to keep these simple so normal users can get to grips with them.


Support

If you wish support please do the following (NONE OF WHICH ARE OPTIONAL
):

#Update to the very latest stable release of Kodi.
#Post a COMPLETE debug log to pastebin.com (no where else) and link it here (make sure this log catches the update library procedure.
#The DEBUG log should contain lines with "DEBUG: could not enumerate file" or entry's which are matched incorrectly. If it does not contain these elements then you do not need help.
#The DEBUG log should show that you are using this complete REGEX set and not small parts of it. The reason for this is that I cannot easily identify which set you are running but mostly the order in which these REGEX run is very important.

If you don't do these 4 simple things I cannot help and wont even bother. Sorry but time is to short to help those that wont help themselves Smile

An again... DO NOT post hand written examples of problem file names or things you wish to match. I NEED the failed to enumerate lines to see what Kodi is seeing not what you think it is seeing.

[/b]

Please, this thread is for discussions on THIS REGEX compilation only. It is not for random REGEX support, how do i setup advancedsettings, why doesn't my library work or anything else. For all other topics create a new thread.

Happy hunting Smile
Is this method viable? I used it but it didn't work.


RE: Extra REGEX for TV Show Episode matching - Janrover - 2021-02-23

(2009-05-24, 11:36)xexe Wrote:
In simple terms adding this to your Kodi configuration will match more TV shows than Kodi will by default.

After several months assisting users via IRC I decided to create a generic set of additional REGEX expressions to catch TV episodes Kodi does not and will not by default (e.g. Topaz etc) for fun. Quite a bit of offline testing has been completed, and whilst I am confident I cannot guarantee this REGEX will not produce some false positives.

The method used in this REGEX differs from Kodi default methodology in SOME places by extracting the season number from folder names rather than the file name. By doing this we can match stuff that otherwise could never be matched.


Examples:

13.show.dvd.avi only has the ep number but "MyShow/season 2/13.show.dvd.avi" has both.
"MyShow/season 5/4400513.show.dvd.avi has a show name that includes numbers making matching very difficult.

Installation

Adding additional TV episode matching is simply a matter of inserting the code listed later to the a file called advancedsettings.xml.
To locate and understand this XML file read the first part of this link Advancedsettings (wiki)
Remember by default advancedsettings.xml will NOT exist. Also note the name of this file IS CASE SENSITIVE and will require a Kodi restart to be applied.
End to end installation should take no more than 2 minutes.

Required Folder Structure

Approximately 50% of this REGEX requires you to have a sensible folder structure for your TV shows as follows:

/showname/season x/episodes e.g. The Unit/season 2/the.unit.203.avi

=2Note: Case is irrelevant
=2Note: This is "Season 1" and NOT "Season 01"

If you do not have this structure 50% of these REGEX's will NOT work for you.

I have had some requests to support different structures. Whilst I am happy to accommodate some slight differences I cannot support multiple languages or weird ass structures. In the end trying to support this would make the REGEX ridiculously complicated for the majority of users whilst only helping a minority.

The chosen structure was decided on after months of seeing what users had developed on their own. Most came to this structure independently and I am happy with it.

Feedback

You are welcome to experiment with this REGEX and report back if you need help or have some suggestions.

I will maintain these first few post. I will happily add new REGEX under a few small conditions:

1. The format you are trying to match allows for a good chance of no false positives i.e. its not my intention to try and deal with absolute rubbish naming dredged from the bowels of the internet.
2. The format you are trying to match will be useful to other people. If the matches will only ever be of use to you alone then this set is not the place for it.
3. If you are suggesting REGEX please supply a couple of examples of the full path you are matching against so I/we can test it.
4. I wont be adding REGEX or updating the existing ones with über complex/1337 REGEX just because it can be done more cleverly. Or put another way we need to keep these simple so normal users can get to grips with them.


Support

If you wish support please do the following (NONE OF WHICH ARE OPTIONAL
):

#Update to the very latest stable release of Kodi.
#Post a COMPLETE debug log to pastebin.com (no where else) and link it here (make sure this log catches the update library procedure.
#The DEBUG log should contain lines with "DEBUG: could not enumerate file" or entry's which are matched incorrectly. If it does not contain these elements then you do not need help.
#The DEBUG log should show that you are using this complete REGEX set and not small parts of it. The reason for this is that I cannot easily identify which set you are running but mostly the order in which these REGEX run is very important.

If you don't do these 4 simple things I cannot help and wont even bother. Sorry but time is to short to help those that wont help themselves Smile

An again... DO NOT post hand written examples of problem file names or things you wish to match. I NEED the failed to enumerate lines to see what Kodi is seeing not what you think it is seeing.

[/b]

Please, this thread is for discussions on THIS REGEX compilation only. It is not for random REGEX support, how do i setup advancedsettings, why doesn't my library work or anything else. For all other topics create a new thread.

Happy hunting Smile

Thank you