jellyfin / jellyfin-plugin-anilist

GNU General Public License v2.0
37 stars 22 forks source link

v10 has incorrect person Id linked when clicking crew portrait #82

Closed sjorge closed 1 month ago

sjorge commented 1 month ago

After updating to v10 we now support retrieving person data from anilist (this works fine if you manually identify a person) thanks to this PR.

However when clicking on an show -> crew -> person, the wrong ID gets loaded. (This is the case for an show fetched with v9 or one fetched on v10).

Retrieved from the show data: Image

But actually links to Image

When clicked imdb data is correct: https://www.imdb.com/name/nm6092929 tmdb data is correct: https://www.themoviedb.org/person/1452028 anilist data is incorrect: https://anilist.co/staff/170468/

After clicking once, the entire person data gets replaced with the anilist data which is not correct.

sjorge commented 1 month ago

Tagging @HansLehnert since you added support, I spot checked 10 different person and they are all wrong. It somehow seems to favor staff not VAs, still not sure why the names are completely different.

For now reverted to version 9.0 pre the changes and disabled auto plugin updates.

Edit: It seems it only 'goes wrong' once clicking on the person on show when ti tries to load the person page. The tmdb/imdb entries when available are still linked to the correct person only the anilist one is wrong, and it seems to use that one to fetch all the data.

Before rolling back I tried around 10-13 different people, on 3 different shows. After removing the plugin clicking on a person no longer has it refresh and incorrect linkes (makes sense as 9.0 does not support this)

HansLehnert commented 1 month ago

This is because v9 had a bug and would incorrectly grab the anime id and persist it as the person id. So, for all series/movies that were refreshed with the old version, the person items will point to some random entry.

Refreshing the movie/series metadata should fix the ids. I don't have any other better solution for cleaning up the bad ids.

sjorge commented 1 month ago

Hmm I'm pretty sure I did a full refresh of the series as I was also having a issue were the ratings are no longer fetched.

Back to the PersonID being wrong, theoretically it means there should (with just v9 installed) already be incorrect AniListPersonID's in the database for everything? If so, it's probably possible to drop them from the database somehow.

HansLehnert commented 1 month ago

Hmm I'm pretty sure I did a full refresh of the series as I was also having a issue were the ratings are no longer fetched.

Which kind of refresh did you try? If you select the "scan for new and updated files", it won't update the series metadata, I believe. Also, there's another issue with the plugin when trying to refresh too many items where it'll reach the API rate limit and it will fail halfway through... So if you had too many items perhaps not all of them got refreshed.

Back to the PersonID being wrong, theoretically it means there should (with just v9 installed) already be incorrect AniListPersonID's in the database for everything? If so, it's probably possible to drop them from the database somehow.

Yes, all persons have incorrect ids. You could do some manual DB operation to drop all the bad ids, but they will only get repopulated when refreshing the series.

sjorge commented 1 month ago

Hmm I'm pretty sure I did a full refresh of the series as I was also having a issue were the ratings are no longer fetched.

Which kind of refresh did you try? If you select the "scan for new and updated files", it won't update the series metadata, I believe. Also, there's another issue with the plugin when trying to refresh too many items where it'll reach the API rate limit and it will fail halfway through... So if you had too many items perhaps not all of them got refreshed.

A full replace without images.

Back to the PersonID being wrong, theoretically it means there should (with just v9 installed) already be incorrect AniListPersonID's in the database for everything? If so, it's probably possible to drop them from the database somehow.

Yes, all persons have incorrect ids. You could do some manual DB operation to drop all the bad ids, but they will only get repopulated when refreshing the series.

Will spend some time tomorrow after work, going to see if I can do it via the API first somehow if not db it is. If I come up with something clean I'll post it here.

sjorge commented 1 month ago
  1. purge all the wrong personIds
  2. upgrade to v10
  3. search missing or replace all will add the ID now.

I tried via the API, it sort of works via de metadata editor API but having to include the whole payload again had some weird results sometimes. I instead just clean them up in the database directly.

import sqlite3
con = sqlite3.connect("/var/lib/jellyfin/data/library.db")
con.row_factory = sqlite3.Row

cur = con.cursor();

cur.execute("PRAGMA case_sensitive_like=ON;");
res = cur.execute("SELECT guid,path,ProviderIds FROM TypedBaseItems WHERE Type = 'MediaBrowser.Controller.Entities.Person' AND providerids LIKE '%AniList=%';").fetchall();
for row in res:
    newids = {}
    ids = row['ProviderIds']
    dbnewids = ""
    for id in ids.split('|'):
        id = id.split('=')
        if id[0] == "AniList":
            continue
        newids[id[0]] = id[1]

    for k,v in newids.items():
        dbnewids += f"{k}={v}|"
    if len(dbnewids) > 0 and dbnewids[-1] == "|":
        dbnewids = dbnewids[:-1]

    print(f"{row}: {ids} -> {dbnewids}")
    cur.execute(
        "UPDATE TypedBaseItems SET ProviderIds = ? WHERE guid = ?",
        (dbnewids, row['guid'])
    )
con.commit()
con.close()

Do this while jellyfin is stopped obviously, I'm sure there is a 'cleaner' api only way to do this but I couldn't be bothered to spend afew days writing a script for that.

Use at your own risk obviously and make a backup first

HansLehnert commented 1 month ago
  1. purge all the wrong personIds
  2. upgrade to v10
  3. search missing or replace all will add the ID now.

When I tried earlier, using "search for missing metadata" or "replace all metadata" would overwrite the incorrect ids without needing to purge the old ones. Did you try that on single items?

sjorge commented 1 month ago
  1. purge all the wrong personIds
  2. upgrade to v10
  3. search missing or replace all will add the ID now.

When I tried earlier, using "search for missing metadata" or "replace all metadata" would overwrite the incorrect ids without needing to purge the old ones. Did you try that on single items?

I'm pretty sure I tried that yesterday, the problem seems to be once you click on a person before refreshing it updates them with the wrong data, then a search missing at least did not fix it.

My library is pretty big so it will takes weeks to refresh, I'm going to have to write a script for that too. If I refresh more than 5 shows at one time I hit the rate limit.

With the wrong Ids gone, for now it no longer 'loads' incorrect data when clicking on a person.