•  Previous
  • 1
  • 21
  • 22
  • 23
  • 24
  • 25(current)
 
Thread Rating:
  • 19 Vote(s) - 4.11 Average
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 [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".
Reply
ive been searching for this for too long thanks!
Reply
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
Reply
(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 : Forum rules (wiki) | Banned_Add-ons (wiki) | Debug Log (wiki) || Artwork (wiki) | NFO_files (wiki) | Import-Export_library (wiki) | HOW-TO:Create_Music_Library (wiki)
Reply
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
Reply
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 : Forum rules (wiki) | Banned_Add-ons (wiki) | Debug Log (wiki) || Artwork (wiki) | NFO_files (wiki) | Import-Export_library (wiki) | HOW-TO:Create_Music_Library (wiki)
Reply
Thanks guys for everything. been on hgh for a while and couldn't learn but I have found nice tricks here! Have a good day everybody!!
Reply
  •  Previous
  • 1
  • 21
  • 22
  • 23
  • 24
  • 25(current)



Extra REGEX for TV Show Episode matching4.1119