Taxel / PlexTraktSync

A python script that syncs the movies, shows and ratings between trakt and Plex (without needing a PlexPass or Trakt VIP subscription)
MIT License
1.61k stars 105 forks source link

ERROR: <Show:61408:xxxxxxx>: Unable to parse a valid provider from guid com.plexapp.agents.xbmcnfotv #452

Closed Hebusing closed 3 years ago

Hebusing commented 3 years ago

The problem

While Movies are synchronizing well, none of the shows are. I've got the following error message for all of them:

ERROR: <Show:61408:24>: Unable to parse a valid provider from guid com.plexapp.agents.xbmcnfotv://76290?lang=xn

76290 is the TheTVDB Id of this show, you check it on their website.

I didn't modify the config.json file:

    "xbmc-providers": {
        "movies": "imdb",
        "shows": "tvdb"
    },

I'm sure I've done something wrong but don't know what... :-(

Expected behavior

Shows should synchronize without those errors.

Steps to reproduce the behavior

I've entered the simple command to sync only the shows:

python3 -m plex_trakt_sync sync --sync tv

In Plex, I'm using the XBMCnfoTVImporter and XBMCnfoMoviesImporter agents.

I do recall that the synchro was working with a previous installation I had, but I've just tried with version 0.7.19 and have a similar error:

Processing TV Shows  [------------------------------------]  2/191  00:15:20
ERROR: <xbmcnfotv:76290:<Show:61408:24>>: Unable to parse a valid provider from guid:'com.plexapp.agents.xbmcnfotv://76290?lang=xn', guids:[]

Workarounds

There is no workaround.

Environment

glensc commented 3 years ago

Post result of python3 -m plex_trakt_sync inspect 61408

glensc commented 3 years ago

also, what are these?

please share some details, links etc

simonc56 commented 3 years ago

The setting file is ok, the id provided by xbmc is valid on tvdb.

image

Problem is in plex_api.py, the provider should be detected as xbmcnfo : https://github.com/Taxel/PlexTraktSync/blob/295c5ff7ae8bcca7b0e44a34295a35cd34544021/plex_trakt_sync/plex_api.py#L68-L70 Unfortunately the string == comparison doesn't match because it is xbmcnfotv instead of xbmcnfo.

A separate test with xbmcnfotv was in the original commit, it has been deleted by mistake when refactoring code I think (@glensc)

A solution is to replace line 68 by : if "xbmcnfo" in x:

Duplicate of :

glensc commented 3 years ago

Ok, seems the guids for these are:

Movies do look like:

  • com.plexapp.agents.xbmcnfo://tt0120586?lang=xn
  • com.plexapp.agents.xbmcnfo://tt0091129?lang=xn
  • com.plexapp.agents.xbmcnfo://tt0115857?lang=xn

and Shows like this:

  • com.plexapp.agents.xbmcnfotv://74380?lang=xn
  • com.plexapp.agents.xbmcnfotv://73838?lang=xn
glensc commented 3 years ago

Seems XBMCnfoTVImporter is third party add on:

and:

glensc commented 3 years ago

@Hebusing try this fix:

Hebusing commented 3 years ago

Hi @glensc , @twolaw ,

Thank you for your quick answer and support!

I've updated the line 68 in plex_trakt_sync/plex_api.py as per your commit (https://github.com/Taxel/PlexTraktSync/pull/453/files), however I'm having this issue now:

Processing TV Shows:   0%|                                                                                                                                                                                           | 0/191 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/PlexTraktSync/plex_trakt_sync/__main__.py", line 16, in <module>
    cli()
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 131, in sync
    sync_all(walker=w, trakt=trakt, plex=plex, dry_run=dry_run)
  File "/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 40, in sync_all
    runner.sync(walker, listutil, dry_run=dry_run)
  File "/PlexTraktSync/plex_trakt_sync/sync.py", line 21, in sync
    for episode in walker.find_episodes():
  File "/PlexTraktSync/plex_trakt_sync/walker.py", line 92, in find_episodes
    yield from self.episode_from_show(show)
  File "/PlexTraktSync/plex_trakt_sync/walker.py", line 113, in episode_from_show
    me = self.mf.resolve_any(pe, show.trakt)
  File "/PlexTraktSync/plex_trakt_sync/media.py", line 115, in resolve_any
    m = self.resolve_guid(guid, tm)
  File "/PlexTraktSync/plex_trakt_sync/media.py", line 132, in resolve_guid
    if guid.provider in ["local", "none", "agents.none"]:
  File "/PlexTraktSync/plex_trakt_sync/plex_api.py", line 70, in provider
    x = CONFIG["xbmc-providers"][self.media_type]
KeyError: 'episodes'

I've also run the command you suggested above python3 -m plex_trakt_sync inspect 61408, and here is the result:

