ZeroQI / Absolute-Series-Scanner

Seasons, absolute mode, Subfolders...
1.01k stars 155 forks source link

Enhancement: TVDB4 (Arc Mode) #34

Closed sven-7 closed 8 years ago

sven-7 commented 8 years ago

Actually saw this mentioned by @MagellanSails on the TVDB forums a while back.

For long-running shows, TVDB arbitrarily splits them up into seasons sometimes. If you're lucky, like One Piece, they make sense. If you're unlucky, like Hunter X Hunter, they don't. It's 3 random seasons on TVDB. But it would be really neat to split them into arcs. User-defined, of course. Not sure if this is actually possible, but could a theoretical TVDB4 (Arc Mode) mode do this:

In this case, it would be up to the user to find season/arc posters where they don't exist in TVDB.

Right now HxH (arbitrarily) is like this:

A better way to split it up would be (TVDB4 - Arc Mode):

This is how I filed/defined my HxH files before moving to TVDB3 (purely for all eps to have Metadata). I'm not sure how much this would be used, but it would definitely be another unique trait of ASS over other scanners. Some other shows people might like to self define arcs for could be: Dragonball Z, Dragonball, One Piece, Naruto, Bleach, Fairy Tail...

ZeroQI commented 8 years ago

For now theses folders are ignored: (Story )Ark/Arc/Video ... (in code '(([Ss]tory )?[Aa]r[kc]|[Vv]ideo).*') That allow for arc folders on disk to have no impact on plex numbering, like: . [01] Story Arc Hunter Exam . [001-031] Arc Hunter Exam We would need to allow tvdb4 in the scanner and allow in the agent to use absolute numbering with kinda random seasons (or any seasons).

sven-7 commented 8 years ago

I think keeping the story/arc/ark/etc... ignore is fine. I would have those labeled as Seasons 1-7 with absolute numbers within them.

EndOfLine369 commented 8 years ago

Interesting enhancement.

Now I don't think it would be required to be a tvdb id'ed tvdb4. The tvdb2/3 were required to be tvdb because we needed the tvdbid defined for the scanner to figure out the seasons for the files from TheTVDB. In this instance, we don't require TVDB info in the scanner. This should be doable under both an anidb and tvdb labels. So not sure how we should label these.

One q i do have though is should it be required for the episodes to be in season folders for arc season definition only? Or do we also want to allow the option of a mapping file that only maps the files in the same directory to a season.

Or maybe a site we could source for arc info?

ZeroQI commented 8 years ago

Episode summaries rely on tvdb so having to specify the tvdbid while un-necessary, would be consistent with other modes ... The behavior is extremely similar to tvdb3 mode which we could split in two behavior: . no seasons defined: we use tvdbid seasons . seasons defined (for archs), we use the absolute numbering to get ep summary regardless of the seasons, could help series split into seasons arbitrarily every 100 episodes for example but only if episode numbering doesn't go back down when changing seasons...

Started looking at the code but my OCD led me astray on section "HAMA - Load logs, add non-present entries ....". will have time this afternoon to look at code

sven-7 commented 8 years ago

I agree with @ZeroQI. I think that behavior would be perfect for this.

@EndOfLine369 -- unfortunately, there really isn't a site that we could source the info from. In addition to the Arc style I suggested above and since this idea has popped up, I thought of some additional uses for it. Let's take the show: Seraph of the End.

AniDB considers it two TV shows:

Seraph of the End: Vampire Reign Seraph of the End: Battle in Nagoya

TVDB considers it to be one show, but also only one single season, not two. As a background, TVDB as a policy has decided that split-cour anime will still be considered one season, not two. Largely because the second season does not start over at 1, but typically continues with the absolute number of 13/14.

With this "TVDB4" mode, I could split them into separate seasons in my file system and essentially get the best of both. One series, with two seasons, continued with absolute numbering. Hopefully this makes sense....

I would then have it labeled as:

Seraph of the End/Season 01 (contains eps 1-12)
Seraph of the End/Season 02 (contains eps 13-24)
EndOfLine369 commented 8 years ago

