• 1
  • 21
  • 22
  • 23
  • 24
  • 25(current)
Extra REGEX for TV Show Episode matching
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 [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.

<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 -->
        The regex components.
        (?i) -- Always case-insensitive
        (?:\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.
          -- Negative lookahead, so that the matched episode number is the last number in the name prior to any bracketed content.
          -- Any number of unbracketed words with separators.
          -- Any number of bracketed data, such as (DVD), [720p], {FLAC}, etc, with 0 or more spaces or underscores in between.  Brackets have to match.
          -- Closing checksum.
          -- Make sure this is not part of a directory.
        (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 [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]
            [Eclipse] Akane-iro ni Somaru Saka - 01 (1024x576 h264) [39920E63].mkv
            Touch 01(DVD) - (112ceb61) Central Anime
            Cross Game 02 - Central Anime (1280x720) [BF23052D].mp4
            [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>

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".
ive been searching for this for too long thanks!
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
(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.
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki) || Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)

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

And also shows without more than one season:

ShowName\EpisodeNumber - EpisodeName [Resolution].FileType


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
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
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki) || Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
(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:
<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>

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.

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

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:
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}
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.
Thanks a lot, I've been searching this for a while ! Big Grin
Hi for current Kodi version I use this:
        <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>
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.
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"

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?
|Banned add-ons (wiki) Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

My Blog Posts
(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...
  • 1
  • 21
  • 22
  • 23
  • 24
  • 25(current)

Logout Mark Read Team Forum Stats Members Help
Extra REGEX for TV Show Episode matching19
This forum uses Lukasz Tkacz MyBB addons.