PyTrakt icon indicating copy to clipboard operation
PyTrakt copied to clipboard

AttributeError: 'Movie' object has no attribute 'trakt'

Open Ashish0804 opened this issue 4 years ago • 3 comments

Looks like trakt was never initialized and thus error. https://github.com/moogar0880/PyTrakt/blob/033f2ed37590621868bba6253ed5435e61e69171/trakt/movies.py#L194

Changing it to trakt_id should fix things but I haven't tested it myself.

Here's the full error log

Traceback (most recent call last):
  File ".\add2traktlist.py", line 56, in <module>
    main()
  File ".\add2traktlist.py", line 51, in main
    traktList.add_items(trakt_object)
  File "C:\Users\Ashish\Anaconda3\lib\site-packages\trakt\core.py", line 586, in inner
    url, generator, args = self._get_first(f, *args, **kwargs)
  File "C:\Users\Ashish\Anaconda3\lib\site-packages\trakt\core.py", line 494, in _get_first
    uri = next(generator)
  File "C:\Users\Ashish\Anaconda3\lib\site-packages\trakt\users.py", line 160, in add_items
    movies = [m.ids for m in items if isinstance(m, Movie)]
  File "C:\Users\Ashish\Anaconda3\lib\site-packages\trakt\users.py", line 160, in <listcomp>
    movies = [m.ids for m in items if isinstance(m, Movie)]
  File "C:\Users\Ashish\Anaconda3\lib\site-packages\trakt\movies.py", line 194, in ids
    return {'ids': {'trakt': self.trakt, 'slug': self.slug,
AttributeError: 'Movie' object has no attribute 'trakt'

Here's how Movie object is being used in my code

Movie(title=res['Title'], imdb_id=res['imdbID'])

res is the response for OMDB api.

Ashish0804 avatar Oct 04 '21 15:10 Ashish0804

There are other errors on that line

This fixed them

        return {'ids': {'trakt': self.trakt_id, 'slug': self.slug,
                        'imdb': self.imdb_id, 'tmdb': self.tmdb_id}}

Ashish0804 avatar Oct 04 '21 15:10 Ashish0804

you are using constructor with data in an unexpected way:

Movie(title=res['Title'], imdb_id=res['imdbID'])

you need to pass ids as ids=dict rather than individual parameters:

Movie(title=res['Title'], ids= {'trakt': trakt_id, 'slug': self.slug,  'imdb': self.imdb_id, 'tmdb': self.tmdb_id})

this is later filled into *_id via extract_ids (in method _build).

glensc avatar Jan 15 '22 12:01 glensc

Adding .trakt in my fork:

  • https://github.com/glensc/python-pytrakt/pull/8

but due to different reasons.

glensc avatar Nov 29 '22 18:11 glensc