Makes sense. So this would not actually be an Arc mode but more of a Custom Season mode for TVDB series. Which adds more weight to it being a tvdb id only.

ZeroQI commented 8 years ago

Correct. i believe we can handle on tvdb3: . normal tvdb3 mode which is tvdb seasons keeping absolute numbering (one piece, etc...) . anidb series separated but showing as one season in tvdb (need abs numbering for eps but manage separated seasons as with Seraph of the End):

so far i have numbering = currentAbsNum if defaulttvdbseason=="a" or metadata.id.startswith("tvdb3-") and not currentSeasonNum == '0' else "s" + currentSeasonNum + "e" + currentEpNum in place of "if defaulttvdbseason=="a": numbering = currentAbsNum" and the next line... and: ep, episode_count = media_episode if defaulttvdbseason=="a" or metadata.id.startswith("tvdb3-") and not media_season == "0" else "s%se%s" % (media_season, media_episode), 0

by removing the season part in tvdb3 mode (apart for specials) then all is more simple cannot test the code above as plex stopped working in my synology NAS

Posted my code reduction and code here untested: https://github.com/ZeroQI/Hama.bundle/blob/revert-50-EndOfLine369-patch-1/Contents/Code/__init__.py

@EndOfLine369: Oh my most trustworthy sidekick (and possibly better coder) would you be able to have a look and test? i believe the two lines changed should do the trick unless i meesed up to variable scope. plex down on my NAS

EndOfLine369 commented 8 years ago

I don't think we should be changing tvdb3's behavior at this point as it has been out there for a while now and would cause anyone using it, not reading this thread, to start having unexpected behavior. This should probably be put as tvdb4 as orig mentioned by sven7 to make it clear on what behavior will occur when used. This will also allow us to more easily define behavior in the code with a clear metadata id.

EndOfLine369 commented 8 years ago

Looking at your edit above, seems you only meant to commit your reduction to non-master but the master got the untested commit. image

ZeroQI commented 8 years ago

after checking yeah i did that by mistake... the behaviour change will encompass all absolute numbering in any seasons. should change nothing once coded properly...it will change from tvdb season with abs numbering to absolute numbering tvdb seasons unless specified

EndOfLine369 commented 8 years ago

I believe all we would need to do for a tvdb4 is...

ASS:

FROM:
  if not re.search(".*? ?\[(anidb|tvdb|tvdb2|tvdb3|tmdb|imdb)-(tt)?[0-9]{1,7}\]", folder_show, re.IGNORECASE):
    for file in ("anidb.id", "Extras/anidb.id", "tvdb.id", "Extras/tvdb.id", "tvdb2.id", "Extras/tvdb2.id", "tvdb3.id", "Extras/tvdb3.id", "tmdb.id", "Extras/tmdb.id", "tsdb.id", "Extras/tsdb.id", "imdb.id", "Extras/imdb.id"):
TO:
  if not re.search(".*? ?\[(anidb|tvdb|tvdb2|tvdb3|tvdb4|tmdb|imdb)-(tt)?[0-9]{1,7}\]", folder_show, re.IGNORECASE):
    for file in ("anidb.id", "Extras/anidb.id", "tvdb.id", "Extras/tvdb.id", "tvdb2.id", "Extras/tvdb2.id", "tvdb3.id", "Extras/tvdb3.id", "tvdb4.id", "Extras/tvdb4.id", "tmdb.id", "Extras/tmdb.id", "tsdb.id", "Extras/tsdb.id", "imdb.id", "Extras/imdb.id"):

HAMA:

##################################################
FROM:
    global SERIE_LANGUAGE_PRIORITY
    match = re.search("(?P<show>.*?) ?\[(?P<source>(anidb|tvdb|tvdb2|tvdb3|tmdb|imdb))-(tt)?(?P<guid>[0-9]{1,7})\]", orig_title, re.IGNORECASE)
TO:
    global SERIE_LANGUAGE_PRIORITY
    match = re.search("(?P<show>.*?) ?\[(?P<source>(anidb|tvdb|tvdb2|tvdb3|tvdb4|tmdb|imdb))-(tt)?(?P<guid>[0-9]{1,7})\]", orig_title, re.IGNORECASE)
