Exceptions when IMDB lacks plot summary, cast, cover url
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Entertainer Media Center |
New
|
Undecided
|
Unassigned |
Bug Description
The following is several very similar bugs in the video meta data scanner,
entertainerlib/
Basically it doesn't cope well with missing data, showing as exceptions at the terminal, and the failure to add these videos to the library.
You can test this with the free short animated film "Big Buck Bunny", see www.bigbuckbunn
As you can see, (currently) the IMDB don't have a plot summary for this:
http://
I have attached a patch for the changes described below.
=======
I saw the following exception in the terminal output running entertainer 0.5.1 on Ubuntu Lucid,
2010-09-08 16:38:36,547 DEBUG [imdbpy.
2010-09-08 16:38:37+0100 [-] Exception in thread Video metadata search thread:
2010-09-08 16:38:37+0100 [-] Traceback (most recent call last):
2010-09-08 16:38:37+0100 [-] File "/usr/lib/
2010-09-08 16:38:37+0100 [-] self.run()
2010-09-08 16:38:37+0100 [-] File "/home/
2010-09-08 16:38:37+0100 [-] plot_string = movie['plot'][0]
2010-09-08 16:38:37+0100 [-] File "/usr/lib/
2010-09-08 16:38:37+0100 [-] rawData = self.data[key]
2010-09-08 16:38:37+0100 [-] KeyError: 'plot'
2010-09-08 16:38:37+0100 [-]
I would replace these line in /entertainerlib
plot = plot_string[
with:
try:
except KeyError:
i.e. Use the dictionary get method's default value feature to avoid the KeyError.
=======
Once the above is fixed, you see new errors about actors, writers and directors:
2010-09-08 16:47:36,510 DEBUG [imdbpy.
Exception in thread Video metadata search thread:
Traceback (most recent call last):
File "/usr/lib/
self.run()
File "/home/
p = self._get_
File "/home/
a1 = movie['
File "/usr/lib/
rawData = self.data[key]
KeyError: 'cast'
This requires more substantial changes in _get_persons which currently makes a lot of big assumptions!
I suggest replacing the current method:
def _get_persons(self, movie):
"""
Get a list of persons. First five names are actors, then comes two
directors and two writers.
@param movie: Movie name
@return: List of strings containing actors, directors and writers
"""
a1 = movie['
a2 = movie['
a3 = movie['
a4 = movie['
a5 = movie['
w1 = movie['
w2 = movie['
d1 = movie['
d2 = movie['
return [a1, a2, a3, a4, a5, w1, w2, d1, d2]
with:
def _get_role(self, movie, role, count=None, default=''):
"""
Get a list of actors (expect up to five), writers (expect up to two)
or directors (expect up to two)
@param movie: Movie name
@param role: string actors, writer, or director
@param count: optional integer, force return of this many strings
@param default: value to pad return list with if using count
@return: List of strings containing people in that role
"""
actors = movie.get(role, [])
names = [a['name'] for a in actors]
if count:
names += [default] * (count - len(names))
return names
def _get_persons(self, movie):
"""
Get a list of persons. First five names are actors, then comes two
directors and two writers.
@param movie: Movie name
@return: List of strings containing actors, directors and writers
"""
a1, a2, a3, a4, a5 = self._get_
w1, w2 = self._get_
d1, d2 = self._get_
return [a1, a2, a3, a4, a5, w1, w2, d1, d2]
=======
Once those are fixed, you get a similar error for missing cover URLs,
2010-09-08 17:04:05,546 DEBUG [imdbpy.
c2010-09-08 17:04:06+0100 [-] Exception in thread Video metadata search thread:
2010-09-08 17:04:06+0100 [-] Traceback (most recent call last):
2010-09-08 17:04:06+0100 [-] File "/usr/lib/
2010-09-08 17:04:06+0100 [-] self.run()
2010-09-08 17:04:06+0100 [-] File "/home/
2010-09-08 17:04:06+0100 [-] self._download_
2010-09-08 17:04:06+0100 [-] File "/usr/lib/
2010-09-08 17:04:06+0100 [-] rawData = self.data[key]
2010-09-08 17:04:06+0100 [-] KeyError: 'cover url'
2010-09-08 17:04:06+0100 [-]
I would replace these calls (two cases) in the run method:
self.
with:
if 'cover url' in movie:
and:
self.
with:
if 'cover url' in series: