def process_recentvideos(self): ignoreepisodesfrom = set() addepisodesfrom = set() seriesadded = set() newitems = [] for mtype in ('movie', 'musicvideo', 'tvshow'): if mediatypes.disabled(mtype): continue for mediaid in self.recentvideos[mtype]: if mtype == 'tvshow': seriesadded.add(mediaid) jsonitem = quickjson.get_item_details(mediaid, mtype) if jsonitem.get('setid'): newitems.append(info.MediaItem(quickjson.get_item_details(jsonitem['setid'], mediatypes.MOVIESET))) newitems.append(info.MediaItem(jsonitem)) if self.abortRequested(): return for episodeid in self.recentvideos['episode']: episode = info.MediaItem(quickjson.get_item_details(episodeid, mediatypes.EPISODE)) series = None if not mediatypes.disabled(mediatypes.TVSHOW) and episode.tvshowid not in seriesadded \ and episode.season > self.processed.get_data(episode.tvshowid, mediatypes.TVSHOW, episode.label): seriesadded.add(episode.tvshowid) series = info.MediaItem(quickjson.get_item_details(episode.tvshowid, mediatypes.TVSHOW)) newitems.append(series) if not include_any_episode(): if self.abortRequested(): return continue if episode.tvshowid in addepisodesfrom: newitems.append(episode) elif episode.tvshowid in ignoreepisodesfrom: if include_episode(episode): episode.skip_artwork = ['fanart'] newitems.append(episode) else: if not series: series = info.MediaItem(quickjson.get_item_details(episode.tvshowid, mediatypes.TVSHOW)) if any(x for x in series.uniqueids.values() if x in settings.autoadd_episodes): addepisodesfrom.add(episode.tvshowid) newitems.append(episode) else: ignoreepisodesfrom.add(episode.tvshowid) if include_episode(episode): episode.skip_artwork = ['fanart'] newitems.append(episode) if self.abortRequested(): return self.reset_recent() self.processor.process_medialist(newitems)
def remove_art(): # TODO: seasons and episodes and whatever like "add missing artwork" does listitem = sys.listitem mediatype = get_mediatype(listitem) dbid = get_dbid(listitem) if not (dbid or mediatype): return if not xbmcgui.Dialog().yesno("Artwork Beef: " + L(32427), L(750)): return remove_localfiles = xbmcgui.Dialog().yesno("Artwork Beef", L(32062)) mediaitem = info.MediaItem(quickjson.get_item_details(dbid, mediatype)) mediaitem.selectedart = cleaner.remove_specific_arttype(mediaitem, '* all') if remove_localfiles: FileManager().remove_deselected_files(mediaitem, True) info.update_art_in_library(mediatype, dbid, mediaitem.selectedart) info.remove_local_from_texturecache(mediaitem.art.values(), True) xbmcgui.Dialog().notification("Artwork Beef", L(32027).format(len(mediaitem.selectedart)))
def add_movieset_movies(mediaitem): if not mediaitem.movies: mediaitem.movies = quickjson.get_item_details( mediaitem.dbid, mediatypes.MOVIESET)['movies'] for movie in mediaitem.movies: movie['art'] = get_own_artwork(movie)
def add_additional_iteminfo(mediaitem, processed, search=None): '''Get more data from the Kodi library, processed items, and look up web service IDs.''' if search and mediaitem.mediatype in search: search = search[mediaitem.mediatype] if mediaitem.mediatype == mediatypes.TVSHOW: # TODO: Split seasons out to separate items if not mediaitem.seasons: mediaitem.seasons, seasonart = _get_seasons_artwork( quickjson.get_seasons(mediaitem.dbid)) mediaitem.art.update(seasonart) if search and settings.default_tvidsource == 'tmdb' and 'tvdb' not in mediaitem.uniqueids: # TODO: Set to the Kodi library if found resultids = search.get_more_uniqueids(mediaitem.uniqueids, mediaitem.mediatype) if 'tvdb' in resultids: mediaitem.uniqueids['tvdb'] = resultids['tvdb'] elif mediaitem.mediatype == mediatypes.SEASON: tvshow = quickjson.get_item_details(mediaitem.tvshowid, mediatypes.TVSHOW) mediaitem.file = tvshow['file'] elif mediaitem.mediatype == mediatypes.EPISODE: if settings.default_tvidsource == 'tmdb': # TheMovieDB scraper sets episode IDs that can't be used in the API, but seriesID/season/episode works uniqueids = quickjson.get_item_details( mediaitem.tvshowid, mediatypes.TVSHOW)['uniqueid'] uniqueid = uniqueids.get('tmdb', uniqueids.get('unknown')) if uniqueid: mediaitem.uniqueids['tmdbse'] = '{0}/{1}/{2}'.format( uniqueid, mediaitem.season, mediaitem.episode) elif mediaitem.mediatype == mediatypes.MOVIESET: if not mediaitem.uniqueids.get('tmdb'): uniqueid = processed.get_data(mediaitem.dbid, mediaitem.mediatype, mediaitem.label) if search and not uniqueid and not mediatypes.only_filesystem( mediaitem.mediatype): searchresults = search.search(mediaitem.label, mediaitem.mediatype) if searchresults: for result in searchresults: if result['label'] == mediaitem.label: uniqueid = result['uniqueids']['tmdb'] break uniqueid = searchresults[0]['uniqueids']['tmdb'] if uniqueid: processed.set_data(mediaitem.dbid, mediatypes.MOVIESET, mediaitem.label, uniqueid) else: processed.set_data(mediaitem.dbid, mediatypes.MOVIESET, mediaitem.label, None) mediaitem.error = L(CANT_FIND_MOVIESET) log( "Could not find set '{0}' on TheMovieDB".format( mediaitem.label), xbmc.LOGNOTICE) mediaitem.uniqueids['tmdb'] = uniqueid if not processed.exists(mediaitem.dbid, mediaitem.mediatype, mediaitem.label): _remove_set_movieposters(mediaitem) if settings.setartwork_fromparent and not mediaitem.file: _identify_parent_movieset(mediaitem) elif mediaitem.mediatype == mediatypes.MUSICVIDEO: if not mediaitem.uniqueids.get('mbtrack') or not mediaitem.uniqueids.get('mbgroup') \ or not mediaitem.uniqueids.get('mbartist'): newdata = processed.get_data(mediaitem.dbid, mediaitem.mediatype, mediaitem.label) if newdata: mb_t, mb_al, mb_ar = newdata.split('/') mediaitem.uniqueids = { 'mbtrack': mb_t, 'mbgroup': mb_al, 'mbartist': mb_ar } elif search and not mediatypes.only_filesystem( mediaitem.mediatype): results = search.search(mediaitem.label, mediatypes.MUSICVIDEO) uq = results and results[0].get('uniqueids') if uq and uq.get('mbtrack') and uq.get('mbgroup') and uq.get( 'mbartist'): mediaitem.uniqueids = uq processed.set_data( mediaitem.dbid, mediatypes.MUSICVIDEO, mediaitem.label, uq['mbtrack'] + '/' + uq['mbgroup'] + '/' + uq['mbartist']) else: processed.set_data(mediaitem.dbid, mediatypes.MUSICVIDEO, mediaitem.label, None) mediaitem.error = L(CANT_FIND_MUSICVIDEO) log( "Could not find music video '{0}' on TheAudioDB". format(mediaitem.label), xbmc.LOGNOTICE) elif mediaitem.mediatype == mediatypes.ALBUM: folders = _identify_album_folders(mediaitem) if folders: mediaitem.file, mediaitem.discfolders = folders
def process_item(self, mediatype, dbid, mode): if self.processor_busy: return if mode == MODE_DEBUG: mode = MODE_AUTO self.set_debug(True) if mode == MODE_GUI: busy = pykodi.get_busydialog() busy.create() if mediatype in mediatypes.artinfo and (mediatype not in mediatypes.audiotypes or get_kodi_version() >= 18): mediaitem = info.MediaItem( quickjson.get_item_details(dbid, mediatype)) log("Processing {0} '{1}' {2}.".format( mediatype, mediaitem.label, 'automatically' if mode == MODE_AUTO else 'manually')) else: if mode == MODE_GUI: busy.close() xbmcgui.Dialog().notification( "Artwork Beef", L(NOT_SUPPORTED_MESSAGE).format(mediatype), '-', 6500) return self.init_run() if mediatype == mediatypes.EPISODE: series = quickjson.get_item_details(mediaitem.tvshowid, mediatypes.TVSHOW) if not any(uniqueid in settings.autoadd_episodes for uniqueid in series['uniqueid'].itervalues()): mediaitem.skip_artwork = ['fanart'] info.add_additional_iteminfo(mediaitem, self.processed, search) if not mediaitem.uniqueids and not mediatypes.only_filesystem( mediaitem.mediatype): if mediatype in mediatypes.require_manualid: self.manual_id(mediaitem) if mode == MODE_GUI: self._manual_item_process(mediaitem, busy) else: medialist = [mediaitem] if mediatype == mediatypes.TVSHOW and not mediatypes.disabled( mediatypes.EPISODE): gen_epthumb = mediatypes.generatethumb(mediatypes.EPISODE) download_ep = mediatypes.downloadanyartwork(mediatypes.EPISODE) if mediaitem.uniqueids and any( x in mediaitem.uniqueids.values() for x in settings.autoadd_episodes): medialist.extend( info.MediaItem(ep) for ep in quickjson.get_episodes(dbid)) elif gen_epthumb or download_ep: for episode in quickjson.get_episodes(dbid): if gen_epthumb and not info.has_generated_thumbnail(episode) \ or download_ep and info.has_art_todownload(episode['art'], mediatypes.EPISODE): episode = info.MediaItem(episode) episode.skip_artwork = ['fanart'] medialist.append(episode) elif mediatype == mediatypes.ARTIST and not mediatypes.disabled( mediatypes.ALBUM): medialist.extend( info.MediaItem(album) for album in quickjson.get_albums( mediaitem.label, mediaitem.dbid)) if mediatype in (mediatypes.ALBUM, mediatypes.ARTIST) and not mediatypes.disabled(mediatypes.ALBUM) \ and not mediatypes.disabled(mediatypes.SONG): medialist.extend( info.MediaItem(song) for song in quickjson.get_songs( mediaitem.mediatype, mediaitem.dbid)) self.process_medialist(medialist, True)