##################################################
FROM:
    if   metadata.id.startswith("tvdb-"):  tvdbid = metadata.id [len("tvdb-"):]
    elif   metadata.id.startswith("tvdb2-"):  tvdbid = metadata.id [len("tvdb2-"):]
    elif   metadata.id.startswith("tvdb3-"):  tvdbid = metadata.id [len("tvdb3-"):]
    elif metadata.id.startswith("anidb-"):
TO:
    if metadata.id.startswith("tvdb"): tvdbid = metadata.id[metadata.id.find("-")+1:]
    elif metadata.id.startswith("anidb-"):
##################################################
FROM:
        abs_manual_placement_worked = True
        if defaulttvdbseason != "0" and max(map(int, media.seasons.keys()))==1 or metadata.id.startswith("tvdb3-"):
TO:
        abs_manual_placement_worked = True
        if defaulttvdbseason != "0" and max(map(int, media.seasons.keys()))==1 or metadata.id.startswith("tvdb3-") or metadata.id.startswith("tvdb4-"):
##################################################
FROM:
            if defaulttvdbseason=="a": numbering = currentAbsNum
TO:
            if defaulttvdbseason=="a" or (metadata.id.startswith("tvdb4-") and currentSeasonNum != "0"): numbering = currentAbsNum
##################################################
FROM:
        for media_episode in media.seasons[media_season].episodes:
          ep, episode_count = "s%se%s" % (media_season, media_episode), 0
          if ep in tvdb_table:
TO:
        for media_episode in media.seasons[media_season].episodes:
          ep, episode_count = media_episode if metadata.id.startswith("tvdb4-") and media_season != "0" else "s%se%s" % (media_season, media_episode), 0
          if ep in tvdb_table:
##################################################

Not hard coded/tested yet. Just spit-balling code out for thought/comments.

ZeroQI commented 8 years ago

i believe we are mostly there apart from season 0 management this works for all for code reduction if metadata.id.startswith("tvdb"): tvdbid = metadata.id[metadata.id.find("-")+1:]

then season 0. when using absolute numbering regarless of seasons, we can put abs number in tvdb_table without seasons apart for season 0 ep, episode_count = media_episode if metadata.id.startswith("tvdb4-") and not media_season == "0" else "s%se%s" % (media_season, media_episode), 0

edit, latest synology Plex package fail to start. Trying my code as we speak but need to create dummy data first

EndOfLine369 commented 8 years ago

Good points. Updated above comment. I'l try to test today and post back.

ZeroQI commented 8 years ago

https://github.com/ZeroQI/Hama.bundle/blob/master/Contents/Code/__init__.py apparently works for tvdb4. reduced code so might have broken something. If works will try to merge tvdb3 and 4 to reduce code and complexity

sven-7 commented 8 years ago

Is there a new scanner to go with this as well? Did not see any pull requests or commits.

EndOfLine369 commented 8 years ago

Here is what you can use to test. "Absolute Series Scanner.py" -> https://gist.github.com/EndOfLine369/20159a2480502f0839fc "init.py" -> https://gist.github.com/EndOfLine369/8ee08c812a5f3943e6cc

Using file setup:

