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.56k stars 101 forks source link

Fails to sync when TV show Specials (S0) are present. BadRequest: ekey was not provided #900

Closed almightiest closed 2 years ago

almightiest commented 2 years ago

Confirmation

The problem

This is related to https://github.com/Taxel/PlexTraktSync/issues/550#issue-1031300599 - but I'm unsure what scraper agent they were using. I use https://github.com/gboudreau/XBMCnfoTVImporter.bundle which allows me to have the same metadata, locally, for Kodi, Jellyfin and Plex.

When I am scraping the show '24' and it has S00E09 present in the 24 show directory, I get a critical failure. If i scrape it again without any Special episodes present, it works.

update.log:

tail: /home/bleh/.cache/PlexTraktSync/log/plextraktsync.log: file truncated
2022-05-02 10:51:17,030 DEBUG[plexapi]:GET https://hidden.plex.direct:32400/
2022-05-02 10:51:17,032 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-05-02 10:51:17,032 DEBUG[urllib3.connectionpool]:Starting new HTTPS connection (1): hidden.plex.direct:32400
2022-05-02 10:51:18,038 DEBUG[urllib3.connectionpool]:https://hidden.plex.direct:32400 "GET / HTTP/1.1" 200 4102
2022-05-02 10:51:18,039 DEBUG[requests_cache.session]:Pre-cache checks for response from https://hidden.plex.direct:32400/: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-05-02 10:51:18,039 DEBUG[requests_cache.session]:Skipping cache write for URL: https://hidden.plex.direct:32400/
2022-05-02 10:51:18,045 DEBUG[plexapi]:GET https://hidden.plex.direct:32400/library
2022-05-02 10:51:18,047 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-05-02 10:51:18,048 DEBUG[urllib3.connectionpool]:https://hidden.plex.direct:32400 "GET /library HTTP/1.1" 200 289
2022-05-02 10:51:18,048 DEBUG[requests_cache.session]:Pre-cache checks for response from https://hidden.plex.direct:32400/library: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-05-02 10:51:18,048 DEBUG[requests_cache.session]:Skipping cache write for URL: https://hidden.plex.direct:32400/library
2022-05-02 10:51:18,049 DEBUG[plexapi]:GET https://hidden.plex.direct:32400/library/metadata/10000
2022-05-02 10:51:18,049 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-05-02 10:51:18,061 DEBUG[urllib3.connectionpool]:https://hidden.plex.direct:32400 "GET /library/metadata/10000 HTTP/1.1" 200 1232
2022-05-02 10:51:18,061 DEBUG[requests_cache.session]:Pre-cache checks for response from https://hidden.plex.direct:32400/library/metadata/10000: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-05-02 10:51:18,061 DEBUG[requests_cache.session]:Skipping cache write for URL: https://hidden.plex.direct:32400/library/metadata/10000
2022-05-02 10:51:18,064 DEBUG[plexapi]:Reloading Episode 'Redemption' for attr 'parentKey'
2022-05-02 10:51:18,064 DEBUG[plexapi]:GET https://hidden.plex.direct:32400/library/metadata/10000?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1
2022-05-02 10:51:18,066 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}

Plex XML info:

<MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="1" librarySectionTitle="TV Shows" librarySectionUUID="hidden" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1649089686">
<Video ratingKey="10000" key="/library/metadata/10000" parentRatingKey="9999" grandparentRatingKey="1000" guid="com.plexapp.agents.xbmcnfotv://76290/0/9?lang=xn" parentGuid="com.plexapp.agents.xbmcnfotv://76290/0?lang=xn" grandparentGuid="com.plexapp.agents.xbmcnfotv://76290?lang=xn" type="episode" title="Redemption" grandparentKey="/library/metadata/1000" parentKey="/library/metadata/9999" librarySectionTitle="TV Shows" librarySectionID="1" librarySectionKey="/library/sections/1" grandparentTitle="24" parentTitle="Specials" contentRating="TV-14" summary="Set and shot on location in Africa, Bauer and mentor Carl Benton battle an international crisis, while here at home the nation prepares for a new president on inauguration day. Taking place just a few months before the new day dawns, U.S. State Department officer Frank Tramell and Jonah Hodges are pulling the strings that will set the stage and raise the stakes for Season Seven." index="9" parentIndex="0" rating="7.4" viewCount="1" lastViewedAt="1524522595" year="2008" thumb="/library/metadata/10000/thumb/1651502480" art="/library/metadata/9999/art/1651502484" parentThumb="/library/metadata/9999/thumb/1651502484" grandparentThumb="/library/metadata/1000/thumb/1651501696" grandparentArt="/library/metadata/1000/art/1651501696" duration="6130000" originallyAvailableAt="2008-11-23" addedAt="1651502383" updatedAt="1651502480">
<Media id="006" duration="6130000" bitrate="900" width="640" height="352" aspectRatio="1.85" audioChannels="2" audioCodec="mp3" videoCodec="mpeg4" videoResolution="sd" container="avi" videoFrameRate="24p" videoProfile="advanced simple">
<Part accessible="1" exists="1" id="899" key="/library/parts/899/1227655000/file.avi" duration="6130000" file="/mnt/tv/24/24.S00.Redemption.2008/24.s00e09.Redemption.2008.avi" size="732889000" container="avi" indexes="sd" videoProfile="advanced simple">
<Stream id="6353" streamType="1" codec="mpeg4" index="0" bitrate="850" bitDepth="8" chromaLocation="left" chromaSubsampling="4:2:0" codecID="XVID" codedHeight="352" codedWidth="640" frameRate="23.976" height="352" level="5" profile="advanced simple" refFrames="1" width="640" displayTitle="SD (MPEG4)" extendedDisplayTitle="SD (MPEG4)"> </Stream>
<Stream id="6354" streamType="2" selected="1" codec="mp3" index="1" channels="2" bitrate="130" audioChannelLayout="stereo" samplingRate="48000" streamIdentifier="1" displayTitle="Unknown (MP3 Stereo)" extendedDisplayTitle="Unknown (MP3 Stereo)"> </Stream>
</Part>
</Media>
<Extras size="0"> </Extras>
<Related> </Related>
</Video>
</MediaContainer>

S00E09 nfo file:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<episodedetails>
<title>Redemption</title>
<showtitle>24</showtitle>
<rating>7.400000</rating>
<votes>20</votes>
<epbookmark>0</epbookmark>
<year>2008</year>
<top250>0</top250>
<season>0</season>
<episode>9</episode>
<displayseason>7</displayseason>
<displayepisode>0</displayepisode>
<outline></outline>
<plot>Set and shot on location in Africa, Bauer and mentor Carl Benton battle an international crisis, while here at home the nation prepares for a new president on inauguration day. Taking place just a few months before the new day dawns, U.S. State Department officer Frank Tramell and Jonah Hodges are pulling the strings that will set the stage and raise the stakes for Season Seven.</plot>
<tagline></tagline>
<runtime>103</runtime>
<thumb>http://thetvdb.com/banners/episodes/76290/399738.jpg</thumb>
<mpaa>TV-14</mpaa>
<playcount>0</playcount>
<lastplayed></lastplayed>
<file></file>
<path>smb://VIDEO/tv/24/</path>
<filenameandpath>smb://VIDEO/tv/24/24.s00e09.Redemption.2008.avi</filenameandpath>
<id>399738</id>
<uniqueid type="tvdb" default="true">399738</uniqueid>
<uniqueid type="imdb">tt0813980</uniqueid>
<premiered>2008-11-23</premiered>
<status></status>
<code></code>
<aired>2008-11-23</aired>
<studio>FOX (US)</studio>
<trailer></trailer>
<fileinfo>
<streamdetails>
        <audio>
                <channels>2</channels>
                <codec>none</codec>
        </audio>
        <video>
                <aspect>1.818</aspect>
                <codec>none</codec>
                <durationinseconds>6100</durationinseconds>
                <height>352</height>
                <scantype>Progressive</scantype>
                <width>640</width>
        </video>
</streamdetails>
</fileinfo>
<actor>
        <name>Kiefer Sutherland</name>
        <role>Jack Bauer</role>
        <thumb>http://thetvdb.com/banners/actors/44914.jpg</thumb>
</actor>
<actor>
        <name>Mary Lynn Rajskub</name>
        <role>Chloe O'Brian</role>
        <thumb>http://thetvdb.com/banners/actors/360573.jpg</thumb>
</actor>
<actor>
        <name>Yvonne Strahovski</name>
        <role>Kate Morgan</role>
        <thumb>http://thetvdb.com/banners/actors/328133.jpg</thumb>
</actor>
<actor>
        <name>Carlos Bernard</name>
        <role>Tony Almeida</role>
        <thumb>http://thetvdb.com/banners/actors/78578.jpg</thumb>
</actor>
<actor>
        <name>Jude Ciccolella</name>
        <role>Mike Novick</role>
        <thumb>http://thetvdb.com/banners/actors/91331.jpg</thumb>
</actor>
<actor>
        <name>Glenn Morshower</name>
        <role>Aaron Pierce</role>
        <thumb>http://thetvdb.com/banners/actors/91321.jpg</thumb>
</actor>
<actor>
        <name>Tanya Wright</name>
        <role>Patty Brooks</role>
        <thumb>http://thetvdb.com/banners/actors/91311.jpg</thumb>
</actor>
<actor>
        <name>Alberta Watson</name>
        <role>Erin Driscoll</role>
        <thumb>http://thetvdb.com/banners/actors/91281.jpg</thumb>
</actor>
<actor>
        <name>Eric Balfour</name>
        <role>Milo Pressman</role>
        <thumb>http://thetvdb.com/banners/actors/82135.jpg</thumb>
</actor>
<actor>
        <name>Regina King</name>
        <role>Sandra Palmer</role>
        <thumb>http://thetvdb.com/banners/actors/82134.jpg</thumb>
</actor>
<actor>
        <name>Peter MacNicol</name>
        <role>Tom Lennox</role>
        <thumb>http://thetvdb.com/banners/actors/82133.jpg</thumb>
</actor>
<actor>
        <name>Marisol Nichols</name>
        <role>Nadia Yassir </role>
        <thumb>http://thetvdb.com/banners/actors/82132.jpg</thumb>
</actor>
<actor>
        <name>Jayne Atkinson</name>
        <role>Karen Hayes</role>
        <thumb>http://thetvdb.com/banners/actors/82131.jpg</thumb>
</actor>
<actor>
        <name>Carlo Rota</name>
        <role>Morris O'Brian</role>
        <thumb>http://thetvdb.com/banners/actors/82130.jpg</thumb>
</actor>
<actor>
        <name>Janeane Garofalo</name>
        <role>Janis Gold</role>
        <thumb>http://thetvdb.com/banners/actors/82129.jpg</thumb>
</actor>
<resume>
        <position>0.000000</position>
        <total>0.000000</total>
</resume>
</episodedetails>

S01E01 nfo file:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<episodedetails>
<title>12:00 A.M. - 1:00 A.M.</title>
<showtitle>24</showtitle>
<rating>8.500000</rating>
<votes>2233</votes>
<epbookmark>0</epbookmark>
<year>2001</year>
<top250>0</top250>
<season>1</season>
<episode>1</episode>
<displayseason>-1</displayseason>
<displayepisode>-1</displayepisode>
<outline></outline>
<plot>It is California Presidential Primary Day in Los Angeles and the longest day of Federal Agent Jack Bauer's life is about to begin. Jack has just patched his family back together after a trying separation. Midnight finds Jack playing chess with his teenage daughter Kim. As she goes to bed, Jack gets a call from Nina Myers, his coworker at the Los Angeles Counter Terrorist Unit, telling him to come in for an emergency meeting. Jack has no choice but to report in, but he and his wife Teri learn that Kim has snuck out before he leaves.

Kim and her friend Janet York drive to an empty furniture store where they party with a couple of college guys whom they recently met. Kim enjoys herself at first, but starts to become suspicious of the two men when they won't take her home.

At CTU, Jack learns that an assassination attempt is being planned against Senator David Palmer; the first African-American presidential candidate with a serious shot at the White House. Jack's boss and friend, Richard Walsh, warns him that people in their own agency may be working with those who plan to kill Palmer.

Senator David Palmer is making his plans for Primary Day when he receives a strange phone call that puts him in a bad mood.

Jack shows how far he's willing to go to do his job when he blackmails District Director George Mason in the hopes of learning information about the Palmer hit.

Teri receives a call from Janet's father, Alan York, and the two decide to go out looking for the girls.

A European photographer makes pleasant conversation with a beautiful woman on a plane bound for LA. The two end up in a lustful encounter, but more sinister plans come to light that involve a stolen wallet and the destruction of the airplane.
</plot>
<tagline></tagline>
<runtime>43</runtime>
<thumb>http://thetvdb.com/banners/episodes/76290/189255.jpg</thumb>
<mpaa>TV-14</mpaa>
<playcount>0</playcount>
<lastplayed></lastplayed>
<file></file>
<path>smb://VIDEO/tv/24/</path>
<filenameandpath>smb://VIDEO/tv/24/24.s01e01.mkv</filenameandpath>
<id>189255</id>
<uniqueid type="tvdb" default="true">189255</uniqueid>
<uniqueid type="imdb">tt0502165</uniqueid>
<premiered>2001-11-06</premiered>
<status></status>
<code></code>
<aired>2001-11-06</aired>
<studio>FOX (US)</studio>
<trailer></trailer>
<fileinfo>
<streamdetails>
        <audio>
                <channels>2</channels>
                <codec>none</codec>
                <language>eng</language>
                <longlanguage>English</longlanguage>
        </audio>
        <video>
                <aspect>1.778</aspect>
                <codec>none</codec>
                <durationinseconds>2560</durationinseconds>
                <height>472</height>
                <scantype>Progressive</scantype>
                <width>692</width>
        </video>
