Mozzo1000 / movielst

:movie_camera: Everything about your movies within the command line.
Other
0 stars 1 forks source link

TMDb request crashes if movie not found #11

Closed Mozzo1000 closed 6 years ago

Mozzo1000 commented 6 years ago

Using TMDb API, if the movie could not be found, it crashes. If the movie could not be found in the TMDb databse, it returns 200 and empty fields, { "page": 1, "total_results": 0, "total_pages": 1, "results": [] }

It crashes because we try to assign tem["title"] with something that does not exists.

Traceback (most recent call last): File "/usr/local/bin/movielst", line 11, in <module> load_entry_point('movielst', 'console_scripts', 'movielst')() File "/Users/REDACTED/Documents/movielst/movielst/movielst.py", line 52, in main util(parser.parse_args()) File "/Users/REDACTED/Documents/movielst/movielst/movielst.py", line 70, in util scan_dir(args.PATH, dir_json) File "/Users/REDACTED/Documents/movielst/movielst/movielst.py", line 324, in scan_dir data = get_movie_info(name) File "/Users/REDACTED/Documents/movielst/movielst/movielst.py", line 345, in get_movie_info return get_api(movie_info['title'], None, external_api=get_setting('API', 'use_external_api')) File "/Users/REDACTED/Documents/movielst/movielst/API.py", line 38, in get_api item["title"] = tmdb["results"][0]['title'] IndexError: list index out of range