ZeroQI / Hama.bundle

Plex HTTP Anidb Metadata Agent (HAMA)
GNU General Public License v3.0
1.21k stars 113 forks source link

Need help setup Traditional Chinese Priority #515

Closed theandychung closed 2 years ago

theandychung commented 2 years ago

Sorry if this question has been asked before, but I have been researching this issue for days and still can't figure out what's wrong. I'm using hama agent in my pi 4 docker plex (plex is in english), and one of the anime I have called BTOOM has some matching issue. My folder is named BTOOOM! 驚爆遊戲, which is in traditional chinese, and the language priority I have is zh-Hant, main, en, ja. I have already put a file named anidb.id inside of this folder, and the only number inside this file is 9249. After refreshing the metadata, I will get the main title, which will be Btoom!. If I try to fix match, I can see the traditional chinese title, but after selecting it, it will still be the main title Btoom!. I checked my anime-titles.xml, and I do see the traditional chinese title. Could you please tell me what I have done wrong? image image image image BTOOOM! 驚爆遊戲.agent-search.log BTOOOM! 驚爆遊戲.agent-update.log

Thanks.

ZeroQI commented 2 years ago

Search log indicate the anidbid your forced used for the match

Update log indicate anidb as series source

[=] title Sources: (AniDB)| AniDB Inside: '['TheTVDB', 'AniDB', 'TheMovieDb']' Value: 'Btooom!'

Anidb xnl used path is given in logs:

http://api.anidb.net:9001/httpapi?request=anime&client=hama&clientver=1&protover=1&aid=9249 is clearly given the anidb part of the logs

<titles>
<title xml:lang="x-jat" type="main">Btooom!</title>
<title xml:lang="bg" type="synonym">Взрив!</title>
<title xml:lang="bg" type="short">БУУУМ!</title>
<title xml:lang="x-jat" type="short">Btoom</title>
<title xml:lang="ja" type="official">BTOOOM!</title>
<title xml:lang="en" type="official">Btooom!</title>
<title xml:lang="de" type="official">Btooom!</title>
<title xml:lang="fr" type="official">Btooom!</title>
<title xml:lang="es" type="official">Btooom!</title>
<title xml:lang="ru" type="official">Взрыв!</title>
<title xml:lang="ar" type="official">بتوم</title>
<title xml:lang="zh-Hant" type="official">BTOOOM! 驚爆遊戲</title>
<title xml:lang="zh-Hans" type="official">BTOOOM! 惊爆游戏</title>
</titles>

Indeed the first language should have the correct title selected... [ ] title: Btooom! [ ] original_title: Btooom! [ ] language_rank: 1

That means the second language got used, should have been 0, however that is in the series XML, whereas titles comes from the anidb XML title file...

I miss some output,apparently Plex logging is not in debug mode so I miss some title debug lines in there...

You need to paste the content of the anidb title XML from the agent data folder/anidb folder/anime titles.xml for this AniDB ID and check the date of the last modification of the file...

https://github.com/Anime-Lists/anime-lists/blob/master/animetitles.xml do show correct entries/ so I believe you title file is outdated and miss "zh-Hant" entry. If not the engine would have an issue but that doesn't seem possible, there is no supported language list, it should just work

theandychung commented 2 years ago

Thanks for helping, and here is the file I am currently using. anime-titles.xml.txt I have deleted and downloaded this file multiple times, and this file I'm using does have traditional chinese in the list. I'm guessing that - in zh-Hant might be an issue, but I'm not sure how to run your code in pycharm with plex api...

Thanks.

theandychung commented 2 years ago

Qualidea Code has the same issue. The same priority but instead of giving me main, it only gives me simplified chinese as its title.

    <anime aid="11846">
        <title xml:lang="x-jat" type="main">Qualidea Code</title>
        <title type="official" xml:lang="en">Qualidea Code</title>
        <title xml:lang="ru" type="syn">Код Квалидеи</title>
        <title type="official" xml:lang="ja">クオリディア・コード</title>
        <title type="official" xml:lang="zh-Hans">代号Qualidea</title>
        <title type="syn" xml:lang="zh-Hant">心靈代碼 Qualidea Code</title>
    </anime>

