def process_medialist(self, medialist, alwaysnotify=False, stop_on_error=False): self.init_run(len(medialist) > 0) processed = {'tvshow': {}, 'movie': [], 'episode': []} artcount = 0 currentitem = 0 if medialist: gatherer = Gatherer(self.monitor, self.only_filesystem) for mediaitem in medialist: if not mediainfo.is_known_mediatype(mediaitem): continue log('Processing {0}'.format(mediaitem['label']), xbmc.LOGINFO) if self.visible: self.progress.update(currentitem * 100 // len(medialist), message=mediaitem['label']) currentitem += 1 self.add_additional_iteminfo(mediaitem) cleaned = mediaitem.get_artwork_updates(cleaner.clean_artwork(mediaitem), mediaitem['art']) if cleaned: add_art_to_library(mediaitem['mediatype'], mediaitem.get('seasons'), mediaitem['dbid'], cleaned) mediaitem['art'].update(cleaned) mediaitem['art'] = dict(item for item in mediaitem['art'].iteritems() if item[1]) forcedart, availableart, services_hit, error = gatherer.getartwork(mediaitem) if error: header = L(PROVIDER_ERROR_MESSAGE).format(error['providername']) xbmcgui.Dialog().notification(header, error['message'], xbmcgui.NOTIFICATION_WARNING) log('{0}\n{1}'.format(header, error['message'])) if stop_on_error: break else: add_processeditem(processed, mediaitem) for arttype, imagelist in availableart.iteritems(): self.sort_images(arttype, imagelist, mediaitem['file']) existingart = dict(mediaitem['art']) # Remove existing local artwork if it is no longer available localart = [(arttype, image['url']) for arttype, image in forcedart.iteritems() \ if not image['url'].startswith('http')] selectedart = dict((arttype, None) for arttype, url in existingart.iteritems() \ if not url.startswith('http') and (arttype, url) not in localart) selectedart.update((key, image['url']) for key, image in forcedart.iteritems()) selectedart = mediainfo.renumber_all_artwork(selectedart) existingart.update(selectedart) selectedart.update(self.get_top_missing_art(mediaitem['mediatype'], existingart, availableart, mediaitem.get('seasons'))) selectedart = mediainfo.get_artwork_updates(mediaitem['art'], selectedart) if selectedart: add_art_to_library(mediaitem['mediatype'], mediaitem.get('seasons'), mediaitem['dbid'], selectedart) artcount += len(selectedart) if not services_hit: if self.monitor.abortRequested(): break elif self.monitor.waitForAbort(THROTTLE_TIME): break self.finish_run() if alwaysnotify or artcount: notifycount(artcount) return processed
def update_art_for_items(items, start): changedcount = 0 for i, item in enumerate(items): progress.update(start + i * stepsize // len(items)) mediainfo.prepare_mediaitem(item) processed = function(item) processed = mediainfo.get_artwork_updates(item['art'], processed) if processed: mediainfo.update_art_in_library(item['mediatype'], item['dbid'], processed) changedcount += len(processed) if monitor.abortRequested(): break return changedcount
def process_item(self, mediatype, dbid, mode): if self.processor_busy: return if mode == MODE_GUI: xbmc.executebuiltin('ActivateWindow(busydialog)') if mediatype == mediatypes.TVSHOW: mediaitem = quickjson.get_tvshow_details(dbid, tvshow_properties) elif mediatype == mediatypes.MOVIE: mediaitem = quickjson.get_movie_details(dbid, movie_properties) elif mediatype == mediatypes.EPISODE: mediaitem = quickjson.get_episode_details(dbid, episode_properties) else: xbmc.executebuiltin('Dialog.Close(busydialog)') xbmcgui.Dialog().notification("Artwork Beef", L(NOT_SUPPORTED_MESSAGE).format(mediatype), '-', 6500) return if mode == MODE_GUI: self.init_run() self.add_additional_iteminfo(mediaitem) gatherer = Gatherer(self.monitor, self.only_filesystem) forcedart, availableart, _, error = gatherer.getartwork(mediaitem, False) if error: header = L(PROVIDER_ERROR_MESSAGE).format(error['providername']) xbmcgui.Dialog().notification(header, error['message'], xbmcgui.NOTIFICATION_WARNING) log('{0}\n{1}'.format(header, error['message'])) for arttype, imagelist in availableart.iteritems(): self.sort_images(arttype, imagelist, mediaitem['file']) xbmc.executebuiltin('Dialog.Close(busydialog)') if availableart: if 'seasons' in mediaitem and 'fanart' in availableart: for season in mediaitem['seasons'].keys(): unseasoned_backdrops = [dict(art) for art in availableart['fanart'] if not art.get('hasseason')] key = 'season.{0}.fanart'.format(season) if key in availableart: availableart[key].extend(unseasoned_backdrops) else: availableart[key] = unseasoned_backdrops tag_forcedandexisting_art(availableart, forcedart, mediaitem['art']) selectedarttype, selectedart = prompt_for_artwork(mediaitem['mediatype'], mediaitem['label'], availableart, self.monitor) if selectedarttype: if selectedarttype.startswith('season.'): gentype = selectedarttype.rsplit('.', 1)[1] multiselect = mediatypes.artinfo[mediatypes.SEASON].get(gentype, {}).get('multiselect', False) else: multiselect = mediatypes.artinfo[mediaitem['mediatype']][selectedarttype]['multiselect'] if multiselect: existingurls = [url for exacttype, url in mediaitem['art'].iteritems() \ if mediainfo.arttype_matches_base(exacttype, selectedarttype)] urls_toset = [url for url in existingurls if url not in selectedart[1]] urls_toset.extend([url for url in selectedart[0] if url not in urls_toset]) selectedart = dict(mediainfo.iter_renumbered_artlist(selectedart, selectedarttype, mediaitem['art'].keys())) else: selectedart = {selectedarttype: selectedart} selectedart = mediainfo.get_artwork_updates(mediaitem['art'], selectedart) if selectedart: add_art_to_library(mediaitem['mediatype'], mediaitem.get('seasons'), mediaitem['dbid'], selectedart) notifycount(len(selectedart)) else: xbmcgui.Dialog().notification(L(NOT_AVAILABLE_MESSAGE), L(SOMETHING_MISSING) + ' ' + L(FINAL_MESSAGE), '-', 8000) self.finish_run() else: medialist = [mediaitem] autoaddepisodes = addon.get_setting('autoaddepisodes_list') if addon.get_setting('episode.fanart') else () if mediatype == mediatypes.TVSHOW and mediaitem['imdbnumber'] in autoaddepisodes: medialist.extend(quickjson.get_episodes(dbid, properties=episode_properties)) self.process_medialist(medialist, True)