Dragon Ball Super [tvdb4-295068]
|--> Season 4 (ep 1-19)
`--> Season 5 (ep 20-46)

image image image

EndOfLine369 commented 8 years ago

Looks like ZeroQI has accidentally broken the master in Hama again. I have reverted the master to the last stable & tested version. Once tvdb4 is tested and his reduction branch is tested we can then put into the stable master.

ZeroQI commented 8 years ago

sorry was dead tired. This worked for tvdb4 for me yesterday, to be checked if i broke something with code reduction: https://gist.github.com/ZeroQI/b57228f6fe5a62026bfff0015af50199

also Corrected if tvdbposternumber * tvdbposternumber == 0: with if tvdbposternumber * tvdbseasonposter == 0:

EndOfLine369 commented 8 years ago

No worries. I've taken an initial glance, it looks good. By putting both tvdb3 & tvdb4 to use abs numbers for numbering I believe it does make some of the if cases simpler. I see some possible issues in the log section being too simplified but will def get back to you. It's ~4am here so will test later as I need sleep :sleepy::zzz:.

sven-7 commented 8 years ago

Ran a test using the code @EndOfLine369 posted. Did a successful split with Seraph of the End.

screen shot 2016-06-13 at 9 39 56 am

screen shot 2016-06-13 at 9 40 14 am

screen shot 2016-06-13 at 9 40 21 am

EndOfLine369 commented 8 years ago

@ZeroQI, Pulled in the rest of your tvdb3/4 updates minus log section reduction. Also made some minor changes when checking for either tvdb3/4. https://gist.github.com/EndOfLine369/8ee08c812a5f3943e6cc In testing, it looks like it pulls in metadata ok. But found an issue where it is not listing the missing episodes correctly when under tvdb4 so that section still needs to be updated for tvdb4. Probably add where if tvdb4 is the abs number in any season. Drawing a blank on how to update that section at the moment without making it a mess.

sven-7 commented 8 years ago

So far, so good for me. I've run tests on a few different series. I know @ZeroQI mentioned we could have this still be a tvdb3 function, but I would absolutely vote to keep it labeled as tvdb4 as it's intended to do something different. I think that will be easier to explain in the readme and for other users. It also helps library organization, as you only have to see which tvdb version you are running by the different .id files.

I'm experiencing the episodes in the missing episode log as @EndOfLine369 has suggested.

screen shot 2016-06-13 at 11 09 58 pm

Durarara!!: Formerly 2 seasons, now I have season 1 and I've split season 2 into it's 3 cours (x2 shou, x2 ten, and x2 ketsu)

screen shot 2016-06-13 at 11 07 35m

Dragon Ball Z Kai: Split it up into the various arcs.

screen shot 2016-06-13 at 11 05 58 pm

Hunter X Hunter: Split up as described in the example.

screen shot 2016-06-13 at 11 06 14 pm
EndOfLine369 commented 8 years ago

That looks really nice. I still think that it would be nice to store this somewhere. Or at least share them for others, as I would not have thought about most of the above separations but would love to mirror them. The problem with storing this type of data is people will eventually disagree as these are not absolutes (and mirror tvdb disagreement). So maybe somewhere we can post/store this info as at least recommendations. We could probably put in an error log that creates an xml format of the setup info and then add a link to where they can post the info.

EndOfLine369 commented 8 years ago

Reviewed/tested the error log reorg. It works fine but as I suspected, the sorting was made too simplistic so kept the current line sorting setup. https://gist.github.com/EndOfLine369/8ee08c812a5f3943e6cc

So the only issue outstanding I can see from this is that with tvdb4 the missing episode listings are broken.

ZeroQI commented 8 years ago

@EndOfLine369: Thanks a lot for the new version.

Line 323 from: if currentSeasonNum and not (currentSeasonNum in media.seasons and ( currentEpNum in media.seasons[currentSeasonNum].episodes or currentAbsNum in media.seasons[currentSeasonNum].episodes )):

To: if currentSeasonNum and not (currentSeasonNum in media.seasons and ( currentEpNum in media.seasons[currentSeasonNum].episodes or not metadata.id.startswith("tvdb4") and currentAbsNum in media.seasons[currentSeasonNum].episodes or metadata.id.startswith("tvdb4") and any(currentAbsNum in media.seasons[season].episodes for season in media.seasons) )):

https://gist.github.com/ZeroQI/b57228f6fe5a62026bfff0015af50199 This should solve the wrongly reposted missing episodes while using tvdb4 issue... Please test sven-7

Line 324 if currentSeasonNum == '0': tvdb_special_missing.append(numbering) else: tvdb_episode_missing.append("s" + currentSeasonNum + "e" + numbering if metadata.id.startswith("tvdb4") else numbering)

Should numbering be: . absolute numbering like it is now since season based on archs so arbitrary . put season 1: "s1e" + numbering if metadata.id.startswith("tvdb4") else numbering . put tvdb real season: "s" + currentSeasonNum + "e" + numbering if metadata.id.startswith("tvdb4") else numbering . put actual season used custom by the user ? Make things complicated here: "s" + max(season for season in media.seasons if currentAbsNum in media.seasons[season].episodes)+ "e" + currentAbsNum

sven-7 commented 8 years ago

@EndOfLine369 any suggestions on how/where we could list the TVDB4 suggestions? I'd be more than happy to help work that list up, at least from some of my own collection. I used to store a lot of my anime this way, so I have a good starting point to jump off from.

I had to find the posters on my own, but that's one of the acceptable things you'd have to accept when choosing to go with the tvdb4 route. I suppose we could house them somewhere, but that's probably a slippery slope we don't want to get into.

Also, great work @ZeroQI and @EndOfLine369! Both ASS and HAMA are pretty damn awesome.

EndOfLine369 commented 8 years ago

@ZeroQI "absolute numbering like it is now since season based on archs so arbitrary" Best to keep it simple and just use the abs num for tvdb3/4 missing ep as the user would already have the files in this numbering also.

@sven-7 still trying to think on that. Maybe a Plex forum thread? A permanent ASS/Hama issue ticket? ...? Glad you like the idea about sharing your setup genius :smile:. Any thoughts @ZeroQI?

MagellanSails commented 8 years ago

@EndOfLine369 Storing the reccommended season/arc lists in an issue or forum thread may get messy and hard to find things as time goes on.

My next thought was to add it to the bottom of the readme on ASS or HAMA's main github page, but then that could become a lot of work for @ZeroQI to maintain.

Adding another readme type file into one of the projects solely for the season/arc mappings might make the most sense. Putting it in the repo would make it easy for anyone to suggest improvements (pull request) and would make it easy to see when/what was updated. It also wouldn't clutter the normal readme for people who are just trying to figure out how to get started with the scanner/agent.

The file wouldn't have to be anything fancy, could be as simple as:

Hunter X Hunter (2011) -Season 01: 001-031: Hunter Exam Arc -Season 02: 032-036: Zoldyck Family Arc -Season 03: 037-044: Heavens Arena Arc -Season 04: 045-070: Yorknew City Arc -Season 05: 071-092: Greed Island Arc -Season 06: 093-136: Chimera Ant Arc -Season 07: 137-148: 13th Hunter Chairman Arc

Seraph of the End -Season 01: 001-012: Vampire Reign -Season 02: 013-024: Battle in Nagoya

Could obviously add more info, but I think that would be a sufficient start. Thoughts?

sven-7 commented 8 years ago

@MagellanSails I like the third idea. That way any of us could improve it and it wouldn't put all the pressure on @ZeroQI to maintain. The forum/issue would definitely get messy.

We could also look into doing some kind of image repository that HAMA could pull from when tvdb4 is activated. That way we could submit season posters that won't get pulled otherwise. Thoughts?

@EndOfLine369 haha, happy to help! Looking forward to this project, actually!

ZeroQI commented 8 years ago

Right now with tvdb4 mode, you create your own Season-Arcs folders and drops the absolute numbering files in any season folder and it just works...

@MagellanSails We could use a mapping file BUT the scanner would be the one assigning eps to specified seasons, so we would need a location it can access without issues (logs folder seem un-elegant) so all is left is the tvdb4.id file or a neighboring file (Arc-Season_mapping) so re-use the tvdb4.id file....

"tvdb4.id" file content: 289906|Seraph of the End Season 01|001|012|Vampire Reign Season 02|013|024|Battle in Nagoya

@EndOfLine369 With the following we can make a list of lines splitted by fields using a separator string not present in possible titles: (or use comma but escape commas in title, no need to de-escape since only tvdbid season and ep range used) file_array=[]; with open("tvdb4.id") as file: file_array [] = file.readline().split("|") #file.readlines()

This give a file_array [0 -> ["289906", "Seraph of the End"], 1->["Season 01", "001", "012", "Vampire Reign"], 2->["Season 02", "013", "024", "Battle in Nagoya"] ] which should allow one or two line loops to test if ep in rage indicated to keep code super short

MagellanSails commented 8 years ago

@ZeroQI oh, I wasn't suggesting we change how tvdb4 is working currently. I actally haven't tried it yet, but it sounds like it working really well. I think we were just talking about compiling a list of episode-to-arc mappings for series so that if someone wanted to use tvdb4 they would know what folders to create

ZeroQI commented 8 years ago

@MagellanSails I believe you misunderstood me. Currently it work regardless which season you put the absolute numbered episode into, but the season folders are created by the user yet the metadata for eps get filled regardless of the season folder they are put into. If we do a list of episode to (arc) season mappings using hte exact same tvdb4.id file, we can prevent the user to create season folders the same way we can prevent it for tvdb2 and tvdb3 mode. We do not change the way tvdb4 work, we add the possibility to have a mapping sepisodes to seasons inside the tvdb4.id file to not require to actually move the files in arbitrary folders.

sven-7 commented 8 years ago

@ZeroQI - would we need to create one tvdb4.id file per show or would we create one master tvdb4.id file?

ZeroQI commented 8 years ago

@sven-7 logically reusing the id is the most logical, but doesn't exclude a centralosed database, but on the scanner it's tricky. Could put it in root folder though and call it tvdb4.id dor example. Ino files type of logs woild do the trick

sven-7 commented 8 years ago

The weakness I see with the .id file is that we'd have to download it every time there are updates.

Could we have a a repository on Git that the scanner and HAMA could call to if the show has a tvdb4.id file?

Or we could have a file on git, that people can go look at and copy the suggestions directly into their tvdb4.id file:

ie...

289906|Seraph of the End
Season 01|001|012|Vampire Reign
Season 02|013|024|Battle in Nagoya
ZeroQI commented 8 years ago

@sven-7: file on git scanner repository doable. Already doing that in the agent with scudlee's xml mapping files... I need to think of a format short to code than people can copy paste to tvdb4.id or use the online mapping

EndOfLine369 commented 8 years ago

@ZeroQI The file we store in ASS git should not be referenced by the scanner at all in my opinion. The point of storing anything in git would be for users to have an available reference list of what others have done. For them to have the option of using the same setup as tvdb4 is to allow people to choose their own season setup. We should not be again forcing a predefined season setup that would make people use our definitions and thus cause us to start regulating the definitions as there can only be one and turn into the current issue we have with thetvdb.

I also don't think we should use the tvdb4.id file to contain the mapping as it is ignored as other id files if the id is already defined in the folder name (I always do). Probably a "tvdb4.mapping" file to make it clear on the content format? I also don't recommend requiring the string 'Season' as there are other allowed season folder names.

To recap what I think has been said/setup so far...

##################################################
Scanner mode "tvdb4" (Custom Seasons):
##################################################
Option 1
Define season folders and place episode files in the season folder they want.

Requirement(s): Episode numbers must be numbered as their absolute numbering

##################################################
Option 2
Define season folders in a mapping file and place episode files in the main series folder.

Requirement(s):
  (1) Episode numbers must be numbered as their absolute numbering
  (2) Mapping file must be defined locally in the series folder
        FORMAT:
        <season_num>|<starting_ep_num>|<ending_ep_num>|<freeform_text_naming_the_season>(optional)
        EX:
        01|001|012|Vampire Reign 
        02|013|024|Battle in Nagoya

With option 1 already being coded and outstanding missing episode listings issue when using tvdb4 mode.

ZeroQI commented 8 years ago

@EndOfLine369 You are good :D

I believe i solved the episodes showing in the missing episode listings in this version: https://gist.github.com/ZeroQI/b57228f6fe5a62026bfff0015af50199

Line 323 changed from: if currentSeasonNum and not (currentSeasonNum in media.seasons and (currentEpNum in media.seasons[currentSeasonNum].episodes or currentAbsNum in media.seasons[currentSeasonNum].episodes )): To: if currentSeasonNum and not (currentSeasonNum in media.seasons and (currentEpNum in media.seasons[currentSeasonNum].episodes or not metadata.id.startswith("tvdb4") and currentAbsNum in media.seasons[currentSeasonNum].episodes or metadata.id.startswith("tvdb4") and any(currentAbsNum in media.seasons[season].episodes for season in media.seasons) )):

Very good in depth analysis and very good naming idea for the file. I do believe we can offer an online list as last resort if we allow custom folders first, then a local list option (a bit like the custom mapping file in hama agent data folder to override scudlee's one), then the online list (if people choose not to put a mapping file or seasons), that way we are not forcing it...

Technical recap again (really like what you did above)

Selection Order: (take the first available or skip to the next) . ID: id in folder name > id in file (already implemented) . tvdb4 mapping: season folders > tvdb4.mapping file > git online file

tvdb4.mapping: FORMAT:

[season_num] | [starting_ep_num] | [ending_ep_num]  | [freeform_text_naming_the_season](optional)

Git tvdb4.mapping online format:

[tvdb_id] | [number_of_seasons_mapped] | [freeform_text_naming_the_serie] (optional)
[season_num] | [starting_ep_num] | [ending_ep_num] | [freeform_text_naming_the_season](optional)

289906|2|Seraph of the End 01|001|012|Vampire Reign 02|013|024|Battle in Nagoya

This give in both instances this structure file_array [ 0->["01", "001", "012", "Vampire Reign"], 1->["02", "013", "024", "Battle in Nagoya"] ]

Code added line 320:
  elif tvdb_mode=="4" and (not folder_season or folder_season ==1):  #1-folders nothing to do, 2-local, 3-online
    file_array=[]
    for files in ("tvdb4.mapping", "Extras/tvdb4.mapping"):
      if os.path.isfile(os.path.join(root, "/".join(reversed(reverse_path)), files)):
        with open(os.path.join(root, "/".join(reversed(reverse_path)), files)) as file: file_array [] = file.readline().split("|")
    if not file_array: #no season folders, no local files
    try:
          with open("https://raw.githubusercontent.com/ZeroQI/Absolute-Series-Scanner/master/tvdb4.mapping") as file:
          file_array, line_array = [], file.readline().split("|")
          for line in range(int(line_array[1])):  file_array[] = file.readline() #read seasons #, then # lines
          if line_array[0]==tvdbid: break
        else: file_array = []; Log("tvdbid: '%s' not found in season mapping file" % line_array[0])
      except    
    if file_array:  tvdb_mapping[absolute_episode] = (int(file_array[season][0]), int(absolute_number)) for absolute_episode in range( int(file_array[season][1]), int(file_array[season][2])) for season in file_array

uploaded the code here: https://gist.github.com/ZeroQI/974f6335ad4f31ecdfe1e4af0404098d Please test if works with local file. it generates the same array format as for tvdb2 and 3 mapping to change hardly any code

EndOfLine369 commented 8 years ago

@ZeroQI Agreed on the priority order. This will allow people to ignore the git file and still do their own while still letting people to lean on our git stored file. tvdb4 mapping: season folders > tvdb4.mapping file > git online file

I would recommend a slight change in the online file format

FROM:
289906|2|Seraph of the End
01|001|012|Vampire Reign
02|013|024|Battle in Nagoya

TO:
<tvdb4entries>
<anime tvdbid="289906" name="Seraph of the End">
01|001|012|Vampire Reign
02|013|024|Battle in Nagoya
</anime>
<anime tvdbid="252322" name="Hunter x Hunter (2011)">
1|001|031|Hunter Exam Arc
2|032|036|Zoldyck Family Arc
3|037|044|Heavens Arena Arc
4|045|070|Yorknew City Arc
5|071|092|Greed Island Arc
6|093|136|Chimera Ant Arc
7|137|148|13th Hunter Chairman Arc
</anime>
...
</tvdb4entries>

This would allow us to better segregate/define the entries in the file as well as allow us to simply use xpath to get to the direct entry without having to scan ourselves through the whole file.

tvdb4anime =  etree.fromstring( urllib2.urlopen('https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/tvdb4.mapping').read() )
somevariable = tvdb4anime.xpath("/tvdb4entries/anime[@tvdbid='%s']" % guid).text

This would then also allow us to use the same piece of code to either parse the contents of the local file or the contents of the anime xml tag.

EndOfLine369 commented 8 years ago

Found some issues in your gist. Will get back to you on that as well as showing the above change in the code.

EndOfLine369 commented 8 years ago

There were a few issues but I have corrected and updated the code with the above xml changes as well.

"Absolute Series Scanner.py" -> https://gist.github.com/EndOfLine369/20159a2480502f0839fc

Git file updated: https://raw.githubusercontent.com/ZeroQI/Absolute-Series-Scanner/master/tvdb4.mapping

##################################################
Scanner mode "tvdb4" (Custom Seasons):
##################################################
Option 1
Define season folders and place episode files in the season folder wanted.

Requirement(s): Episode numbers must be numbered as their absolute numbering

##################################################
Option 2
Define season folders in a mapping file and place episode files in the main series folder.

Requirement(s):
  (1) Episode numbers must be numbered as their absolute numbering
  (2) Mapping file must be defined locally in the series folder
        FORMAT:
        [season_num]|[starting_ep_num]|[ending_ep_num]|[freeform_text_naming_the_season](optional)
        EX:
        01|001|012|Vampire Reign 
        02|013|024|Battle in Nagoya

##################################################
Option 3
Place episode files in the main series folder. 
Mapping info will be pulled down from github
https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/tvdb4.mapping

Requirement(s):
  (1) Episode numbers must be numbered as their absolute numbering
  (2) Online XML entry format
        FORMAT:
        <anime tvdbid="[tvdbid_num]" name="[series_name]">
        [season_num]|[starting_ep_num]|[ending_ep_num]|[freeform_text_naming_the_season](optional)
        </anime>
        EX:
        <anime tvdbid="289906" name="Seraph of the End">
        01|001|012|Vampire Reign
        02|013|024|Battle in Nagoya
        </anime>
sven-7 commented 8 years ago

Added Dragon Ball Kai to the mapping #36 . Testing this out, not familiar with how I should do this with Git, so guidance is welcome. I'm sure I'll be doing this a handful of times for that list.

EndOfLine369 commented 8 years ago

Merged

sven-7 commented 8 years ago

Nice. Will start a side project working on this mapping list.

In the meantime, I'll grab your latest ASS. What is the latest HAMA?

Also, added #37 to track the readme updates we'll need to do.

EndOfLine369 commented 8 years ago

Taking that as it worked as expected. I just used your Dragon Ball Kai entry and it separated out mine into 5 seasons as expected. :smile:

EndOfLine369 commented 8 years ago

I renamed the git file to 'tvdb4.mapping.xml' to get git formatting and there is no need to make it match the local file name. Gist updated https://gist.github.com/EndOfLine369/20159a2480502f0839fc

sven-7 commented 8 years ago

Nice! Really happy with how this is working so far.

Will work on this mapping soon.

This is probably too detailed/a pain in the ASS (pun?), but should we alphabetize tvdb4.mapping.xml?

EndOfLine369 commented 8 years ago

Latest ASS "Absolute Series Scanner.py" -> https://gist.github.com/EndOfLine369/20159a2480502f0839fc Latest HAMA "init.py" -> https://gist.github.com/EndOfLine369/8ee08c812a5f3943e6cc

I forgot to check the above mentioned fix of missing ep listings by ZeroQI. Will do that now.

EndOfLine369 commented 8 years ago

@ZeroQI, got an error on your Hama update. NameError: global name 'any' is not defined from the any(currentAbsNum in media.seasons[season].episodes for season in media.seasons) Issue is the python version not having the 'any' built in function. Changed it to this and it works ok [currentAbsNum in media.seasons[season].episodes for season in media.seasons].count(True) > 0

Updated HAMA Gist: https://gist.github.com/EndOfLine369/8ee08c812a5f3943e6cc

EndOfLine369 commented 8 years ago

Created ASS Pull Request https://github.com/ZeroQI/Absolute-Series-Scanner/pull/38 & HAMA Pull Request https://github.com/ZeroQI/Hama.bundle/pull/54