2

I'm trying to adjust KODI's search filter with regex so the scrapers recognize tv shows from their original file names.

They either come in this pattern: "TV show name S04E01 some extra info" or this "TV show name 01 some extra info" The first is not recognized, because "S04" scrambles the search in a number of ways, this needs to go. The second is not recognized, because it needs an 'e' before numbers, otherwise, it won't be recognized as an episode number.

So I see two approaches.

  1. Make the filter ignore s01-99

  2. prepend an 'e' any freestanding two-digit numbers, but I worry if regex can even do that.

I have no experience in the regex, but I've been playing around coming up with this, which unsurprisingly doesn't do the trick

^(?!s{00,99})\d{2}$
Manoj
  • 2,000
  • 2
  • 16
  • 21
Sc0rax
  • 23
  • 5
  • Can you be more specific? You have `TV show name S04E01 some extra info` and `TV show name 01 some extra info`. Now, what do you want to get as a result? What tools are you using to get the result? What exactly are you trying and what does not work? How does it work? – Wiktor Stribiżew Jan 25 '21 at 15:25
  • Yes, please add more details straight to the question. – Wiktor Stribiżew Jan 29 '21 at 12:08
  • I had a feeling I was too unspecific in my original post. so I can source my shows in two formats, either with "S01E01" or just "01" I can select which one to take depending on which filter I'm able to get. It'll assume S01 if there is nothing. The only way Kodi scraper understand tv show episodes is the "E01" format. If theres a "S02-S99" prepended to it, it causes problems, especially with anime, having individual folders for each season. 4th season of Attack on Titan is called "Attack on Titan: The Final Season" To Kodi, this is S01 of the final season, so better leave it out. – Sc0rax Jan 29 '21 at 12:20
  • kodi has an inbuilt regex filter which can be adjusted/appended to if needed. kodi.wiki/view/Advancedsettings.xml (tvshowmatching section in this case) I am trying for this filter to either ignore all "S00-S99" contents of a filename or add an "E" to a free standing double digit in a filename, depending which kind of sourcefile I'll select. I only need one of either solution to work and will adjust the source material accordingly. (releasegroups have only these two kinds of naming policies) – Sc0rax Jan 29 '21 at 12:26
  • Ok, adding `E` to any double digit is easy: `\b([0-9]{2})\b` => `E$1`, but you need to use a specific regex replace method. I do not know if kodi has one. – Wiktor Stribiżew Jan 29 '21 at 12:32
  • If you want to match `s01-99`, you may simply use `\bs(0[1-9]|[1-9][0-9])\b` – Wiktor Stribiżew Jan 29 '21 at 12:35

1 Answers1

1

You may either find \b([0-9]{2})\b regex matches and replace with E$1, or match \bs(0[1-9]|[1-9][0-9])\b pattern in an ignore filter.

Details

  • \b([0-9]{2})\b - matches and captures into Group 1 any two digits that are not enclosed with letters, digits and _. The E$1 replacement means that the matched text (two digits) is replaced with itself (since $1 refers to the Group 1 value) with E prepended to the value.
  • \bs(0[1-9]|[1-9][0-9])\b - matches an s followed with number between 01 and 99 because (0[1-9]|[1-9][0-9]) is a capturing group matching either 0 and then any digit from 1 to 9 ([1-9]), or (|) any digit from 1 to 9 ([1-9]) and then any digit ([0-9]).

NOTE: If you need to generate a number range regex, you may use this JSFiddle of mine.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563