ZeroQI / Hama.bundle

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

Suicide Squad Isekai is pulling the Japanese episode summaries from TVDB #576

Open Jinra opened 3 months ago

Jinra commented 3 months ago

Problem

Oddly enough, the series summary is in english, but episode summaries are pulling from the Japanese version. I've done quite a bit of testing in the bundle, but can't figure out why it only wants to pull Japanese.

I've tested on another anime that's inheriting from TVDB (Berserk 1997), but that pulls both series and episode summaries in English as expected. Any API calls either from CLI or browser, both pull summaries in english, even when copying the exact headers and token the bundle is using.

Here's a python snippet I've been using for testing. The only way I can get it to pull in Japanese is to change the Accept-Language key value to ja

import requests

url = 'https://api.thetvdb.com'
test_ep = '/series/436846/episodes?page=1'
token = 'A27AD9BE0DA63333'
login_ep = '/login'
headers = {
    'User-agent': 'Plex/HAMA',
    'Content-type': 'application/json',
    'Accept-Language': 'en'
}
bearer_token = ''

data = {
    'apikey': token
}

if not bearer_token:
    r = requests.post(url+login_ep, headers=headers, json=data)
    bearer_token = r.json()['token']

headers['Authorization'] = f'Bearer {bearer_token}'
r = requests.get(url+test_ep, headers=headers)

Log Snippet

[X]    s1e1 s01e001 anidbid:   18098 air_date: 2024-06-27 abs_number: 1, title: 第1話
 - [1] title:   [en] 第1話
 - [1] summary: [en] ″新しい世界″。狂気に満ちた理想を掲げ毎夜ゴッサム・シティを暴れ回るハーレイ・クインとジョーカーだったが、カタナの襲撃により、ハーレイは監獄にブチ込まれてしまう。収監の半年後、A.R.G.U.S長官のアマンダはハーレイを気絶させ監獄から連れ出し、ヘリコプターへと乗せる。目を覚ましたハーレイの目の前にいたのは、悪党面したおっさん=デッドショット、お調子者のナルシスト=クレイフェイス、ズタ袋を被ったマッチョマン=ピースメイカー!!意味不明な状況下、モニター越しのアマンダから告げられたのは、爆弾付きの極秘ミッションだった!!
common.SaveFile() - CachePath: '/config/Library/Application Support/Plex Media Server/Plug-in Support/Data/com.plexapp.agents.hama/DataItems', file: 'TheTVDB/json/436846/episode_9879316_ja.json'

Root Agent Log

2024-08-22 00:20:16,149 - 15151ea57b38 - Fetching 'https://api.thetvdb.com/series/436846/episodes?page=1' from the HTTP cache
2024-08-22 00:20:16,171 - 15151ea57b38 - Downloaded URL 'https://api.thetvdb.com/series/436846/episodes?page=1'
ZeroQI commented 3 months ago

Plex library language is the one used for the summaries, whether series or episodes. Metadata source for each is not indicated.

I've done quite a bit of testing in the bundle, but can't figure out why it only wants to pull Japanese.

If you did look in the series specific logs, it tells the metadata source priority for each field AND which source provided which value... Logs location is in the troubleshooting section of the readme

Jinra commented 3 months ago

If you did look in the series specific logs, it tells the metadata source priority for each field AND which source provided which value

Yes and it is as I mentioned, they're both pulling from TVDB. I'm just not sure why it's pulling the Japanese version

Plex library language is the one used for the summaries, whether series or episodes.

Library is set to English, and language priorities are only en

Source Log

metadata.seasons[ 1].episodes[  1]
[?] rank: 0, source_title:   AniDB, title: "Episode 1"
[!] title: Episode 1, language_rank 0, rank: 0, len(languages): "3"
[=] title                          Sources: (AniDB), TheTVDB                                              Inside: '['TheTVDB', 'AniDB']'  Value: 'Episode 1'
[=] summary                        Sources: (TheTVDB)                                                     Inside: '['TheTVDB']'  Value: '″新しい世界″。狂気に満ちた理想を掲げ毎夜ゴッサム・シティを暴れ回るハーレイ・クインとジョーカーだったが、カタナの襲撃により、ハーレイは監獄にブチ込まれてしまう..'
[=] originally_available_at        Sources: (AniDB), TheTVDB                                              Inside: '['TheTVDB', 'AniDB']'  Value: '2024-06-27'
[=] directors                      Sources: (AniDB),TheTVDB                                               Inside: '['AniDB']'  Value: 'Osada Eri'
[=] producers                      Sources: (AniDB),TheTVDB                                               Inside: '['AniDB']'  Value: 'Umehara Eiji,Nagatsuki Tappei'
[=] rating                         Sources:  TheTVDB, AniDB| TheTVDB, (AniDB)                             Inside: '['AniDB']'  Value: '3.20'
[=] thumbs                   ( 1)  Sources: (TheTVDB)                                                     Inside: '['TheTVDB']'  Value: '{'https://thetvdb.plexapp.com/banners/v4/episode/9879316/screencap/667c2935936db.jpg': ('TheTVDB/episodes/667c2935936db.jpg', 1, None)}'
[=] duration                       Sources: (TheTVDB), AniDB, MyAnimeList, TheMovieDb, OMDb               Inside: '['TheTVDB', 'AniDB']'  Value: '1440000'
[=] content_rating                 Sources: AniDB, (TheTVDB)                                              Inside: '['TheTVDB']'  Value: 'TV-MA'
ZeroQI commented 3 months ago

https://api.thetvdb.com/series/436846/episodes?page=1 doesn't have japanese summary, title pulled from AniDB.

Cached file japanese indeed TheTVDB/json/436846/episode_9879316_ja.json

Don't have logs so cannot check the json for each episode by clicking on it to identify the issue...

Jinra commented 3 months ago

https://api.thetvdb.com/series/436846/episodes?page=1 doesn't have japanese summary, title pulled from AniDB.

Yea I'm only talking about the summaries. There is a Japanese summary which is what Hama is pulling for episodes_page1-en.json attached here episodes_page1_en.json

Don't have logs so cannot check the json for each episode by clicking on it to identify the issue...

Here are the full logs Suicide Squad ISEKAI {imdb-tt28279848}.agent-update.log

Jinra commented 3 months ago

After some more digging and testing. I think the problem is the line here https://github.com/ZeroQI/Hama.bundle/blob/daa43001bc1ced67aa2f90de8c61e5a1d109e862/Contents/Code/TheTVDBv2.py#L234

This seems to determine the search language. I have my priority setup as en, x-jat, ja. Since line 71 defining language_episodes seems to ignore x-jat, the remaining array is just ['en', 'ja']. The logic in line 234 seems to ignore the first priority item entirely and use the language at index 1 which is ja for me.

ZeroQI commented 1 month ago

common.SaveFile() - CachePath: '/config/Library/Application Support/Plex Media Server/Plug-in Support/Data/com.plexapp.agents.hama/DataItems', file: 'TheTVDB/json/436846/episodes_page1_en.json' => the file says english but contain Japanese summaries, is loaded at that line, and use lang variable (the library language which is set to english)

https://github.com/ZeroQI/Hama.bundle/blob/daa43001bc1ced67aa2f90de8c61e5a1d109e862/Contents/Code/TheTVDBv2.py#L129

delete the cached file, metadata search for series and modify title searched to "clear-cache", cancel, and refresh metadata and check this json file content for english summary

ZeroQI commented 2 weeks ago

Issue still present ?

Jinra commented 2 weeks ago

it might be, but I've adjusted my language to only have en as a workaround