PlexTraktSync inspect [d406ca4b: Sort dependencies @2021-08-16 23:51:38]
Inspecting: <tvdb:76290:<Show:61408:24>>
URL: https://app.plex.tv/desktop/#!/server/458a72f90678cd921133072963cd33f507447c23/details?key=/library/metadata/61408
Media.Guid: 'com.plexapp.agents.xbmcnfotv://76290?lang=xn'
Guids:
  Guid: com.plexapp.agents.xbmcnfotv://76290?lang=xn, Id: 76290, Provider: tvdb
Metadata: {'collected_at': '2020-07-09:T06:39:10.000Z', 'media_type': 'digital'}
Trakt: https://trakt.tv/shows/1960
Watched on Plex: False
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/PlexTraktSync/plex_trakt_sync/__main__.py", line 16, in <module>
    cli()
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/PlexTraktSync/plex_trakt_sync/commands/inspect.py", line 53, in inspect
    print(f"Warched on Trakt: {m.watched_on_trakt}")
  File "/PlexTraktSync/plex_trakt_sync/media.py", line 72, in watched_on_trakt
    return watched.get_completed(self.show_trakt_id, self.season_number, self.episode_number)
  File "/PlexTraktSync/plex_trakt_sync/media.py", line 45, in show_trakt_id
    return self.show.trakt_id
AttributeError: 'NoneType' object has no attribute 'trakt_id'

Hope that helps! Happy to do other tests as well. :-) THANK YOU again!

glensc commented 3 years ago

Looks like it's more messed up than simple line change.

for the workaround, you can try using older versions (0.6.x, 0.5.x), if the bug is related to refactoring in this project, it may help. but if the bug is due agent behaving differently, then no.

I've added one more commit to #453, it may fix the error sync command was having, but as inspect is having a different error, the sync may match the completely wrong trakt object (shows vs episodes). so use with care not to corrupt your data.

you may turn everything off in "sync" section in config.json and use --dry-run option to be extra careful, but that may not show what is happening.

simonc56 commented 3 years ago

I have a Kodi database with Plex on it, i'll try those XBMCnfoTVImporter and XBMCnfoMoviesImporter agent.

glensc commented 3 years ago

I think just need to put the .nfo file along the media, not full Kodi?

glensc commented 3 years ago

Sync should be fixed with this PR:

And inspect with this PR:

glensc commented 3 years ago

Aside, someone could document that those two plugins are supported by sending a pull request updating README.md.

almightiest commented 3 years ago

@glensc I applied the 2 PRs and got the following issue on inspect:

python3 -m plex_trakt_sync inspect 9383

PlexTraktSync inspect [Unknown version] WARNING: No response from https://REDACTED:32400, fallback to http://REDACTED:32400 Inspecting 9383: <tvdb:281776:<Show:9383:You're-the-Worst>> URL: https://app.plex.tv/desktop/#!/server/REDACTED/details?key=/library/metadata/9383 Media.Type: show Media.Guid: 'com.plexapp.agents.xbmcnfotv://281776?lang=xn' Guids: Guid: com.plexapp.agents.xbmcnfotv://281776?lang=xn, Id: 281776, Provider: tvdb Metadata: {'collected_at': '2021-07-28:T14:17:53.000Z', 'media_type': 'digital'} Trakt: https://trakt.tv/shows/60635 Watched on Plex: False Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/bleh/PlexTraktSync/plex_trakt_sync/main.py", line 16, in cli() File "/usr/lib/python3/dist-packages/click/core.py", line 764, in call return self.main(args, kwargs) File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke return callback(args, **kwargs) File "/home/bleh/PlexTraktSync/plex_trakt_sync/commands/inspect.py", line 61, in inspect print(f"Warched on Trakt: {m.watched_on_trakt}") File "/home/bleh/PlexTraktSync/plex_trakt_sync/media.py", line 78, in watched_on_trakt return watched.get_completed(self.show_trakt_id, self.season_number, self.episode_number) File "/home/bleh/PlexTraktSync/plex_trakt_sync/media.py", line 46, in show_trakt_id raise RuntimeError(f"Unexpected call: episode without show property") RuntimeError: Unexpected call: episode without show property

I'm sure it's user error, so apologies in advance :-D

glensc commented 3 years ago

It seems you did not apply changes fully from #456, but I'll merge it so it's only one PR to test at a time.

you should probably give details how you applied the changes, then can direct what you did wrong.

glensc commented 3 years ago

@pgjensen on the other hand, why are you doing inspect 9383 you're not the original reporter, so don't even know what is your error? also 9383 seems to be show, not episode, so it's a different error.

almightiest commented 3 years ago

Sorry about the confusion, stemming from original issue being about show, and then turning into episode issue as well. I can log a separate bug regarding inspect for shows not working if you prefer.

