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.6k stars 105 forks source link

Feature request: inspect Show and Season #1117

Closed simonc56 closed 2 years ago

simonc56 commented 2 years ago

Feature description

Actually, when running plextraktsync inspect 4922 it will crash if 4922 (the Plex ratingKey) is a show or a season. It will be ok only if it's a movie or an episode.

I think for shows and seasons, it should al least display title, type and guid.

Use case

This is usefull for debugging.

Trace

Inspecting 4918: <tmdb:4289:Show:4918:Break-High>
URL: https://app.plex.tv/desktop/#!/server/3f48753c4e05de184b1316596945dd36194419e4/details?key=/library/metadata/4918
Title: Break High
Media.Duration: 03:52:00
Media.Type: 'show'
Media.Guid: 'plex://show/5e530863e264b7001fc42a9a'
Media.Guids: [<Guid:imdb://tt181299>, <Guid:tmdb://4289>, <Guid:tvdb://25848>]
Guids:
  Guid: <PlexGuid:tmdb://4289>, Id: 4289, Provider: 'tmdb'
  Guid: <PlexGuid:tvdb://25848>, Id: 25848, Provider: 'tvdb'
  Guid: <PlexGuid:imdb://tt181299>, Id: tt181299, Provider: 'imdb'
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Prog\PlexTraktSync\plextraktsync\__main__.py", line 18, in <module>
    cli()
  File "C:\Users\twolaw\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\twolaw\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\twolaw\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\twolaw\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\twolaw\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "D:\Prog\PlexTraktSync\plextraktsync\cli.py", line 28, in wrap
    cmd(*args, **kwargs)
  File "D:\Prog\PlexTraktSync\plextraktsync\commands\inspect.py", line 105, in inspect
    inspect_media(id)
  File "D:\Prog\PlexTraktSync\plextraktsync\commands\inspect.py", line 71, in inspect_media
    print(f"Metadata: {pm.to_json()}")
  File "D:\Prog\PlexTraktSync\plextraktsync\plex_api.py", line 412, in to_json
    "resolution": self.resolution,
  File "D:\Prog\PlexTraktSync\plextraktsync\plex_api.py", line 309, in resolution
    stream = self.video_streams[0]
  File "D:\Prog\PlexTraktSync\plextraktsync\plex_api.py", line 268, in video_streams
    return self.streams(VideoStream)
  File "D:\Prog\PlexTraktSync\plextraktsync\decorators\flatten.py", line 7, in inner
    return list(method(*args, **kwargs))
  File "D:\Prog\PlexTraktSync\plextraktsync\plex_api.py", line 257, in streams
    for part in self.parts:
  File "D:\Prog\PlexTraktSync\plextraktsync\plex_api.py", line 252, in parts
    for media in item.item.media:
  File "C:\Users\twolaw\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\plexapi\base.py", line 487, in __getattribute__
    value = super(PlexPartialObject, self).__getattribute__(attr)
AttributeError: 'Show' object has no attribute 'media'
glensc commented 2 years ago

inspect was written in sense of debugging, and it's organically grown, depending on the needs. episode support was already added.

glensc commented 2 years ago

Show inspect:

glensc commented 2 years ago

How to resolve Season guid to something that trakt allows to search?

Guids:
  Guid: <PlexGuid:com.plexapp.agents.thetvdb://328724/2?lang=en>, Id: 328724/2, Provider: 'tvdb'
Metadata: {'collected_at': '2020-11-07:T15:59:00.000Z', 'media_type': 'digital'}
[2022-10-21 01:46:26] ERROR    Ignoring invalid id: '328724/2'
simonc56 commented 2 years ago

With legacy plex agent you can't (will it be deprecated sometime). But with the new agent you have external guids, right?

glensc commented 2 years ago

looks like trakt doesn't allow searching by season

Media.Type: 'season'
Media.Guid: 'plex://season/602e62e291bd55002cf7d7c5'
Media.Guids: [<Guid:tmdb://61356>]
Guids:
  Guid: <PlexGuid:tmdb://61356>, Id: 61356, Provider: 'tmdb'
glensc commented 2 years ago

yep. missing from docs too:

tmdb /search/tmdb/:id
  /search/tmdb/:id?type=movie
  /search/tmdb/:id?type=show
  /search/tmdb/:id?type=episode
  /search/tmdb/:id?type=person
glensc commented 2 years ago

just skipping such searches then: