def manual_set_music_artwork(self, details, mediatype): """manual override artwork options""" from .utils import manual_set_artwork if mediatype == "artist" and "artist" in details: header = "%s: %s" % (xbmc.getLocalizedString(13511), details["artist"]) else: header = "%s: %s" % (xbmc.getLocalizedString(13511), xbmc.getLocalizedString(558)) changemade, artwork = manual_set_artwork(details["art"], mediatype, header) # save results if any changes made if changemade: details["art"] = artwork refresh_needed = False download_art = self._mutils.addon.getSetting( "music_art_download") == "true" download_art_custom = self._mutils.addon.getSetting( "music_art_download_custom") == "true" # download artwork to music folder if needed if details.get("diskpath") and download_art: details["art"] = download_artwork(details["diskpath"], details["art"]) refresh_needed = True # download artwork to custom folder if needed if details.get("customartpath") and download_art_custom: details["art"] = download_artwork(details["customartpath"], details["art"]) refresh_needed = True # reload skin to make sure new artwork is visible if refresh_needed: xbmc.sleep(500) xbmc.executebuiltin("ReloadSkin()") # return endresult return details
def manual_set_music_artwork(self, details, mediatype): '''manual override artwork options''' from utils import manual_set_artwork if mediatype == "artist" and "artist" in details: header = "%s: %s" % (xbmc.getLocalizedString(13511), details["artist"]) else: header = "%s: %s" % (xbmc.getLocalizedString(13511), xbmc.getLocalizedString(558)) changemade, artwork = manual_set_artwork(details["art"], mediatype, header) # save results if any changes made if changemade: details["art"] = artwork refresh_needed = False download_art = self.metadatautils.addon.getSetting("music_art_download") == "true" download_art_custom = self.metadatautils.addon.getSetting("music_art_download_custom") == "true" # download artwork to music folder if needed if details.get("diskpath") and download_art: details["art"] = download_artwork(details["diskpath"], details["art"]) refresh_needed = True # download artwork to custom folder if needed if details.get("customartpath") and download_art_custom: details["art"] = download_artwork(details["customartpath"], details["art"]) refresh_needed = True # reload skin to make sure new artwork is visible if refresh_needed: xbmc.sleep(500) xbmc.executebuiltin("ReloadSkin()") # return endresult return details
def get_album_metadata(self, artist, album, track, disc, ignore_cache=False, flush_cache=False, manual=False): """collect all album metadata""" cache_str = "music_artwork.album.%s.%s.%s" % ( artist.lower(), album.lower(), disc.lower()) if not album: cache_str = "music_artwork.album.%s.%s" % (artist.lower(), track.lower()) details = {"art": {}, "cachestr": cache_str} # retrieve details from cache cache = self._mutils.cache.get(cache_str) if not cache and flush_cache: # nothing to do - just return empty results return details elif cache and flush_cache: # only update kodi metadata for updated counts etc details = extend_dict( self.get_album_kodi_metadata(artist, album, track, disc), cache) elif cache and not ignore_cache: # we have a valid cache - return that details = cache elif cache and manual: # user wants to manually override the artwork in the cache details = self.manual_set_music_artwork(cache, "album") else: # nothing in cache - start metadata retrieval local_path = "" local_path_custom = "" # get metadata from kodi db details = extend_dict( details, self.get_album_kodi_metadata(artist, album, track, disc)) if not album and details.get("title"): album = details["title"] # get artwork from songlevel path if details.get("diskpath") and self._mutils.addon.getSetting( "music_art_musicfolders") == "true": details["art"] = extend_dict( details["art"], self.lookup_albumart_in_folder(details["diskpath"])) local_path = details["diskpath"] # get artwork from custom folder if self._mutils.addon.getSetting("music_art_custom") == "true": if sys.version_info.major == 3: custom_path = self._mutils.addon.getSetting( "music_art_custom_path") else: custom_path = self._mutils.addon.getSetting( "music_art_custom_path").decode("utf-8") local_path_custom = self.get_custom_album_path( custom_path, artist, album, disc) details["art"] = extend_dict( details["art"], self.lookup_albumart_in_folder(local_path_custom)) details["customartpath"] = local_path_custom # lookup online metadata if self._mutils.addon.getSetting("music_art_scraper") == "true": # prefer the musicbrainzid that is already in the kodi database - only perform lookup if missing mb_albumid = details.get("musicbrainzalbumid") if not mb_albumid: mb_albumid = self.get_mb_album_id(artist, album, track) if mb_albumid: # get artwork from fanarttv if self._mutils.addon.getSetting( "music_art_scraper_fatv") == "true": details["art"] = extend_dict( details["art"], self._mutils.fanarttv.album(mb_albumid)) # get metadata from theaudiodb if self._mutils.addon.getSetting( "music_art_scraper_adb") == "true": details = extend_dict( details, self.audiodb.album_info(mb_albumid)) # get metadata from lastfm if self._mutils.addon.getSetting( "music_art_scraper_lfm") == "true": details = extend_dict( details, self.lastfm.album_info(mb_albumid)) # metadata from musicbrainz if not details.get("year") or not details.get("genre"): details = extend_dict( details, self.mbrainz.get_albuminfo(mb_albumid)) # musicbrainz thumb as last resort if not details["art"].get("thumb"): details["art"]["thumb"] = self.mbrainz.get_albumthumb( mb_albumid) # download artwork to music folder if local_path and self._mutils.addon.getSetting( "music_art_download") == "true": details["art"] = download_artwork( local_path, details["art"]) # download artwork to custom folder if local_path_custom and self._mutils.addon.getSetting( "music_art_download_custom") == "true": details["art"] = download_artwork( local_path_custom, details["art"]) # set default details if not details.get("album") and details.get("title"): details["album"] = details["title"] if details["art"].get("thumb"): details["art"]["albumthumb"] = details["art"]["thumb"] # store results in cache and return results self._mutils.cache.set(cache_str, details) return details
def get_artist_metadata(self, artist, album, track, ignore_cache=False, flush_cache=False, manual=False): """collect artist metadata for given artist""" details = {"art": {}} cache_str = "music_artwork.artist.%s" % artist.lower() # retrieve details from cache cache = self._mutils.cache.get(cache_str) if not cache and flush_cache: # nothing to do - just return empty results return details elif cache and flush_cache: # only update kodi metadata for updated counts etc details = extend_dict(self.get_artist_kodi_metadata(artist), cache) elif cache and not ignore_cache: # we have a valid cache - return that details = cache elif cache and manual: # user wants to manually override the artwork in the cache details = self.manual_set_music_artwork(cache, "artist") else: # nothing in cache - start metadata retrieval log_msg( "get_artist_metadata --> artist: %s - album: %s - track: %s" % (artist, album, track)) details["cachestr"] = cache_str local_path = "" local_path_custom = "" # get metadata from kodi db details = extend_dict(details, self.get_artist_kodi_metadata(artist)) # get artwork from songlevel path if details.get("diskpath") and self._mutils.addon.getSetting( "music_art_musicfolders") == "true": details["art"] = extend_dict( details["art"], self.lookup_artistart_in_folder(details["diskpath"])) local_path = details["diskpath"] # get artwork from custom folder if self._mutils.addon.getSetting("music_art_custom") == "true": if sys.version_info.major == 3: custom_path = self._mutils.addon.getSetting( "music_art_custom_path") else: custom_path = self._mutils.addon.getSetting( "music_art_custom_path").decode("utf-8") local_path_custom = self.get_customfolder_path( custom_path, artist) log_msg("custom path on disk for artist: %s --> %s" % (artist, local_path_custom)) details["art"] = extend_dict( details["art"], self.lookup_artistart_in_folder(local_path_custom)) details["customartpath"] = local_path_custom # lookup online metadata if self._mutils.addon.getSetting("music_art_scraper") == "true": if not album and not track: album = details.get("ref_album") track = details.get("ref_track") # prefer the musicbrainzid that is already in the kodi database - only perform lookup if missing mb_artistid = details.get( "musicbrainzartistid", self.get_mb_artist_id(artist, album, track)) details["musicbrainzartistid"] = mb_artistid if mb_artistid: # get artwork from fanarttv if self._mutils.addon.getSetting( "music_art_scraper_fatv") == "true": details["art"] = extend_dict( details["art"], self._mutils.fanarttv.artist(mb_artistid)) # get metadata from theaudiodb if self._mutils.addon.getSetting( "music_art_scraper_adb") == "true": details = extend_dict( details, self.audiodb.artist_info(mb_artistid)) # get metadata from lastfm if self._mutils.addon.getSetting( "music_art_scraper_lfm") == "true": details = extend_dict( details, self.lastfm.artist_info(mb_artistid)) # download artwork to music folder if local_path and self._mutils.addon.getSetting( "music_art_download") == "true": details["art"] = download_artwork( local_path, details["art"]) # download artwork to custom folder if local_path_custom and self._mutils.addon.getSetting( "music_art_download_custom") == "true": details["art"] = download_artwork( local_path_custom, details["art"]) # fix extrafanart if details["art"].get("fanarts"): for count, item in enumerate( details["art"]["fanarts"]): details["art"]["fanart.%s" % count] = item if not details["art"].get("extrafanart") and len( details["art"]["fanarts"]) > 1: details["art"]["extrafanart"] = "plugin://script.skin.helper.service/"\ "?action=extrafanart&fanarts=%s" % quote_plus(repr(details["art"]["fanarts"])) # multi-image path for all images for each arttype for arttype in ["banners", "clearlogos", "thumbs"]: art = details["art"].get(arttype, []) if len(art) > 1: # use the extrafanart plugin entry to display multi images details["art"][arttype] = "plugin://script.skin.helper.service/"\ "?action=extrafanart&fanarts=%s" % quote_plus(repr(art)) # set default details if not details.get("artist"): details["artist"] = artist if details["art"].get("thumb"): details["art"]["artistthumb"] = details["art"]["thumb"] # always store results in cache and return results self._mutils.cache.set(cache_str, details) return details
def get_album_metadata(self, artist, album, track, disc, ignore_cache=False, flush_cache=False, manual=False): '''collect all album metadata''' cache_str = "music_artwork.album.%s.%s.%s" % (artist.lower(), album.lower(), disc.lower()) if not album: cache_str = "music_artwork.album.%s.%s" % (artist.lower(), track.lower()) details = {"art": {}} details["cachestr"] = cache_str # retrieve details from cache cache = self.metadatautils.cache.get(cache_str) if not cache and flush_cache: # nothing to do - just return empty results return details elif cache and flush_cache: # only update kodi metadata for updated counts etc details = extend_dict(self.get_album_kodi_metadata(artist, album, track, disc), cache) elif cache and not ignore_cache: # we have a valid cache - return that details = cache elif cache and manual: # user wants to manually override the artwork in the cache details = self.manual_set_music_artwork(cache, "album") else: # nothing in cache - start metadata retrieval local_path = "" local_path_custom = "" # get metadata from kodi db details = extend_dict(details, self.get_album_kodi_metadata(artist, album, track, disc)) # get artwork from songlevel path if details.get("diskpath") and self.metadatautils.addon.getSetting("music_art_musicfolders") == "true": details["art"] = extend_dict(details["art"], self.lookup_albumart_in_folder(details["diskpath"])) local_path = details["diskpath"] # get artwork from custom folder if self.metadatautils.addon.getSetting("music_art_custom") == "true": custom_path = self.metadatautils.addon.getSetting("music_art_custom_path").decode("utf-8") if custom_path: diskpath = self.get_custom_album_path(custom_path, artist, album, disc) if diskpath: details["art"] = extend_dict(details["art"], self.lookup_albumart_in_folder(diskpath)) local_path_custom = diskpath details["customartpath"] = diskpath # lookup online metadata if self.metadatautils.addon.getSetting("music_art_scraper") == "true": # prefer the musicbrainzid that is already in the kodi database - only perform lookup if missing mb_albumid = details.get("musicbrainzalbumid") if not mb_albumid: mb_albumid = self.get_mb_album_id(artist, album, track) if mb_albumid: # get artwork from fanarttv if self.metadatautils.addon.getSetting("music_art_scraper_fatv") == "true": details["art"] = extend_dict(details["art"], self.metadatautils.fanarttv.album(mb_albumid)) # get metadata from theaudiodb if self.metadatautils.addon.getSetting("music_art_scraper_adb") == "true": details = extend_dict(details, self.audiodb.album_info(mb_albumid)) # get metadata from lastfm if self.metadatautils.addon.getSetting("music_art_scraper_lfm") == "true": details = extend_dict(details, self.lastfm.album_info(mb_albumid)) # metadata from musicbrainz if not details.get("year") or not details.get("genre"): details = extend_dict(details, self.mbrainz.get_albuminfo(mb_albumid)) # musicbrainz thumb as last resort if not details["art"].get("thumb"): details["art"]["thumb"] = self.mbrainz.get_albumthumb(mb_albumid) # download artwork to music folder if local_path and self.metadatautils.addon.getSetting("music_art_download") == "true": details["art"] = download_artwork(local_path, details["art"]) # download artwork to custom folder if local_path_custom and self.metadatautils.addon.getSetting("music_art_download_custom") == "true": details["art"] = download_artwork(local_path_custom, details["art"]) # set default details if not details.get("album") and details.get("title"): details["album"] = details["title"] if details["art"].get("thumb"): details["art"]["albumthumb"] = details["art"]["thumb"] # store results in cache and return results self.metadatautils.cache.set(cache_str, details) return details
def get_artist_metadata(self, artist, album, track, ignore_cache=False, flush_cache=False, manual=False): '''collect artist metadata for given artist''' details = {"art": {}} cache_str = "music_artwork.artist.%s" % artist.lower() # retrieve details from cache cache = self.metadatautils.cache.get(cache_str) if not cache and flush_cache: # nothing to do - just return empty results return details elif cache and flush_cache: # only update kodi metadata for updated counts etc details = extend_dict(self.get_artist_kodi_metadata(artist), cache) elif cache and not ignore_cache: # we have a valid cache - return that details = cache elif cache and manual: # user wants to manually override the artwork in the cache details = self.manual_set_music_artwork(cache, "artist") else: # nothing in cache - start metadata retrieval log_msg("get_artist_metadata --> artist: %s - album: %s - track: %s" % (artist, album, track)) details["cachestr"] = cache_str local_path = "" local_path_custom = "" # get metadata from kodi db details = extend_dict(details, self.get_artist_kodi_metadata(artist)) # get artwork from songlevel path if details.get("diskpath") and self.metadatautils.addon.getSetting("music_art_musicfolders") == "true": details["art"] = extend_dict(details["art"], self.lookup_artistart_in_folder(details["diskpath"])) local_path = details["diskpath"] # get artwork from custom folder if self.metadatautils.addon.getSetting("music_art_custom") == "true": custom_path = self.metadatautils.addon.getSetting("music_art_custom_path").decode("utf-8") if custom_path: diskpath = self.get_customfolder_path(custom_path, artist) log_msg("custom path on disk for artist: %s --> %s" % (artist, diskpath)) if diskpath: details["art"] = extend_dict(details["art"], self.lookup_artistart_in_folder(diskpath)) local_path_custom = diskpath details["customartpath"] = diskpath # lookup online metadata if self.metadatautils.addon.getSetting("music_art_scraper") == "true": if not album and not track: album = details.get("ref_album") track = details.get("ref_track") # prefer the musicbrainzid that is already in the kodi database - only perform lookup if missing mb_artistid = details.get("musicbrainzartistid", self.get_mb_artist_id(artist, album, track)) details["musicbrainzartistid"] = mb_artistid if mb_artistid: # get artwork from fanarttv if self.metadatautils.addon.getSetting("music_art_scraper_fatv") == "true": details["art"] = extend_dict(details["art"], self.metadatautils.fanarttv.artist(mb_artistid)) # get metadata from theaudiodb if self.metadatautils.addon.getSetting("music_art_scraper_adb") == "true": details = extend_dict(details, self.audiodb.artist_info(mb_artistid)) # get metadata from lastfm if self.metadatautils.addon.getSetting("music_art_scraper_lfm") == "true": details = extend_dict(details, self.lastfm.artist_info(mb_artistid)) # download artwork to music folder if local_path and self.metadatautils.addon.getSetting("music_art_download") == "true": details["art"] = download_artwork(local_path, details["art"]) # download artwork to custom folder if local_path_custom and self.metadatautils.addon.getSetting("music_art_download_custom") == "true": details["art"] = download_artwork(local_path_custom, details["art"]) # fix extrafanart if details["art"].get("fanarts"): for count, item in enumerate(details["art"]["fanarts"]): details["art"]["fanart.%s" % count] = item if not details["art"].get("extrafanart") and len(details["art"]["fanarts"]) > 1: details["art"]["extrafanart"] = "plugin://script.skin.helper.service/"\ "?action=extrafanart&fanarts=%s" % quote_plus(repr(details["art"]["fanarts"])) # multi-image path for all images for each arttype for arttype in ["banners", "clearlogos", "thumbs"]: art = details["art"].get(arttype, []) if len(art) > 1: # use the extrafanart plugin entry to display multi images details["art"][arttype] = "plugin://script.skin.helper.service/"\ "?action=extrafanart&fanarts=%s" % quote_plus(repr(art)) # set default details if not details.get("artist"): details["artist"] = artist if details["art"].get("thumb"): details["art"]["artistthumb"] = details["art"]["thumb"] # always store results in cache and return results self.metadatautils.cache.set(cache_str, details) return details
def get_pvr_artwork(self, title, channel, genre="", manual_select=False, ignore_cache=False): """ collect full metadata and artwork for pvr entries parameters: title (required) channel: channel name (required) year: year or date (optional) genre: (optional) the more optional parameters are supplied, the better the search results """ details = {"art": {}} # try cache first cache_str = "pvr_artwork.%s.%s" % (title.lower(), channel.lower()) cache = self._mutils.cache.get(cache_str) if cache and not manual_select and not ignore_cache: log_msg("get_pvr_artwork - return data from cache - %s" % cache_str) details = cache else: # no cache - start our lookup adventure log_msg("get_pvr_artwork - no data in cache - start lookup - %s" % cache_str) # workaround for recordings recordingdetails = self.lookup_local_recording(title, channel) if recordingdetails and not (channel and genre): genre = recordingdetails["genre"] channel = recordingdetails["channel"] details["pvrtitle"] = title details["pvrchannel"] = channel details["pvrgenre"] = genre details["cachestr"] = cache_str details["media_type"] = "" details["art"] = {} # filter genre unknown/other if not genre or genre.split(" / ")[0] in xbmc.getLocalizedString( 19499).split(" / "): details["genre"] = [] genre = "" log_msg("genre is unknown so ignore....") else: details["genre"] = genre.split(" / ") details["media_type"] = self.get_mediatype_from_genre(genre) searchtitle = self.get_searchtitle(title, channel) # only continue if we pass our basic checks filterstr = self.pvr_proceed_lookup(title, channel, genre, recordingdetails) proceed_lookup = False if filterstr else True if not proceed_lookup and manual_select: # warn user about active skip filter proceed_lookup = xbmcgui.Dialog().yesno( line1=self._mutils.addon.getLocalizedString(32027), line2=filterstr, heading=xbmc.getLocalizedString(750)) if proceed_lookup: # if manual lookup get the title from the user if manual_select: if sys.version_info.major == 3: searchtitle = xbmcgui.Dialog().input( xbmc.getLocalizedString(16017), searchtitle, type=xbmcgui.INPUT_ALPHANUM) else: searchtitle = xbmcgui.Dialog().input( xbmc.getLocalizedString(16017), searchtitle, type=xbmcgui.INPUT_ALPHANUM).decode("utf-8") if not searchtitle: return # if manual lookup and no mediatype, ask the user if manual_select and not details["media_type"]: yesbtn = self._mutils.addon.getLocalizedString(32042) nobtn = self._mutils.addon.getLocalizedString(32043) header = self._mutils.addon.getLocalizedString(32041) if xbmcgui.Dialog().yesno(header, header, yeslabel=yesbtn, nolabel=nobtn): details["media_type"] = "movie" else: details["media_type"] = "tvshow" # append thumb from recordingdetails if recordingdetails and recordingdetails.get("thumbnail"): details["art"]["thumb"] = recordingdetails["thumbnail"] # lookup custom path details = extend_dict( details, self.lookup_custom_path(searchtitle, title)) # lookup movie/tv library details = extend_dict( details, self.lookup_local_library(searchtitle, details["media_type"])) # do internet scraping if enabled if self._mutils.addon.getSetting("pvr_art_scraper") == "true": log_msg( "pvrart start scraping metadata for title: %s - media_type: %s" % (searchtitle, details["media_type"])) # prefer tmdb scraper tmdb_result = self._mutils.get_tmdb_details( "", "", searchtitle, "", "", details["media_type"], manual_select=manual_select, ignore_cache=manual_select) log_msg("pvrart lookup for title: %s - TMDB result: %s" % (searchtitle, tmdb_result)) if tmdb_result: details["media_type"] = tmdb_result["media_type"] details = extend_dict(details, tmdb_result) # fallback to tvdb scraper if (not tmdb_result or (tmdb_result and not tmdb_result.get("art")) or details["media_type"] == "tvshow"): tvdb_match = self.lookup_tvdb( searchtitle, channel, manual_select=manual_select) log_msg( "pvrart lookup for title: %s - TVDB result: %s" % (searchtitle, tvdb_match)) if tvdb_match: # get full tvdb results and extend with tmdb if not details["media_type"]: details["media_type"] = "tvshow" details = extend_dict( details, self._mutils.thetvdb.get_series(tvdb_match)) details = extend_dict( details, self._mutils.tmdb. get_videodetails_by_externalid( tvdb_match, "tvdb_id"), ["poster", "fanart"]) # fanart.tv scraping - append result to existing art if details.get( "imdbnumber") and details["media_type"] == "movie": details["art"] = extend_dict( details["art"], self._mutils.fanarttv.movie(details["imdbnumber"]), ["poster", "fanart", "landscape"]) elif details.get( "tvdb_id") and details["media_type"] == "tvshow": details["art"] = extend_dict( details["art"], self._mutils.fanarttv.tvshow(details["tvdb_id"]), ["poster", "fanart", "landscape"]) # append omdb details if details.get("imdbnumber"): details = extend_dict( details, self._mutils.omdb.get_details_by_imdbid( details["imdbnumber"]), ["rating", "votes"]) # set thumbnail - prefer scrapers thumb = "" if details.get("thumbnail"): thumb = details["thumbnail"] elif details["art"].get("landscape"): thumb = details["art"]["landscape"] elif details["art"].get("fanart"): thumb = details["art"]["fanart"] elif details["art"].get("poster"): thumb = details["art"]["poster"] # use google images as last-resort fallback for thumbs - if enabled elif self._mutils.addon.getSetting( "pvr_art_google") == "true": if manual_select: google_title = searchtitle else: google_title = '%s %s' % ( searchtitle, channel.lower().split(" hd")[0]) thumb = self._mutils.google.search_image( google_title, manual_select) if thumb: details["thumbnail"] = thumb details["art"]["thumb"] = thumb # extrafanart if details["art"].get("fanarts"): for count, item in enumerate( details["art"]["fanarts"]): details["art"]["fanart.%s" % count] = item if not details["art"].get("extrafanart") and len( details["art"]["fanarts"]) > 1: details["art"]["extrafanart"] = "plugin://script.skin.helper.service/"\ "?action=extrafanart&fanarts=%s" % quote_plus(repr(details["art"]["fanarts"])) # download artwork to custom folder if self._mutils.addon.getSetting( "pvr_art_download") == "true": details["art"] = download_artwork( self.get_custom_path(searchtitle, title), details["art"]) log_msg("pvrart lookup for title: %s - final result: %s" % (searchtitle, details)) # always store result in cache # manual lookups should not expire too often if manual_select: self._mutils.cache.set(cache_str, details, expiration=timedelta(days=365)) else: self._mutils.cache.set(cache_str, details) return details
def get_pvr_artwork(self, title, channel, genre="", manual_select=False, ignore_cache=False): ''' collect full metadata and artwork for pvr entries parameters: title (required) channel: channel name (required) year: year or date (optional) genre: (optional) the more optional parameters are supplied, the better the search results ''' details = {"art": {}} # try cache first cache_str = "pvr_artwork.%s.%s" % (title.lower(), channel.lower()) cache = self.metadatautils.cache.get(cache_str) if cache and not manual_select and not ignore_cache: log_msg("get_pvr_artwork - return data from cache - %s" % cache_str) details = cache else: # no cache - start our lookup adventure log_msg("get_pvr_artwork - no data in cache - start lookup - %s" % cache_str) # workaround for recordings recordingdetails = self.lookup_local_recording(title, channel) if recordingdetails and not (channel and genre): genre = recordingdetails["genre"] channel = recordingdetails["channel"] details["pvrtitle"] = title details["pvrchannel"] = channel details["pvrgenre"] = genre details["cachestr"] = cache_str details["media_type"] = "" details["art"] = {} # filter genre unknown/other if not genre or genre.split(" / ")[0] in xbmc.getLocalizedString(19499).split(" / "): details["genre"] = [] genre = "" log_msg("genre is unknown so ignore....") else: details["genre"] = genre.split(" / ") details["media_type"] = self.get_mediatype_from_genre(genre) searchtitle = self.get_searchtitle(title, channel) # only continue if we pass our basic checks filterstr = self.pvr_proceed_lookup(title, channel, genre, recordingdetails) proceed_lookup = False if filterstr else True if not proceed_lookup and manual_select: # warn user about active skip filter proceed_lookup = xbmcgui.Dialog().yesno( line1=self.metadatautils.addon.getLocalizedString(32027), line2=filterstr, heading=xbmc.getLocalizedString(750)) if proceed_lookup: # if manual lookup get the title from the user if manual_select: searchtitle = xbmcgui.Dialog().input(xbmc.getLocalizedString(16017), searchtitle, type=xbmcgui.INPUT_ALPHANUM).decode("utf-8") if not searchtitle: return # if manual lookup and no mediatype, ask the user if manual_select and not details["media_type"]: yesbtn = self.metadatautils.addon.getLocalizedString(32042) nobtn = self.metadatautils.addon.getLocalizedString(32043) header = self.metadatautils.addon.getLocalizedString(32041) if xbmcgui.Dialog().yesno(header, header, yeslabel=yesbtn, nolabel=nobtn): details["media_type"] = "movie" else: details["media_type"] = "tvshow" # append thumb from recordingdetails if recordingdetails and recordingdetails.get("thumbnail"): details["art"]["thumb"] = recordingdetails["thumbnail"] # lookup custom path details = extend_dict(details, self.lookup_custom_path(searchtitle, title)) # lookup movie/tv library details = extend_dict(details, self.lookup_local_library(searchtitle, details["media_type"])) # do internet scraping if enabled if self.metadatautils.addon.getSetting("pvr_art_scraper") == "true": log_msg( "pvrart start scraping metadata for title: %s - media_type: %s" % (searchtitle, details["media_type"])) # prefer tmdb scraper tmdb_result = self.metadatautils.get_tmdb_details( "", "", searchtitle, "", "", details["media_type"], manual_select=manual_select, ignore_cache=manual_select) log_msg("pvrart lookup for title: %s - TMDB result: %s" % (searchtitle, tmdb_result)) if tmdb_result: details["media_type"] = tmdb_result["media_type"] details = extend_dict(details, tmdb_result) # fallback to tvdb scraper if (not tmdb_result or (tmdb_result and not tmdb_result.get("art")) or details["media_type"] == "tvshow"): tvdb_match = self.lookup_tvdb(searchtitle, channel, manual_select=manual_select) log_msg("pvrart lookup for title: %s - TVDB result: %s" % (searchtitle, tvdb_match)) if tvdb_match: # get full tvdb results and extend with tmdb if not details["media_type"]: details["media_type"] = "tvshow" details = extend_dict(details, self.metadatautils.thetvdb.get_series(tvdb_match)) details = extend_dict(details, self.metadatautils.tmdb.get_videodetails_by_externalid( tvdb_match, "tvdb_id"), ["poster", "fanart"]) # fanart.tv scraping - append result to existing art if details.get("imdbnumber") and details["media_type"] == "movie": details["art"] = extend_dict( details["art"], self.metadatautils.fanarttv.movie( details["imdbnumber"]), [ "poster", "fanart", "landscape"]) elif details.get("tvdb_id") and details["media_type"] == "tvshow": details["art"] = extend_dict( details["art"], self.metadatautils.fanarttv.tvshow( details["tvdb_id"]), [ "poster", "fanart", "landscape"]) # append omdb details if details.get("imdbnumber"): details = extend_dict( details, self.metadatautils.omdb.get_details_by_imdbid( details["imdbnumber"]), [ "rating", "votes"]) # set thumbnail - prefer scrapers thumb = "" if details.get("thumbnail"): thumb = details["thumbnail"] elif details["art"].get("landscape"): thumb = details["art"]["landscape"] elif details["art"].get("fanart"): thumb = details["art"]["fanart"] elif details["art"].get("poster"): thumb = details["art"]["poster"] # use google images as last-resort fallback for thumbs - if enabled elif self.metadatautils.addon.getSetting("pvr_art_google") == "true": if manual_select: google_title = searchtitle else: google_title = '%s %s' % (searchtitle, channel.lower().split(" hd")[0]) thumb = self.metadatautils.google.search_image(google_title, manual_select) if thumb: details["thumbnail"] = thumb details["art"]["thumb"] = thumb # extrafanart if details["art"].get("fanarts"): for count, item in enumerate(details["art"]["fanarts"]): details["art"]["fanart.%s" % count] = item if not details["art"].get("extrafanart") and len(details["art"]["fanarts"]) > 1: details["art"]["extrafanart"] = "plugin://script.skin.helper.service/"\ "?action=extrafanart&fanarts=%s" % quote_plus(repr(details["art"]["fanarts"])) # download artwork to custom folder if self.metadatautils.addon.getSetting("pvr_art_download") == "true": details["art"] = download_artwork(self.get_custom_path(searchtitle, title), details["art"]) log_msg("pvrart lookup for title: %s - final result: %s" % (searchtitle, details)) # store result in cache and return details # always re-store in cache to prevent the cache from expiring self.metadatautils.cache.set(cache_str, details) return details