Better ABsolute Scanner (BABS)

Hey guys, sorry for breaking things!  It was a bit of a surprise to me that this scanner and at least one other third party scanner is importing things directly from the official scanner, since the signatures of the methods used internally are not controlled by the Framework or any API, and (as you've discovered) may be subject to change.  They don't tend to change often, of course, but a safer approach would be to maintain the needed functionality in a standalone way without these dependencies.

Having said that, absolute episode ordering is something that's been requested quite a bit, and I'd like to see if we can do a better job of supporting it in the official scanner.  The issue, as the OP points out, is that there's ambiguity between two fairly popular conventions (i.e. "102" taken to mean "Season 1 Episode 2" and "102" taken to mean "Episode 102").  I don't think it would be wise to modify the existing behavior (in which "102" means "Season 1 Episode 2") across the board, and making this a preference would require a change to core PMS since there's no way to do this in the plug-in right now.

Thanks to biorummet and EntroX for fixes on this. I found this problem today and fixed it--then checked the forums and saw you guys were ahead of me. I also found some issues in the AbsTVDB metadata agent that goes with this scanner (failing searches for "Fix Incorrect Match").

... a safer approach would be to maintain the needed functionality in a standalone way without these dependencies.

If you have any hints on how to make the functionality standalone without duplicating the Plex code, please pass them along. When I made this scanner and the agent a couple of years back, I couldn't see any way other than creating a separate package. I haven't been following Plex development closely, so if there's a way to make this less dependent on the Plex code, I'm willing to investigate that path.

Also, for anyone interested, I'm hoping to be able to post an update for BABS and AbsTVDB in the next week or two. I'm looking at another change someone suggested and trying to figure out how best to make the code available to people who want it. I'll probably fork the Plex repo on GitHub and maintain BABS and AbsTVDB there in the future. I'll post an update here when I have it sorted out.

I have a problem, plex will overwrite the BABS scanner after some time, can I make it stop with those folishness?

Same here. BABS Scanner is often deleted. I'm using PMS on a Synology

I had several problems with the scanner. the first being the scanner counted the opening and endings for a show as an episode rather than ignore them. so a file named "Anime - OP01.mkv" would be mistaken as episode one for show anime. I modified the regex so it would not match the episode if "OP", or "ED" was directly behind the number.
 
Lines 43-50 of BABS.py
just_episode_regexs = [
    '(?P[0-9]{1,3})[\. -_]of[\. -_]+[0-9]{1,3}',       # 01 of 08
    '^(?P[0-9]{1,3})[^0-9]',                           # 01 - Foo
    '(^|[ \.\-_])e(p{0,1}|(pisode){0,1})[ \.\-_]*(?P[0-9]{2,3})([^0-9c-uw-z%]|$)', # Blah Blah ep234
    '.*?[ \.\-_](?P[0-9]{2,3})[^0-9c-uw-z%]+',         # Flah - 04 - Blah
    '.*?[ \.\-_](?P[0-9]{2,3})$',                      # Flah - 04
-    '.*?[^0-9x](?P[0-9]{2,3})$' # Flah707 
+    '.*?[^0-9x](?<!OP)(?<!ED)(?P\d{2,3})' # Flah707 as long as it isn't precede by op, ed
  ]
 
The second problem I had was for the show "3x3 Eyes" all episodes where mistaken as being part of season 3 episode 3. Below this is the part I edited to make it so it doesn't try to find the episode number in the name of the show.
Lines 281-287 of BABS.py
          print "BABS: after whackRx, file = |", file, "|"
 
+          #BABS: Before matching for episdodes replace the show name with an X to prevent the regex from matching the show name
+          #important for 3x3 Eyes since 3x3 generally means season 3 episode 3
+          file = re.sub(show, 'X', file)
          
          for rx in episode_regexps:

I have included an attachment with a copy of the script that reflects these changes.

I was really excited about using BABS to try to handle anime, i.e. Fairy Tale with 175 episodes.  It gets the absolute ordering correct, but thetvdb scanner still doesn't work (it only works on the first season stuff and the rest don't scrape metadata until episode 101, which it treats as episode 01 again.  I tried using the Anidb plugin, but that just crashes plexmediaserver after a few seconds.  Any ideas how to properly address this?  I have my episodes inside a directory named Fairy Tail and named like this...

Fairy Tail - 01 - The Fairy Tail.mkv
Fairy Tail - 02 - Fire Dragon, Monkey, and Bull.mkv
Fairy Tail - 03 - Infiltrate the Everlue Mansion.mkv
Fairy Tail - 04 - Dear Kaby.mkv
Fairy Tail - 05 - The Wizard in Armor.mkv
Fairy Tail - 06 - Fairies in the Wind.mkv
Fairy Tail - 07 - Flame and Wind.mkv
Fairy Tail - 08 - The Strongest Team!!!.mkv
Fairy Tail - 09 - Natsu Devours a Village.mkv
Fairy Tail - 10 - Natsu vs. Erza.mkv
Fairy Tail - 100 - Mest.mkv
Fairy Tail - 101 - Black Wizard.mkv
Fairy Tail - 102 - Iron Soul.mkv
Fairy Tail - 103 - Makarov Charges.mkv
Fairy Tail - 104 - Lost Magic.mkv
Fairy Tail - 105 - Fire Dragon vs. Flame God.mkv
Fairy Tail - 106 - Grand Magic World.mkv
Fairy Tail - 107 - Arc of Embodiment.mkv
Fairy Tail - 108 - Human Gate.mkv
Fairy Tail - 109 - Lucy Fire.mkv
Fairy Tail - 11 - The Cursed Island.mkv
etc...

Hey Rubylaser,

You need to use the abstvdb agent with the babs scanner to get your anime correct. This will search based on absolute ordering - which is what you have.

The best way to do it is to have your anime in it's own library so it doesn't mess up tv or movies or anything like that. 

Hope that helps.

Hey Rubylaser,

You need to use the abstvdb agent with the babs scanner to get your anime correct. This will search based on absolute ordering - which is what you have.

The best way to do it is to have your anime in it's own library so it doesn't mess up tv or movies or anything like that. 

Hope that helps.

Thanks, I have them in an Anime section already, I'll try out the abstvdb agent right now :)

Edit: This solution works flawlessly.  Thanks for the simple instructions!

Hi,

Is it possible to combine the functionality of BABS and AbsTVDB, so that BABS uses the TVDB absolute number to determine the season/episode number?  For example, Fairy Tail 103 would sit in Season 3 (with Episode 7), as opposed to being lumped together in one season on Plex?

Edit: A similar question was posted on the AbdTVDB forum post, but did not receive any replies.

My One Piece is broken down in the 17 seasons per the The TVDB website. I was able to accomplish that by putting each episode into the correct season header.

For example:

Season 15 has episode 519 in it (that would be 15x01). so it does not display 15x01 on plex, it displays 519, but there are the folder headings to help break it up.

So depending on what you were hoping to accomplish, that may help. If you just wanted to make it easy to scroll, yes. If you wanted it to actually say 15x01, then it will not (from what i have seen). Meaning it won't convert abs to seasonXepisode

My aim was to leave the anime folder structure as-is (so, using One Piece as an example - I get my OP from yibis, and they use absolute ordering, which I just copy into my Anime/One Piece folder).  Because the season structure (as seen in the Plex interface) is determined solely by the scanner, my thoughts were that if you could define a TVDB ID for an anime, you could read that while scanning to determine what season/episode number each item should be assigned (because the season structuring, from what I can tell, is based on a 'Season' metadata field, and not the actual folder structure).  Right now, for absolute numbering, the season is forced to 1 (there's a season = 1 statement in the code).

With that, I've been able to test the creation/reading of a 'tvdb.id' field in the anime folder (a one-line modification of BABS), but what I haven't gotten round to doing is parsing the TVDB ID and the subsequent data from the website (because I have no idea how I will do that).  Hopefully, it won't be that difficult...

Edit:  It wasn't overly difficult.  I've modified BABS to look for a 'tvdb.id' file in the anime directory (which is a single-line file containing the anime ID as given by TVDB).  If it finds this file, the scanner then downloads the XML file from TVDB containing the show details, parses it, and figures out what the season/episode number should be based on the absolute number.  I'm just running a through test right now, but it was working fine for One Piece and Fairy Tail.  There's quite a bit of overhead, because it has to download the XML twice - once when scanning, and again when matching, but as far as I'm aware, there's no way around that.  I'll post up the file tomorrow once I'm sure it doesn't break anything.

I've included a download to my modified S - BABS (for Series - BABS), which sorts absolute-numbered items in series.  To run this, you will need to follow the regular instruction for setting up a scanner, and in addition, you will need to include a tvdb.id file in the anime folder which contains the ID of the anime (which you obtain from TVDB).  I've included a sample tvdb.id file for Fairy Tail (zipped to allow upload: tvdb.zip (118 Bytes)).

Screenshot of One Piece sorting: http://imgur.com/MnSSsre

Screenshot of Fairy Tail sorting: http://imgur.com/mxqO40H

This has been tested on Ubuntu, but should be cross-compatible with other platforms.

Thank you so much! Finally my Anime section will be tidy and clean :'D

I'm using both BABS and AbsTVDB. If I have all of the episodes in the root folder of the anime series it finds the correct metadata for the episode. For example episode #176, if the root folder of naruto shippuuden, downloads the metadata correctly for "Rookie Instructor Iruka" but in Plex it puts it in a season 01 sub directory. If I move that episode into a season 09 folder on my hard drive the metadata won't download correctly. Am I doing something wrong?

I'm using both BABS and AbsTVDB. If I have all of the episodes in the root folder of the anime series it finds the correct metadata for the episode. For example episode #176, if the root folder of naruto shippuuden, downloads the metadata correctly for "Rookie Instructor Iruka" but in Plex it puts it in a season 01 sub directory. If I move that episode into a season 09 folder on my hard drive the metadata won't download correctly. Am I doing something wrong?

The default BABS puts everything into season 1, if it detects an absolute structure series (like what you have).  Putting it into a separate Season 9 folder just means that it treats it as season 9, episode 176.

The Series BABS (S - BABS) I've linked above solves that problem (see three posts above this one), and it correctly converts the absolute number (in this case, episode 176, into season 9 episode 1).

Awesome, so with your S-BABS modification should I keep it in absolute structure order on the drive, make an tvdb.id file, and then it will populate in the plex database with season directories? Or do I have to also make the season directories on the drive. 

You need to keep it in absolute structure and make a tvdb.id file, and it will populate the season metadata in Plex.  So, you don't need to create season folders.

Well, what can I say.  It's working perfectly. Thanks for your help Sjai! Just wondering, what do you do with specials that don't have an absolute number with them?

No problem, DFLeiva.  Specials should still work as normal (i.e. by putting them in a Season 0 folder in the same folder as the anime), although I haven't tested this.

Thank you SO MUCH this scanner works great for me!! Totatlly solved all my Anime numbering problems! :)