Qualidea Code 心靈代碼.agent-update.log Qualidea Code 心靈代碼.agent-search.log image

ZeroQI commented 2 years ago

Txt file has the entry, seem like a bug... X-jat has no issue to my knowledge

Need debug mode enabled, metadata updated, then logs attached again please

https://support.plex.tv/articles/200289496-general/

theandychung commented 2 years ago

After refreshing metadata, plex still didn't give me the right title. Here are the logs after I clicked "match":

Qualidea Code 心靈代碼.agent-update.log Qualidea Code 心靈代碼.agent-search.log BTOOOM! 驚爆遊戲.agent-search.log BTOOOM! 驚爆遊戲.agent-update.log

Still have the same result, not getting the traditional chinese title :(

Thanks.

ZeroQI commented 2 years ago

[ ] title: 代号Qualidea [ ] original_title: Qualidea Code [ ] language_rank: 0 Language_rank 0 means the first item in language priority list provided the title http://api.anidb.net:9001/httpapi?request=anime&client=hama&clientver=1&protover=1&aid=11846

<title xml:lang="zh-Hans" type="official">代号Qualidea</title> 
<title xml:lang="zh-Hant" type="synonym">心靈代碼 Qualidea Code</title>

Hama picked the wrong one while indicating it did find the dirst language http://api.anidb.net:9001/httpapi?request=anime&client=hama&clientver=1&protover=1&aid=9249 [ ] title: Btooom! [ ] original_title: Btooom! [ ] language_rank: 1

<title xml:lang="zh-Hant" type="official">BTOOOM! 驚爆遊戲</title>
<title xml:lang="zh-Hans" type="official">BTOOOM! 惊爆游戏</title>

second item provided the title, but is not consistent and ignores language...

Code analysis

https://github.com/ZeroQI/Hama.bundle/blob/master/Contents/Code/AniDB.py#L184 title, original_title, language_rank = GetAniDBTitle(xml.xpath('/anime/titles/title'))

https://github.com/ZeroQI/Hama.bundle/blob/c53b2af530ee028294336378585b05150a6d295e/Contents/Code/AniDB.py#L381 def GetAniDBTitle(titles, lang=None, title_sort=False):

Seem like language information is missing, line 184, please replace it with: title, original_title, language_rank = GetAniDBTitle(xml.xpath('/anime/titles/title'), [language.strip() for language in Prefs['SerieLanguagePriority'].split(',')])

theandychung commented 2 years ago

Didn't work out, didn't see any change to the title in plex. Here is the log. I deleted the old log to make sure those are created after the change. Qualidea Code 心靈代碼.agent-update.log Qualidea Code 心靈代碼.agent-search.log BTOOOM! 驚爆遊戲.agent-search.log BTOOOM! 驚爆遊戲.agent-update.log

Another question, should the xml file title anime-title or animetitle? image

More question: I checked 11846.xml, and I see the simplified chinese "代号Qualidea" was sorted into "zh-Hant" (the location of this 11846.xml was in plex/config/Library/Application Support/Plex Media Server/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/AniDB/xml/) image it seems like there is something wrong when making the xml for Qualidea Code

theandychung commented 2 years ago

I deleted all the xml files in the xml folder, and everything seems working. Not sure how that old Qualidea Code xml got it wrong but all seems good now. Either your code or the new anime-title.xml fixed it. Do I need to manually update that anime-title.xml from now on?

Thanks.

ZeroQI commented 2 years ago

Xmls are cached a week so seem like an outed was cached

theandychung commented 2 years ago

do I need to manually update that xml file or it should be automatically updated in the future?

ZeroQI commented 2 years ago

https://github.com/ZeroQI/Hama.bundle/blob/c53b2af530ee028294336378585b05150a6d295e/Contents/Code/AniDB.py#L384 Not specifying the sereis title is ok since it does use it by default so my code is useless It seems the xml was downloaded without traditional chinese and changed afterwards, but stayed cached for a week