def metadata_update(): ''' Updates metadata for library If movie's theatrical release is more than a year ago it is ignored. Checks movies with a missing 'media_release_date' field. By the time this field is filled all other fields should be populated. ''' logging.info('Updating library metadata.') movies = core.sql.get_user_movies() cutoff = datetime.datetime.today() - datetime.timedelta(days=365) u = [] for i in movies: if i['release_date'] and datetime.datetime.strptime(i['release_date'], '%Y-%m-%d') < cutoff: continue if not i['media_release_date'] and i['status'] not in ('Finished', 'Disabled'): u.append(i) if not u: return logging.info('Updating metadata for: {}.'.format(', '.join([i['title'] for i in u]))) for i in u: Metadata.update(i.get('imdbid'), tmdbid=i.get('tmdbid'), force_poster=False) return
def update_metadata(self, params): ''' Re-downloads metadata for imdbid params(dict): params passed in request url, must include imdbid, may include tmdbid If tmdbid is None, looks in database for tmdbid using imdbid. If that fails, looks on tmdb api for imdbid If that fails returns error message Returns dict ajax-style response ''' if not params.get('imdbid'): return {'response': False, 'error': 'no imdbid supplied'} r = Metadata.update(params['imdbid'], params.get('tmdbid')) if r['response'] is True: return {'response': True, 'message': 'Metadata updated'} else: return r