[Rel] HTTP Anidb Metadata Agent (HAMA)

For some reason I’m not getting the titles of the episodes to download anymore. Let me give you an example with Naruto, I’ve tried removing the folder from my directory and emptying the trash and putting it back in and it doesn’t grab the title. I have also tried refreshing the show. The logs are right after a refresh of the show.

There’s 3 lines in Plex Media Scanner.log and it only serve to prove if the scanner crash
Plex Media Scanner (custom ASS).log has 5 lines “2016-09-14 20:57:24,657 - ASS : INFO - ‘X-Plex-Token.id’ file present”
The Agent logs is right so you use tvdb3 mode so tvdb seasons with absolute numbering for eps:

  • D:\Anime TV Shows\Naruto Shippuden [tvdb3-79824][HorribleSubs] Naruto Shippuuden - 457 [1080p].mkv’

Created pull request: https://github.com/ZeroQI/Hama.bundle/pull/81
Once confirmed all works will push to the master branch

Using your newest version gives the following error when hitting Refresh on Naruto:

2016-09-15 17:27:56,956 - com.plexapp.agents.hama (1a64) : INFO (logkit/Info:16) - — Update Begin -------------------------------------------------------------------------------------------
2016-09-15 17:27:56,956 - com.plexapp.agents.hama (1a64) : INFO (logkit/Info:16) - metadata source: ‘tvdb3’, id: ‘79824’, Title: ‘Naruto Shippuden’, lang: ‘en’, (True)
2016-09-15 17:27:56,956 - com.plexapp.agents.hama (1a64) : INFO (logkit/Info:16) - Theme song - already added
2016-09-15 17:27:56,956 - com.plexapp.agents.hama (1a64) : INFO (logkit/Info:16) - TVDB - tvdbid: ‘79824’, url: ‘http://thetvdb.com/api/A27AD9BE0DA63333/series/79824/all/en.xml
2016-09-15 17:27:56,956 - com.plexapp.agents.hama (1a64) : INFO (logkit/Info:16) - url: ‘http://thetvdb.com/api/A27AD9BE0DA63333/series/79824/all/en.xml’, filename: ‘TVDB/79824.xml’
2016-09-15 17:27:57,073 - com.plexapp.agents.hama (1a64) : DEBUG (networking/load:161) - Fetching ‘http://thetvdb.com/api/A27AD9BE0DA63333/series/79824/all/en.xml’ from the HTTP cache
2016-09-15 17:27:57,220 - com.plexapp.agents.hama (1a64) : WARNING (logkit/Warn:19) - IMDB ID was empty, loaded through tvdb serie xml, IMDBID: ‘tt0988824’
2016-09-15 17:27:57,267 - com.plexapp.agents.hama (1a64) : INFO (logkit/Info:16) - abs_manual_placement_worked: ‘True’, abs_manual_placement_info: ‘[]’
2016-09-15 17:27:57,269 - com.plexapp.agents.hama (1a64) : CRITICAL (core/log_exception:574) - Exception in the update function of agent named ‘HamaTV’, called with guid ‘com.plexapp.agents.hama://tvdb3-79824?lang=en’ (most recent call last):
File “C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-24ffd60\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\agentkit.py”, line 1065, in update
agent.update(obj, media, lang, **kwargs)
File "C:\Users\Daniel\AppData\Local\Plex Media Server\Plug-ins\Hama.bundle\Contents\Code_init
.py", line 926, in update
def update(self, metadata, media, lang, force ): self.Update(metadata, media, lang, force, False )
File “C:\Users\Daniel\AppData\Local\Plex Media Server\Plug-ins\Hama.bundle\Contents\Code_init_.py”, line 492, in Update
elif roles[ role ][1]==‘writers’: metadata.writers.add(creator.text)
NameError: global name ‘tvdb3’ is not defined

Corrected error, please try again

Here are the new errors with the updated version. I’m also trying to grab metadata for a couple new shows I added at this point.

My apologies, i found the error edited quickly on my phone this morning, forgot quotes around the error and it basically gave the exact same message… Here is the correction.
https://github.com/ZeroQI/Hama.bundle/blob/1c440250133a613e6a3cfc7a9238efa7d4784786/Contents/Code/init.py

Thanks for your work on this! I updated to the newest version. I refreshed Naruto Shippuden and it downloaded the titles for the episodes. I did notice though that this is what it retrieved for the titles of Blood Lad:

An example of the naming is: (Hi10)Blood_Lad-01(BD_1080p)(OWA-Kaitou)(4CB90ED2).mkv

If I force it to [tvdb-269875] instead of the default (which I believe is anidb?) it works. Not sure if that’s an issue or not but thought I would let you know. I’ll just keep grabbing tvdb anyways. At this point everything basically works so thanks again for looking at the previous issues.

So ASS scanner job is to try to get the title from the file while it waits for the agent to refresh it…
Since it never refreshes, it is never updated. Looks like the agent code is not perfect and doesn’t work for Anidb ids even though the mapping is in the mapping file…

Well i moved code the wrong way and that explains it as a test basically shunt anidb single season series, that should fix it, please try again: https://github.com/ZeroQI/Hama.bundle/blob/ZeroQI-patch-2/Contents/Code/init.py

It works again with the default anidb! Quick question regarding one more file. Dragon ball kai absolute episode 98 is also a special but it belongs at the end of the first season and should be watched before season 2. Hama doesn’t grab the metadata and it stays episode 98 in Plex. This is the tvdb page for it: http://thetvdb.com/index.php?tab=episode&seriesid=88031&seasonid=48651&id=4169644

I would think it should grab it correctly because of the absolute numbering used?

Also, when I have my folders setup like the following image:

It creates two entries in plex:

Is that as intended in plex due to having one source be anidb and the other source be tvdb?

According to tvdb and the very link you pasted this ep is s00e01. There is no ep 98 so no metadata updated so working as designed.
It’s nice to see thetvdb supported specials insertion at the right place but unuseable for plex as we cannot have ep 14.5 for example…

One serie folder should not be in the other one folder and be detected as different serie… But it seems it works, so would love to see the agent logs…

Why nos label the file Specials/xxx s01e01 I am not a cat (OVA).ext?
Also [anidb-xxx-s00e01] would map it to the same serie.
Yes two separate metadata id means two series

Here is the Hama log for blood lad with the OVA inside of the Blood Lad series folder and the OVA folder name with [tvdb-269875-s0e1] appended to it :

If I append [anidb-9803] to the end instead it still thinks it is a separate series even if I put it within the Blood Lad series folder. See:

Each serie/folder is associated a metadata id during search and we can force it

Since the id is different (anidb for blood lad and tvdb for the movie) it is showing as two separate series.

Weird thing is subfolders used to merge with the parent folders with same id in a bad way, which is why i disabled subfolders yet it work for you…

Did you add as root folder blood lad?

  • If so all is good.
  • If not please attach the custom scanner log as i will need to remove useless code and edit the readme for the scanner.

From anidb side it is another serie not a special otherwise we would have called it s01 and that would have been it. Let's use tvdb since otherwise no metadata on the movie

Force tvdbid and special episode mapping

  • Blood Lad [tvdb-269875]
  • Blood Lad Ex - I am not a cat [tvdb-269875-s00e01]

Or let scanner find by magic with anidb2 mode the tvdb id and mapping IF ScudLee's mapping file is up to date but i don't like that too much as it load files in scanner and relies on one mapping file so less control - Blood Lad [anidb2-8929] - Blood Lad Ex - I am not a cat [anidb2-9803-s00e01]

It seems to have worked when I used tvdb as the main folder and also for the special episode within it. Here are the logs with forced tvdbid and special episode mapping of tvdb. I just tried it again with tokyo ghoul and the same thing happens. If the root series folder is left with no specific mapping, it defaults to anidb. If within the root series folder there are specials that are forced to special mapping to tvdb, it will create new series for those items. It isn’t merging an anidb root series with tvdb special mapped series.

Working exactly as designed.
Plex will group eps from the series with the same metadata id under one serie entry…

AniDB is the default so it will support anidb specials for the metadata unless you have multiple seasons in which case it will use tvdb specials metadata (Agent is called Http AniDB Metadata Agent or HAMA so AniDB being the default is expected)

It really comes down to choose anidb or tvdb naming convention and stick to it but single season series need to be told the specials follow tvdb numbering

You can however display an absolutely numbered anidb series as tvdb season numbering using tvdb2 or tvdb3. You could use tvdb4 to use arks as seasons for long tunning series…

If you put the movie folder in the serie folder why not create a specials folder (or not, with s00e01 will still work) and name the file Blood Lad [tvdb-269675]/Specials/Blood lad s00e01movie.ext…
If both movie and serie folders are at root level then anidb2 or tvdb for both id forcing is the only way to have metadata for the movie.

That’s fine, I’ll just make sure to use both anidb or use both tvdb for series and specials.

On another note, and this seems to be a bug, I’m having problems with Dragon Ball Z specials. I’ve tried both with all the specials in the root series folder and all of the specials in a folder called specials and both ways gives the same results. Each of the specials are within their own folder with forced TVDB mapping for the folder name. Some are being incorrectly placed as copies of other specials, some do not have the metadata grabbed and remain episode 23 or episode 24, and some are not being detected at all.

I have included 1 screenshot to show you what each of the folders are called. A couple are cut off but they all have the same naming as show in the Folder Naming screenshot. Ignore the Extras folder, that was deleted.

I have two screenshots called Plex Library that show you which episodes are duplicated under episode 1, 2, and 19. It also shows you that there are missing episodes (like 14 & 15) which are under other episodes like 1 and 2. It also shows you that the final couple of episodes have no meta data scrapped from tvdb.


The three screenshots labelled screenshots show you which episodes are being lumped together incorrectly.

Logs also uploaded as a rar file.

I did a powershell script on windows for scanner and agent to update with a right click > execute PowerShell even if the plex server itself is running on a NAS. Please let me know any remaining bug for scanner or agent remaining.

@Brenex