</streamdetails>
</fileinfo>
<actor>
        <name>Kiefer Sutherland</name>
        <role>Jack Bauer</role>
        <thumb>http://thetvdb.com/banners/actors/44914.jpg</thumb>
</actor>
<actor>
        <name>Mary Lynn Rajskub</name>
        <role>Chloe O'Brian</role>
        <thumb>http://thetvdb.com/banners/actors/360573.jpg</thumb>
</actor>
<actor>
        <name>Yvonne Strahovski</name>
        <role>Kate Morgan</role>
        <thumb>http://thetvdb.com/banners/actors/328133.jpg</thumb>
</actor>
<actor>
        <name>Carlos Bernard</name>
        <role>Tony Almeida</role>
        <thumb>http://thetvdb.com/banners/actors/78578.jpg</thumb>
</actor>
<actor>
        <name>Jude Ciccolella</name>
        <role>Mike Novick</role>
        <thumb>http://thetvdb.com/banners/actors/91331.jpg</thumb>
</actor>
<actor>
        <name>Glenn Morshower</name>
        <role>Aaron Pierce</role>
        <thumb>http://thetvdb.com/banners/actors/91321.jpg</thumb>
</actor>
<actor>
        <name>Tanya Wright</name>
        <role>Patty Brooks</role>
        <thumb>http://thetvdb.com/banners/actors/91311.jpg</thumb>
</actor>
<actor>
        <name>Alberta Watson</name>
        <role>Erin Driscoll</role>
        <thumb>http://thetvdb.com/banners/actors/91281.jpg</thumb>
</actor>
<actor>
        <name>Eric Balfour</name>
        <role>Milo Pressman</role>
        <thumb>http://thetvdb.com/banners/actors/82135.jpg</thumb>
</actor>
<actor>
        <name>Regina King</name>
        <role>Sandra Palmer</role>
        <thumb>http://thetvdb.com/banners/actors/82134.jpg</thumb>
</actor>
<actor>
        <name>Peter MacNicol</name>
        <role>Tom Lennox</role>
        <thumb>http://thetvdb.com/banners/actors/82133.jpg</thumb>
</actor>
<actor>
        <name>Marisol Nichols</name>
        <role>Nadia Yassir </role>
        <thumb>http://thetvdb.com/banners/actors/82132.jpg</thumb>
</actor>
<actor>
        <name>Jayne Atkinson</name>
        <role>Karen Hayes</role>
        <thumb>http://thetvdb.com/banners/actors/82131.jpg</thumb>
</actor>
<actor>
        <name>Carlo Rota</name>
        <role>Morris O'Brian</role>
        <thumb>http://thetvdb.com/banners/actors/82130.jpg</thumb>
</actor>
<actor>
        <name>Janeane Garofalo</name>
        <role>Janis Gold</role>
        <thumb>http://thetvdb.com/banners/actors/82129.jpg</thumb>
</actor>
<resume>
        <position>0.000000</position>
        <total>0.000000</total>
</resume>
</episodedetails>

Error trace / logs

plextraktsync sync --show 24
INFO     PlexTraktSync [0.19.1]                                                                                                                           
Sync Shows: [<Show:1000:24>]
Processing shows   0% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/1  [ 0:00:00 < -:--:-- , ? it/s ]
Traceback (most recent call last):
  File "/home/bleh/.local/bin/plextraktsync", line 8, in <module>
    sys.exit(cli())
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/cli.py", line 28, in wrap
    cmd(*args, **kwargs)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/commands/sync.py", line 60, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/sync.py", line 74, in sync
    for episode in walker.find_episodes():
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/walker.py", line 270, in find_episodes
    yield from self.episode_from_show(show)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/walker.py", line 309, in episode_from_show
    me = self.mf.resolve_any(pe, show)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/media.py", line 175, in resolve_any
    m = self.resolve_guid(guid, show)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/media.py", line 183, in resolve_guid
    logger.warning(f"{guid.pm.item}: Skipping {guid} because provider {guid.provider} has no external Id")
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 841, in __repr__
    '%s-%s' % (self.grandparentTitle.replace(' ', '-')[:20], self.seasonEpisode),
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/base.py", line 467, in __getattribute__
    value = super(PlexPartialObject, self).__getattribute__(attr)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 878, in seasonEpisode
    return 's%se%s' % (str(self.seasonNumber).zfill(2), str(self.episodeNumber).zfill(2))
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/base.py", line 467, in __getattribute__
    value = super(PlexPartialObject, self).__getattribute__(attr)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 872, in seasonNumber
    self._seasonNumber = self.parentIndex if self.parentIndex else self.season().seasonNumber
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 897, in season
    return self.fetchItem(self.parentKey)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/base.py", line 170, in fetchItem
    raise BadRequest('ekey was not provided')
plexapi.exceptions.BadRequest: ekey was not provided

Expected behavior

I expect it to properly sync S00E09.

Steps to reproduce the behavior

  1. Enable the XBMCnfoTVImporter.bundle agent for TV shows in Plex
  2. Create a folder for the show '24' with an episode for S00E09 and S01E01.
  3. Ensure there's a local NFO for each of those.
  4. Import into Plex using the XBMCnfoTVImporter agent.
  5. Scan the show in plextraktsync, and see the failure.
  6. Remove the S00E09 from the '24' folder.
  7. Rescan Plex.
  8. Scan the show in plextraktsync, and see it is successful.

Inspect of problematic items

plextraktsync inspect 10000
PlexTraktSync [0.19.1]

Traceback (most recent call last):
  File "/home/bleh/.local/bin/plextraktsync", line 8, in <module>
    sys.exit(cli())
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/cli.py", line 28, in wrap
    cmd(*args, **kwargs)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/commands/inspect.py", line 115, in inspect
    inspect_media(id)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/commands/inspect.py", line 37, in inspect_media
    print(f"Inspecting {id}: {pm}")
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/plex_api.py", line 379, in __repr__
    return f"<{guid.provider}:{guid.id}:{str(self.item).strip('<>')}>"
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 841, in __repr__
    '%s-%s' % (self.grandparentTitle.replace(' ', '-')[:20], self.seasonEpisode),
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/base.py", line 467, in __getattribute__
    value = super(PlexPartialObject, self).__getattribute__(attr)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 878, in seasonEpisode
    return 's%se%s' % (str(self.seasonNumber).zfill(2), str(self.episodeNumber).zfill(2))
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/base.py", line 467, in __getattribute__
    value = super(PlexPartialObject, self).__getattribute__(attr)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 872, in seasonNumber
    self._seasonNumber = self.parentIndex if self.parentIndex else self.season().seasonNumber
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/video.py", line 897, in season
    return self.fetchItem(self.parentKey)
  File "/home/bleh/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plexapi/base.py", line 170, in fetchItem
    raise BadRequest('ekey was not provided')
plexapi.exceptions.BadRequest: ekey was not provided

Workarounds

Remove the media, which isn't viable.

Install method

pipx (Recommended)

Version

0.19.1

Python Version

3.8.10

Operating System and Version

Ubuntu 20.04.4 LTS

glensc commented 2 years ago

I think it's bug in plex api:

see this comment:

almightiest commented 2 years ago

I believe the problem was actually unrelated to the agent itself, and instead was related to a stale Plex authentication in the .pytrakt.json file. The weird part is that the API still queried for some things, but not others. Once I initiated a plextraktsync login-plex and re-authenticated to the same Plex instance, this error just disappeared.

So, it's here in case anyone ever runs into the issue, but it's a serious corner case based on a prior Plex issue and having to re-install my Plex installation a while back.

glensc commented 2 years ago

Plex authentication is not in the .pytrakt.json file, but in .env, so which re-login did you do? plex-login or trakt-login?

almightiest commented 2 years ago

My bad, .env, Plex login.

simonc56 commented 2 years ago

Your solution :

Once I initiated a plextraktsync login-plex and re-authenticated to the same Plex instance, this error just disappeared.

From this issue https://github.com/Taxel/PlexTraktSync/issues/385#issuecomment-885876754 the solution was :

I renamed the .sqlite file and it has been rebuilt and I no longer experience this error.

It's a corner case and will be difficult to fix.

simonc56 commented 2 years ago

Maybe fixed by https://github.com/pkkid/python-plexapi/pull/950