Regular expressions and substitution
#1
Hello,

Is it possible to have regex matching a string in a episode name, for example 'Special', and from that change how that episode is named when added to the library? The reason I am wanting to do this is because some series I have could both have no season numbering with episode numbering starting on 01, and have some additional special episodes that could be numbered starting from 01 as well. This makes for a very confusing library viewing of that series, since it will treat all such occurrences as identical episodes and they will appear in the library as such.

If the actual filenames are 'Some series 01.mkv' and 'Some series Special 01.mkv', then XBMC will scrape them into the library as identical episodes, which they are not. Manually editing the titles of all such occurences would be very cumbersome, as my library has become rather vast and is still growing.

I have looked into what may possible with advancedsettings.xml, but I could not find something like this.

Thank you for reading.
Reply
#2
This should be possible with recent nightly builds. I'm not sure if it's made it to the wiki yet, so check the Pull Request on github for usage details.
Reply
#3
That is brilliant, thank you. :-)

Though, it may seem like the latest nightly is having trouble connecting to the scraper.

22:45:17 T:2953850880 DEBUG: GetEpisodeList: Searching 'http://api.anidb.net:9001/httpapi?request=anime&client=xbmcscrap&clientver=1&protover=1&aid=8163' using AniDB.net scraper (file: '/Users/user/Library/Application Support/XBMC/addons/metadata.anidb.net', content: 'tvshows', version: '2.0.0')
22:45:17 T:2953850880 DEBUG: CurlFile::Open(0xb01025d4) http://api.anidb.net:9001/httpapi?reques...1&aid=8163
22:45:17 T:2953850880 WARNING: FillBuffer: curl failed with code 7
22:45:17 T:2953850880 ERROR: CCurlFile::CReadState::Open, didn't get any data from stream.
22:45:17 T:2953850880 ERROR: Run: Unable to parse web site
Reply
#4
Nah, anidb.net is just down. It does that sometimes.
Reply
#5
Ah, quite right. It works again. I am however, still not getting the special episodes added to my library after changing to the nightly and using the season 0 regex. It does match the episodes.

02:41:23 T:2953850880 DEBUG: VideoInfoScanner: Found episode match smb://server/media/some series/some series - special 01 [720p].mkv (s0e1) [special[s]?[_ \-]+([0-9]+)(-[0-9]+)?[_ \-]]

Then there is this:

02:41:23 T:2953850880 DEBUG: VideoInfoScanner: No NFO file found. Using title search for 'smb://server/media/some series/some series - Special 01 [720p].mkv'
02:41:23 T:2953850880 DEBUG: GetEpisodeList: Searching 'http://api.anidb.net:9001/httpapi?request=anime&client=xbmcscrap&clientver=1&protover=1&aid=7440' using AniDB.net scraper (file: '/Users/user/Library/Application Support/XBMC/addons/metadata.anidb.net', content: 'tvshows', version: '2.0.0')
02:41:23 T:2953850880 DEBUG: scraper: GetEpisodeList returned <episodeguide></episodeguide>

It did not find anything for that title?

Kind of strange, since they had been added with earlier settings prior to the nightly build, using stable Eden. After updating to the nightly and changing my advancedsettings.xml file, I removed the relevant files from my library and did a new scan.

Removing the season 0 regex lets the episodes return to being discovered as season 1, but the results are the same as when using the season 0 regex. They seem to not be found on the scraper and are not added to my library.

Any ideas?
Reply
#6
Double-check (and/or delete) your cache. The anidb scraper retains cached files for 48 hours, so it's possible that XBMC is not actually getting the episode list from anidb.net but from a broken/empty cached file.

The cache should be in the same folder as your userdata folder (wiki) (but not in the userdata folder), on windows this will be %APPDATA%\XBMC\cache. Specifically, you want the scrapers\metadata.anidb.net subfolder.
Reply
#7
Thank you for the suggestion. I found the folder in OSX on /Users/user/.xbmc/temp/scrapers/metadata.anidb.net, deleted it, and after that the episodes were scraped and put in my library. :-)

The only remaining thing I would like changed is that the special episodes are put in along with the first season episodes, even if XBMC is set to flatten only on series with one season. I would not mind as much, had only the sorting been good, but it isn't, I have to carefully read the names in order to play them in the right order.

I usually have my XBMC configured to flatten series if there is only one season, and in this case it is treating the series as being just one season. I had to select to always flatten in order to get it to display a "Specials" folder. I quite like that it is treating them as being a Special season in this way. As mentioned previously though, the special episodes will be listed double, both in "Season 1" and the "Specials" folder.

On the other hand, an app I have on my iPad to remotely control XBMC, will show both a "Season 1" folder and a "Specials" folder even if XBMC itself is configured to flatten only on series with one season. However, the "Season 1" folder on the iPad still contains the special episodes as well.

In the "Season 1" folder the specials are named Sx01 .. Sx04 etc, while the true first season episodes are named 1x01 .. 1x04 etc. You would think that it would group Sx episodes together and then 1x episodes together or the other way around, but they are mixed a bit oddly.

I'm not sure if this is something that could be fixed in XBMC core or in the scraper?
Reply
#8
The specials will be mixed in based on data from tvdb, but you can turn this off in the scraper settings. Go to your anime source in XBMC, bring up the context menu and select "Change content", and then press the Settings button. The option is right at the bottom of the AniDB tab - "Map specials inside of episode list" - turn that off.

If you set the option above it - "Map specials at the end of episode list" to on, then with flattening turned off, they shouldn't appear in the season 1 folder, only in the Specials folder. The specials in this case get attached to season 2, but without any actual season 2 episodes, the season 2 folder isn't shown. That's just based on my brief experimentation just now, I haven't checked thoroughly.
Reply
#9
Oh, I did not know of or think to look at those options. Thank you. I just updated to todays nightly as well.

I still prefer to keep the "flatten only if one season" feature on, there are just so many series with one season and it's nicer just opening a series folder and seeing all the episodes there in that case. Adding just a single "Season 1" folder to the structure feels unnecessary and adds an extra click to the browsing. Having the specials sorted at the end, after the season one episodes is fine, though I would prefer a separate folder for them. Which I kind of get, since I have that on my iPad app.

XBMC just keeps getting better. :-)

Tweaking my regex for various cases of OVA/specials and everything should be in order. :-)
Reply

Logout Mark Read Team Forum Stats Members Help
Regular expressions and substitution0