Scanner call - root: 'D:\Anime TV Shows', path: 'Dragon Ball Z [tvdb3-81472]\Specials\Plan to Destroy the Saiyajins Space Story (2) [tvdb3-81472-s0e18]', dirs: '0', files: '1'
folder_show: 'Plan to Destroy the Saiyajins Space Story (2) [tvdb3-81472-s0e18]', folder_season: '0', tvdb mode: '3', tvdb id: '81472'
offset_season = -1, offset_episode = 17
"Plan to Destroy the Saiyajins Space Story (2) [tvdb3-81472]" s0000e019 (Orig: s1e2) "[DBNL]Dragon.Ball.Z.The.Plan.to.Eradicate.the.Saiyans.Part.2.[sub][x264][768CF4E1].mkv"

=> I am sorry but it is working as designed. if you leave the file in the folder as movie 2, it will be one ep further than movie one then end up in duplicates, name them DBZ s00e01 OR put it in part 1 folder and they will be in sequence

Scanner call - root: 'D:\Anime TV Shows', path: 'Dragon Ball Z [tvdb3-81472]\Specials\The History of Trunks [tvdb3-81472-s0e15]', dirs: '0', files: '1'
folder_show: 'The History of Trunks [tvdb3-81472-s0e15]', folder_s`ason: '0', tvdb mode: '3', tvdb id: '81472'
offset_season = -1, offset_episode = 14
"The History of Trunks [tvdb3-81472]" s0000e002 "[DBNL]Dragon.Ball.Z.Special.02.The.History.of.Trunks.[DR][x264][FE8D5132].mkv" "6" "The History of Trunks" 

Since it got matched using regex it didn’t map

Scanner call - root: 'D:\Anime TV Shows', path: 'Dragon Ball Z [tvdb3-81472]\Specials\Bardock The Father of Goku [tvdb3-81472-s0e14]', dirs: '0', files: '1'
folder_show: 'Bardock The Father of Goku [tvdb3-81472-s0e14]', folder_season: '0', tvdb mode: '3', tvdb id: '81472'
offset_season = -1, offset_episode = 13
"Bardock The Father of Goku [tvdb3-81472]" s0000e001 "[DBNL]Dragon.Ball.Z.Special.01.Bardock.the.Father.of.Goku.[DR][x264][834CAE29].mkv" "6" "Bardock the Father of Goku" 

Since it got matched using regex it didn’t map. Will have to edit code to fix
Apparently ep mapped arrive as season 1, episodes that fail mapping as s0exx
that means s1e1 get passed through mapping unchanged (lucky) and get the offset for season and ep right. regex come as s0exx.

try changing code from (respect space tabultations, very important in python)
elif season > 0: season, ep, ep2 = season+offset_season if offset_season >= 0 else 0, ep+offset_episode, ep2+offset_episode if ep2 else None
to
elif season > 0 or offset_season == -1: season, ep, ep2 = season+offset_season if offset_season >= 0 else 0, ep+offset_episode, ep2+offset_episode if ep2 else None

[DBNL]Dragon.Ball.Z.Special.02.The.History.of.Trunks.[DR][x264][FE8D5132].mkv will be mapped to s0e16 instead of s0e2 like now, should be s0e15 but you named it special 2 so ep 2… put s01e01 before special 2 and should be grand. still don’t know why you don’t just use tvdb naming ie: Dragon Ball Z s00e15 Special 02 The History of Trunks.mkv for example…

[DBNL]Dragon.Ball.Z.Special.01.Bardock.the.Father.of.Goku.[DR][x264][834CAE29].mkv will then be s00e14

Good Evening to everyone!
i m here because, i need help :frowning:
I have big problem with K-ON series. I cant find K- on Movie in Plex library. Same problem is with specails part. Plex make Specials folder but parts are not correct named.
Here is how looks my folder with K-ON anime. I read info in Absolute-Series-Scanner so i used folder name like “Movies name” and “SPECIALS” folder but it does not work correct. Can i ask you what iam dooing wrong? Log is also in attachment.

BTW: How to correct use folder for MOVIE anime like “Kotonoha no Niwa” In my case is movie show like “SEASON 1” Is it right ?

agent crashes… did you create FanartTV folder?
\AppData\Local\Plex Media Server\Plug-in Support\Data\com.plexapp.agents.hama\DataItems\FanartTV

E:\FullHD\Anime\K-On! the Movie\K-On! the Movie - Complete Movie.mkv
E:\FullHD\Anime\K-On! the Movie\Specials\K-On! Special 1 - Planning Discussion!.mkv
E:\FullHD\Anime\K-On! the Movie\Specials\K-On! Special 2 - Visiting!.mkv

delete logs restart plex and try again and attach logs again

Thank you for answer. You have right. I skip folder Fanart TV. It’s little bit better now but Movie file is assigned like episode 1 Season 1 which is bad.

BTW: How works HAMA scanner for Anime Movie? It was my perviouse question on anime “Kotonoha no Niwa” : I have this anime in folder " “Kotonoha no Niwa” but its showed like Season1 whithout information . Is it correct?