Herjar / radarr_sonarr_watchmon

GNU General Public License v3.0
45 stars 15 forks source link

trakt.py 3.0.0 API broken/no more available ? #19

Closed niawag closed 1 month ago

niawag commented 1 month ago

Hi, I'm using your project for quite some time and it's a great tool !

I'm facing a problem since this night, it's unable to connect to trakt server. I thought the problem was about auth and did a bit of debugging on my side but I now think that the problem lies in the trakt.py 3.0.0 library. Auth is not working because in "\trakt\interfaces\oauth\device.py":

class DeviceOAuthInterface(Interface):
    path = 'oauth/device'

    def code(self, **kwargs):
        client_id = self.client.configuration['client.id']

        if not client_id:
            raise ValueError('"client.id" configuration parameter is required')

        response = self.http.post(
            'code',
            data={
                'client_id': client_id
            }
        )

        data = self.get_data(response, **kwargs)
...

the http.post line returns no response. I printed the line and it returns a 404. Trakt.tv is not down so I guess it's a problem with the API. Here is the resulting error :

Traceback (most recent call last):
  File "radarr_sonarr_watchmon.py", line 532, in <module>
    app.initialize()
  File "adarr_sonarr_watchmon.py", line 85, in initialize
    self.authenticate()
  File "radarr_sonarr_watchmon.py", line 60, in authenticate
    code.get('user_code'),
    ^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
Herjar commented 1 month ago

I'm getting the same error here. I don't have time to look at it right now, but feel free to do a pull request if you find a solution.

niawag commented 1 month ago

Hi, I'll have a look and report what I found. If I manage to fix it I'll do a PR

niawag commented 1 month ago

Ok, that was an easy one ! I just had to change http to https to make it work as shown here: https://github.com/Herjar/radarr_sonarr_watchmon/pull/20 As I thought it might be a problem with trakt.py version, I downloaded the latest stable (4.4.0) and it seems to be working too (synced 1 movie and a few tv shows). I checked the breaking changes from v3.0.0 to v4.4.0 listed here:

BREAKING

  • Method signatures have been changed for:
    • Trakt['sync/history'] get(), movies(), shows()
    • Trakt['sync/ratings'] get(), movies(), shows(), seasons(), episodes()
    • Trakt['sync/watchlist'] get(), movies(), shows(), seasons(), episodes()
  • pagination=True now always returns a PaginationIterator with:
    • total_items - Total number of items
    • total_pages - Total number of pages
    • get(page) - Fetch the specified page
    • __iter__ - Iterate over all items, automatically requesting the next page as required
  • Trakt['search'].lookup() now always returns a list of matched items (previously a list was only returned when more than one item was returned)

It seems that only Trakt['sync/watchlist'] is used in your script and was used in my tests without issue. I've set recent_days to 1000 and it listed a lot of movies and tvshows without error. So I guess you could set trakt.py version to 4.4.0 in requirements.txt, unless there is a use case I didn't test.

Herjar commented 1 month ago

Thank you for fixing the problem. I also update the required trakt.py version now.