Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoneType is not iterable #29

Open
ghost opened this issue Sep 12, 2013 · 5 comments
Open

NoneType is not iterable #29

ghost opened this issue Sep 12, 2013 · 5 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Sep 12, 2013

Hi,

I am using PyTMDB3 and for the most part successfully, although I have 1 problem. I have the following code:

import os

from tmdb3 import searchMovie
from tmdb3 import set_key

set_key('<APIKEY>')

for path, subdirs, files in os.walk(r'/media/Movies'):
    files = [ file for file in files if not file.endswith( ('.nfo','.tbn','.jpg','.xml','.srt') ) ]
    for filename in files:
        fname = str(os.path.splitext(filename)[0])
        res = searchMovie(fname)
    print (res[0])

It goes through my movies and prints out the movie name found on tmdb. It works although there are 5 movies in which it doesnt work and I get an error and I cant figure out why.

The movies are Madagascar, Robin Hood, The Grey, The Watch and Zombieland. I can see that they are all on tmdb so am not sure why it isnt finding them.

The error is:
Traceback (most recent call last):
File "scan.py", line 14, in
res = searchMovie(fname)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/tmdb_api.py", line 121, in searchMovie
return MovieSearchResult(Request('search/movie', **kwargs), locale=locale)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/tmdb_api.py", line 148, in init lambda x: Movie(raw=x, locale=locale))
File "/usr/local/lib/python2.7/dist-packages/tmdb3/pager.py", line 101, in init super(PagedRequest, self).init(self._getpage(1), 20)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/pager.py", line 56, in __init__self._data = list(iterable)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/pager.py", line 108, in _ge tpageyield self._handler(item)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/tmdb_api.py", line 148, in lambda x: Movie(raw=x, locale=locale))
File "/usr/local/lib/python2.7/dist-packages/tmdb3/util.py", line 350, in __call__obj._populate.apply(kwargs['raw'], False)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/util.py", line 83, in apply if (k in
TypeError: argument of type 'NoneType' is not iterable

Thanks for any help.

Jay

@wagnerrp
Copy link
Owner

For some reason, the API is returning "null"s in the list of results. I'll have to pass this upstream to see what's going on.

@ghost ghost assigned wagnerrp Sep 13, 2013
@wagnerrp
Copy link
Owner

It seems these are movies that have been deleted, but haven't been completely flushed out of the API servers. They should be getting server side, but currently aren't.

http://www.themoviedb.org/talk/522e418d760ee3380c10d5a2

wagnerrp added a commit that referenced this issue Sep 13, 2013
This temporarily resolves an issue where the TheMovieDb server returns
nulls in searches when a movie has been deleted but not yet flushed out
of the cache. This prevents the error internally, but does not attempt
to re-order to remove the nulls, so is merely passing the issue onto the
application using this library.

Refs #29
@ghost
Copy link
Author

ghost commented Sep 13, 2013

I have updated the changes, same issue

@wagnerrp
Copy link
Owner

It resolves the issue locally, but as the commit message mentioned, it's not a proper fix. It just passes the null entries on to you to deal with.

@ghost
Copy link
Author

ghost commented Sep 13, 2013

Sorry I didn't notice that, I have added some checking code and its all working fine again. Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
@wagnerrp and others