inspect 76971 for episode did work successfully with latest main and #453 applied

glensc commented 3 years ago

Ok. i'll merge #453 then

Hebusing commented 3 years ago

@glensc: it works, thank you! :-)

glensc commented 3 years ago

@Hebusing: I'm not certain how this supposed to work:

This is an example (created with stub data)

$ ./plex_trakt_sync.sh inspect 1461
Inspecting 1461: <tvdb:1461:<Show:1461:Game-of-Thrones>>
Media.Type: show
Media.Guid: 'com.plexapp.agents.xbmcnfotv://1461?lang=xn'
Guids:
  Guid: com.plexapp.agents.xbmcnfotv://1461?lang=xn, Id: 1461, Provider: tvdb
WARNING: <Show:1461:Game-of-Thrones>: Skipping guid com.plexapp.agents.xbmcnfotv://1461?lang=xn not found on Trakt

what is see it just has Plex Id in the url 1461->1461, so obviously this has no match in either database (tvdb, imdb) whatever I configure in config.json.

can you give insights into what I've done wrong? or even better, submit a pull request to this project readme documenting this integration support and how to set it up.

simonc56 commented 3 years ago

You are supposed to tell in the config.json what provider xbmc is using : tmdb, tvdb, tmdb,... Therefore, the script will know that ids with xbmcnfo(tv) provider are in fact coming from this specified provider.

In your exemple, you have setup xbmcnfotv as using tvdb ids. Which is not correct for Game-of-Thrones because its id on tvdb is 121361.

source : https://kodi.wiki/view/NFO_files/Episodes#nfo_Tags

glensc commented 3 years ago

@twolaw please read again what I wrote, and pay attention to the guid value. plex id and what number is in guid are equal, this can't be right, so, therefore, it does not matter what is in my config.json for xbmc-providers.

simonc56 commented 3 years ago

My bad, I misread. Can you show the nfo file ? Maybe the xbmcnfotv agent didn't find the data. Something strange in xbmcnfotv code is :

# if tv show id doesn't exist, create
# one based on hash of title

https://github.com/gboudreau/XBMCnfoTVImporter.bundle/blob/534e7737886135b2d0b43d8ae9ee394f1a116051/Contents/Code/__init__.py#L293-L302

But it doesn't explain the plex id being same number as provider id...

simonc56 commented 3 years ago

I did the test to add a tv episode in Plex with xbmcnfotv agent without the nfo.

The result is the same as you, the xbmcnfotv id is the same as Plex show id (named ratingKey in xml) : 4437

guid="com.plexapp.agents.xbmcnfotv://4437/1/1?lang=xn"

The parentRatingKey is the Plex Season : parentRatingKey="4438" parentGuid="com.plexapp.agents.xbmcnfotv://4437/1?lang=xn"

The grandparentRatingKey is the Plex Show : grandparentRatingKey="4437" grandparentGuid="com.plexapp.agents.xbmcnfotv://4437?lang=xn"

<MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="2" librarySectionTitle="TV Shows" librarySectionUUID="xxxxxxxx-xxxx-xxxxx-9268-xxxxxxxxxxxxx" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1631637446">
<Video ratingKey="4439" key="/library/metadata/4439" parentRatingKey="4438" grandparentRatingKey="4437" guid="com.plexapp.agents.xbmcnfotv://4437/1/1?lang=xn" parentGuid="com.plexapp.agents.xbmcnfotv://4437/1?lang=xn" grandparentGuid="com.plexapp.agents.xbmcnfotv://4437?lang=xn" type="episode" title="2019-04-06" grandparentKey="/library/metadata/4437" parentKey="/library/metadata/4438" librarySectionTitle="Séries TV" librarySectionID="2" librarySectionKey="/library/sections/2" grandparentTitle="Demon Slayer" parentTitle="Saison 1" summary="" index="1" parentIndex="1" viewCount="1" lastViewedAt="1629685218" year="2019" thumb="/library/metadata/4439/thumb/1634312827" art="/library/metadata/4437/art/1634312828" grandparentThumb="/library/metadata/4437/thumb/1634312828" grandparentArt="/library/metadata/4437/art/1634312828" grandparentTheme="/library/metadata/4437/theme/1634312828" duration="1420032" originallyAvailableAt="2019-04-06" addedAt="1629623479" updatedAt="1634312827" audienceRatingImage="themoviedb://image.rating">

The xbmcnfotv agent can't do the match, but Plex still finds other guids (based on filename I think) :

<Guid id="imdb://tt9828480"/>
<Guid id="tmdb://1675448"/>
<Guid id="tvdb://7122169"/>
glensc commented 3 years ago

Indeed. I didn't even have .nfo file present.