def tvshows(self, library, dialog): ''' Process tvshows and episodes from a single library. ''' processed_ids = [] for items in server.get_items(library['Id'], "Series", False, self.sync['RestorePoint'].get('params')): with self.video_database_locks() as (videodb, jellyfindb): obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, True) self.sync['RestorePoint'] = items['RestorePoint'] start_index = items['RestorePoint']['params']['StartIndex'] for index, show in enumerate(items['Items']): percent = int((float(start_index + index) / float(items['TotalRecordCount'])) * 100) message = show['Name'] dialog.update(percent, heading="%s: %s" % (translate('addon_name'), library['Name']), message=message) if obj.tvshow(show, library=library) is not False: for episodes in server.get_episode_by_show(show['Id']): for episode in episodes['Items']: dialog.update(percent, message="%s/%s" % (message, episode['Name'][:10])) obj.episode(episode) processed_ids.append(show['Id']) with self.video_database_locks() as (videodb, jellyfindb): obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, True) obj.item_ids = processed_ids if self.update_library: self.tvshows_compare(library, obj, jellyfindb)
def tvshows(self, library, dialog): ''' Process tvshows and episodes from a single library. ''' with self.library.database_lock: with Database() as videodb: with Database('emby') as embydb: obj = TVShows(self.server, embydb, videodb, self.direct_path, True) for items in server.get_items(library['Id'], "Series", False, self.sync['RestorePoint'].get('params')): self.sync['RestorePoint'] = items['RestorePoint'] start_index = items['RestorePoint']['params']['StartIndex'] for index, show in enumerate(items['Items']): percent = int((float(start_index + index) / float(items['TotalRecordCount']))*100) message = show['Name'] dialog.update(percent, heading="%s: %s" % (_('addon_name'), library['Name']), message=message) if obj.tvshow(show, library=library) != False: for episodes in server.get_episode_by_show(show['Id']): for episode in episodes['Items']: dialog.update(percent, message="%s/%s" % (message, episode['Name'][:10])) obj.episode(episode) if self.update_library: self.tvshows_compare(library, obj, embydb)