Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMDB integration #1190

Open
Rand-Random opened this issue Oct 20, 2024 · 6 comments
Open

TMDB integration #1190

Rand-Random opened this issue Oct 20, 2024 · 6 comments

Comments

@Rand-Random
Copy link

Rand-Random commented Oct 20, 2024

Noticed the drop of TvDB, I had auto-link enabled sadly this setting didn't get ported to TMDB.
Therefor I noticed new episodes didn't get images as it used to.

I re-enabled the auto-link setting, but now I wonder is there a way to tell shoko to try to automagically match my entire collection to TMDB?

Notice a bug (or unknown behaviour) in matching episodes as well.

Why did EP 03 not match with S01E03 the date is identical, S01E01 matches neither title nor date
image

Also should BG (Best Guess) exclude entries that already have DT (Dates and Title Match) ?

Edit:
Saw the latest commits, so maybe the matching was already fixed.

@harshithmohan
Copy link
Member

I re-enabled the auto-link setting, but now I wonder is there a way to tell shoko to try to automagically match my entire collection to TMDB?

Run import action

@Rand-Random
Copy link
Author

Rand-Random commented Oct 20, 2024

I re-enabled the auto-link setting, but now I wonder is there a way to tell shoko to try to automagically match my entire collection to TMDB?

Run import action

Thanks, will try it.

Ragarding the matching issue EP 03 not using S01E03 I downloaded the newest daily/canary build and yes, the issue was fixed.
There for I am closing this issue. @revam Thanks.

@Rand-Random
Copy link
Author

Hope its okay, to re-open the issue, why does Shoko match the following:

[2024-10-29 17:05:10:057] Info|SearchTmdbJob_AnimeID:18756 > Linking anime OVA Incha Couple ga You Gal-tachi to Sex Training Suru Hanashi (18756) to show 無責任艦長タイラー OVA (128948)
[2024-10-29 17:05:10:057] Info|Shoko.Server.Providers.TMDB.TmdbLinkingService > Adding TMDB show link: AniDB (AnimeID=18756) → TMDB Show (ID=128948)

I don't see any resemblance.

Why does plex (shoko metadata) not use the same image as shoko does?
image

I would assume because the order of the images is different than in shoko and it uses the first image.

Censored the NSFW images just in case.

@Rand-Random Rand-Random reopened this Oct 29, 2024
@harshithmohan
Copy link
Member

Webui uses the anidb image while Metadata adds TMDB/TVDB images first and then AniDB

@Rand-Random
Copy link
Author

Had a look at the *.py file of shoko metadata and found the following lines of code in __init__.py:

series = HttpReq("api/serie?id=%s&level=3&allpics=1&tagfilter=%d" % (aid, flags))

I double checked with swagger, what the order of images is when this api is called
image

The order seems to be correct, first ANIDB and than TMDB, so I diged further and found this line of code:

self.metadata_add(metadata.posters, try_get(series['art'], 'thumb', []))

the method metadata_add looks like this:

    def metadata_add(self, meta, images):
        valid = list()
        
        for art in images:
            try:
                if 'support/plex_404.png' in art['url']:
                    continue
                if 'Static/plex_404.png' in art['url']:
                    continue
                if ':' in art['url']:
                    urlparts = urllib.parse.urlparse(art['url'])
                    art['url'] = art['url'].replace("{scheme}://{host}:{port}/".format(scheme=urlparts.scheme, host=urlparts.hostname, port=urlparts.port), '')
                url = "http://{host}:{port}{relativeURL}".format(host=Prefs['Hostname'], port=Prefs['Port'], relativeURL=art['url'])
                idx = try_get(art, 'index', 0)
                Log("[metadata_add] :: Adding metadata %s (index %d)" % (url, idx))
                meta[art['url']] = Proxy.Media(HTTP.Request(url).content, idx)
                valid.append(art['url'])
            except Exception as e:
                Log("[metadata_add] :: Invalid URL given (%s), skipping" % art['url'])
                Log(e)

        meta.validate_keys(valid)

        for key in meta.keys():
            if (key not in valid):
                del meta[key]

the code seems to work with indexes, in the code:

idx = try_get(art, 'index', 0)

but looking at the swagger result the indexes seems to be correct.
I lucky guessed that maybe the index isn't 0 based and added the code idx += 1 here

idx = try_get(art, 'index', 0)
+ idx += 1
Log("[metadata_add] :: Adding metadata %s (index %d)" % (url, idx))

I verified that this line is working as one would expect by doing this steps:

  1. adding the line
  2. restarted plex media server
  3. refreshed the metadata of the entry in plex
    = order is correct
    image

to double check, I did those step

  1. removed the line
  2. restarted plex media server
  3. refreshed the metadata of the entry in plex
    = order is incorrect
    image

Note:
after a couple of attempts I noticed, I don't even need to restart the server the changes in __init__.py are immediatly effective

I would assume this to be an error, which also present in the current master of shoko metadata
https://github.com/Cazzar/ShokoMetadata.bundle/blob/a78b876b74cddd666148097596e015549a8f1d61/Contents/Code/__init__.py#L281C13-L281C47

ping @Cazzar , maybe you want to chime in

@harshithmohan
Copy link
Member

I would make an issue on that repo so that it doesn't go missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants