121,122c121,126 < plot_string = movie['plot'][0] < plot = plot_string[plot_string.rfind("::")+2:].lstrip() --- > #Don't always get a plot summary, default to empty string > try: > plot_string = movie['plot'][0] > plot = plot_string[plot_string.rfind("::")+2:].lstrip() > except KeyError: > plot = '' 139c143,144 < self._download_cover_art(movie['cover url'], title) --- > if 'cover url' in movie: > self._download_cover_art(movie['cover url'], title) 155,157c160,167 < time = series['runtime'] < runtime = time[0][:time[0].find(":")] < int(runtime) # This raises exception if runtime is not integer --- > try: > time = series['runtime'] > runtime = time[0][:time[0].find(":")] > int(runtime) # This raises a ValueError if runtime is not integer > except KeyError, ValueError: > #What is a good default? > #TODO - look at the video file itself for this information > runtime = '' 160c170 < plot = series['episodes'][self.season][self.episode]['plot'] --- > plot = series['episodes'][self.season][self.episode].get('plot', '') 167c177,178 < self._download_cover_art(series['cover url'], series_title) --- > if 'cover url' in series: > self._download_cover_art(series['cover url'], series_title) 205a217,235 > 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 >0: > names = names[:count] > while len(names) < count: > names.append(default) > assert len(names)==count > return names > 213,222c243,245 < a1 = movie['actors'][0]['name'] < a2 = movie['actors'][1]['name'] < a3 = movie['actors'][2]['name'] < a4 = movie['actors'][3]['name'] < a5 = movie['actors'][4]['name'] < w1 = movie['writer'][0]['name'] < w2 = movie['writer'][1]['name'] < d1 = movie['director'][0]['name'] < d2 = movie['director'][1]['name'] < --- > a1, a2, a3, a4, a5 = self._get_role(movie, 'actors', count=5) > w1, w2 = self._get_role(movie, 'writer', count=2) > d1, d2 = self._get_role(movie, 'director', count=2)