itsToggle / plex_debrid

Plex torrent streaming through Debrid Services
1.49k stars 127 forks source link

Adding a particular show request via Overseerr crashes the script #281

Closed codevski closed 1 year ago

codevski commented 1 year ago

Awesome work dude with this script. Just ran into a issue after adding a particular show: ekin-su.and.davide.homecomings 2022

So I've been digging around on trying to find out what is causing the script to crash and I noticed after adding a particular show via overseerr I get this crash:

[07/12/22 09:53:00] [overseerr] found new overseerr request by user "codevski".
[07/12/22 09:53:00] [plex] getting entire plex library ... done
[07/12/22 09:53:03] matching item: 'tmdb://215392' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:53:04] matching item: 'tmdb://593643' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:53:04] matching item: 'tmdb://830788' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:53:05] matching item: 'tmdb://823766' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:53:06] matching item: 'tmdb://619730' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:53:06] matching item: 'tmdb://153312' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:53:07] checking new content ... done
[07/12/22 09:53:07] matching item: 'ekin-su.and.davide.homecomings' of service 'content.services.overseerr' to service 'content.services.trakt'
Exception in thread Thread-1 (threaded):
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/ui/__init__.py", line 390, in threaded
    element.download(library=library)
  File "/content/classes.py", line 769, in download
    self.aliases('en')
  File "/content/classes.py", line 356, in aliases
    aliases = sys.modules['content.services.trakt'].aliases(self,lan)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/services/trakt.py", line 1077, in aliases
    response, header = get('https://api.trakt.tv/'+type+'/' + str(self.ids.trakt) + '/aliases')
                                                                  ^^^^^^^^
AttributeError: 'show' object has no attribute 'ids'. Did you mean: 'id'?

as soon as I remove the request I get this:

Type 'exit' to return to the main menu.
[07/12/22 09:53:58] [plex] getting entire plex library ... done
[07/12/22 09:54:04] [plex] getting all watchlists ... done
[07/12/22 09:54:11] [overseerr] getting all overseerr requests ... done
[07/12/22 09:54:11] matching item: 'tmdb://593643' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:54:12] matching item: 'tmdb://830788' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:54:13] matching item: 'tmdb://823766' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:54:14] matching item: 'tmdb://619730' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:54:14] matching item: 'tmdb://153312' of service 'content.services.overseerr' to service 'content.services.plex'
[07/12/22 09:54:16] checking new content ... done
[07/12/22 09:54:16] media error: (attr exception): 'season' object has no attribute 'originallyAvailableAt'

Also not sure what the media error season object is complaining about.

Steps to replicate:

Search show in Overseerr: Ekin-Su & Davide: Homecomings Select request Popup box will have We were unable to automatically match this series. Please select the correct match below. Select the correct show which is the first one image follow basic prompts and script will crash after it detects the request

itsToggle commented 1 year ago

Alright! thats some good investigating. It seems that this show can not be found on trakt or doesnt have any IDS associated with it on trakt. This could be because its missing an IMDB ID on overseerr. I will catch the error, so that the script doesnt crash anymore if this happens. This will not fix the underlying issue that this show cant be found though. Ill investigate, thanks for the detailed description! :)

itsToggle commented 1 year ago

the "media error: (attr exception): 'season' object has no attribute 'originallyAvailableAt'" simply means that this particular season does not have a release date set yet (because its announced, but not no date has been set yet). This error is handled by ignoring this particular season, so there is nothing to worry about on your end.

itsToggle commented 1 year ago

alright Ive caught the error. I didnt realize it accured whilst getting aliases - perhaps the rest of the workflow is unaffected by a missing trakt ID. Ill push the update soon, this issue will automatically close if that happens. Feel free to reopen it if the issue persists after this.

I-am-PUID-0 commented 1 year ago

@itsToggle I appear to be having a similar issue with version 2.53

The below error is consistently occurring with the same item on each run.

[11/12/22 16:39:16] matching item: 'santa.clause.is.comin.to.town.2022' of service 'content.services.overseerr' to service 'content.services.trakt'

Exception in thread Thread-1 (threaded):

Traceback (most recent call last):

File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner

self.run()

File "/usr/local/lib/python3.11/threading.py", line 975, in run

self._target(*self._args, **self._kwargs)

File "/ui/init.py", line 372, in threaded

element.download(library=library)

File "/content/classes.py", line 727, in download

self.Releases += scraper.scrape(self.query(title).replace(str(self.year), str(year)),self.deviation())

^^^^^^^^^^^^^^^^

File "/content/classes.py", line 407, in deviation

return '[^A-Za-z0-9]*(' + title + ':?.)(?[?(' + str(self.year) + '|' + str(self.year - 1) + '|' + str(self.year + 1) + ')'



TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
itsToggle commented 1 year ago

@I-am-PUID-0 in your case it seems that the movie has no release year data on trakt. I've caught this same error somewhere else before, but it seems that it carries through. I'll check it out.

I-am-PUID-0 commented 1 year ago

@I-am-PUID-0 in your case it seems that the movie has no release year data on trakt. I've caught this same error somewhere else before, but it seems that it carries through. I'll check it out.

Yeah. I think it's a bad TMDB listing linked to Overseerr and Trakt: https://www.themoviedb.org/movie/959608-santa-clause-is-comin-to-town?language=en

Though, it's odd that plex_debrid exited due to the bad reference.

itsToggle commented 1 year ago

alright so currently the trakt api is down and keeps returning a 503 error. This leads to the following (debug enabled) output on my end: image which doesnt crash the script like it did in your case.

Im sure they will fix the api shortly so I can try to reproduce your error.

itsToggle commented 1 year ago

whats also curious is that Im actually already catching the case that there is no release year data: image line 712 has the release year check, your script crashed on line 727 where the allowed title deviation is defined. If the year were missing, the script should never actually reach line 727.

codevski commented 1 year ago

Yeah been running into issues removing tv show and re-adding not adding all the shows have a feeling related to this trakt API being down so going to just wait and do some digging around once they get there DB and API back up. Quick question you have a discord server?

itsToggle commented 1 year ago

Yeah Id definitly recommend joining it aswell, heres the invite: https://discord.com/invite/UKkPeRdukx :)

I-am-PUID-0 commented 1 year ago

Exited again, new content, same lines -- except File "/ui/init.py", line 372, in threaded is now File "/ui/__init__.py", line 387, in threaded

`[20/12/22 16:24:41] matching item: 'comedy.central.roast.of.hans.klok.2021' of service 'content.services.overseerr' to service 'content.services.trakt' Exception in thread Thread-1 (threaded): Traceback (most recent call last): File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/usr/local/lib/python3.11/threading.py", line 975, in run self._target(*self._args, *self._kwargs) File "/ui/init.py", line 387, in threaded element.download(library=library) File "/content/classes.py", line 727, in download self.Releases += scraper.scrape(self.query(title).replace(str(self.year), str(year)),self.deviation()) ^^^^^^^^^^^^^^^^ File "/content/classes.py", line 407, in deviation return '[^A-Za-z0-9](' + title + ':?.)(?[?(' + str(self.year) + '|' + str(self.year - 1) + '|' + str(self.year + 1) + ')'


TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'`

Though, it looks like Trakt's API is back up, as I also have the following line:

`[20/12/22 16:24:41] [trakt] error: (401 unauthorized): trakt api key for user 'redacted' does not seem to work. Consider re-authorizing plex_debrid for this trakt user.`

I'll reauthorize the Trakt API key and see if the error occurs again. 
I-am-PUID-0 commented 1 year ago

With Trakt API up, it still throws the error for the above content. It looks as though Trakt/TMDB is missing data for the content.

itsToggle commented 1 year ago

Oh I see what might be happening - it seems that the media item does have release year information (according to the query for that movie, first line of the error message), but that information is overwritten while matching from "overseerr" to "trakt". With Trakt being back up, I'll check this out again!

itsToggle commented 1 year ago

Yeah as I suspected; the overseerr request is first matched to plex, which does return a release year, and then to trakt, which doesnt. The trakt information is considered more accurate and therefore overwrites the plex information, which then leads to the missing year. Should be fixed in v2.54 which Im working on now.

I-am-PUID-0 commented 1 year ago

Yeah as I suspected; the overseerr request is first matched to plex, which does return a release year, and then to trakt, which doesnt. The trakt information is considered more accurate and therefore overwrites the plex information, which then leads to the missing year. Should be fixed in v2.54 which Im working on now.

Awesome! Thanks! :)

itsToggle commented 1 year ago

I'll assume this is fixed for now. I'm not sure what happens for tv shows that are incorrectly/partially matched yet, as I couldn't find an example, but for movies the fix seems to work.