def monitor_livetv(self): ''' for livetv we are not notified when the program changes so we have to monitor that ourself ''' if self.monitoring_stream: # another monitoring already in progress... return last_title = "" while not self.abortRequested() and getCondVisibility("Player.HasVideo"): self.monitoring_stream = True li_title = xbmc.getInfoLabel("Player.Title").decode('utf-8') if li_title and li_title != last_title: all_props = [] last_title = li_title self.reset_win_props() li_channel = xbmc.getInfoLabel("VideoPlayer.ChannelName").decode('utf-8') # pvr artwork if getCondVisibility("Skin.HasSetting(SkinHelper.EnablePVRThumbs)"): li_genre = xbmc.getInfoLabel("VideoPlayer.Genre").decode('utf-8') pvrart = self.metadatautils.get_pvr_artwork(li_title, li_channel, li_genre) all_props = prepare_win_props(pvrart, u"SkinHelper.Player.") # pvr channellogo channellogo = self.metadatautils.get_channellogo(li_channel) all_props.append(("SkinHelper.Player.ChannelLogo", channellogo)) all_props.append(("SkinHelper.Player.Art.ChannelLogo", channellogo)) if last_title == li_title: self.metadatautils.process_method_on_list(self.set_win_prop, all_props) # show infopanel if needed self.show_info_panel() self.waitForAbort(2) self.monitoring_stream = False
def set_music_properties(self): '''sets the window props for a playing song''' li_title = xbmc.getInfoLabel("MusicPlayer.Title").decode('utf-8') li_title_org = li_title li_artist = xbmc.getInfoLabel("MusicPlayer.Artist").decode('utf-8') li_album = xbmc.getInfoLabel("MusicPlayer.Album").decode('utf-8') li_disc = xbmc.getInfoLabel("MusicPlayer.DiscNumber").decode('utf-8') li_plot = xbmc.getInfoLabel("MusicPlayer.Comment").decode('utf-8') # fix for internet streams if not li_artist and xbmc.getCondVisibility("Player.IsInternetStream"): for splitchar in [" - ", "-", ":", ";"]: if splitchar in li_title: li_artist = li_title.split(splitchar)[0].strip() li_title = li_title.split(splitchar)[1].strip() break if xbmc.getCondVisibility("Skin.HasSetting(SkinHelper.EnableMusicArt)" ) and li_artist and (li_title or li_album): result = self.metadatautils.get_music_artwork( li_artist, li_album, li_title, li_disc) if result.get("extendedplot") and li_plot: li_plot = li_plot.replace('\n', ' ').replace('\r', '').rstrip() result["extendedplot"] = "%s -- %s" % (result["extendedplot"], li_plot) all_props = prepare_win_props(result, u"SkinHelper.Player.") if li_title_org == xbmc.getInfoLabel("MusicPlayer.Title").decode( 'utf-8'): process_method_on_list(self.set_win_prop, all_props)
def monitor_livetv(self): ''' for livetv we are not notified when the program changes so we have to monitor that ourself ''' if self.monitoring_stream: # another monitoring already in progress... return last_title = "" while not self.abortRequested() and xbmc.getCondVisibility("Player.HasVideo"): self.monitoring_stream = True li_title = xbmc.getInfoLabel("Player.Title").decode('utf-8') if li_title and li_title != last_title: all_props = [] last_title = li_title self.reset_win_props() li_channel = xbmc.getInfoLabel("VideoPlayer.ChannelName").decode('utf-8') # pvr artwork if xbmc.getCondVisibility("Skin.HasSetting(SkinHelper.EnablePVRThumbs)"): li_genre = xbmc.getInfoLabel("VideoPlayer.Genre").decode('utf-8') pvrart = self.metadatautils.get_pvr_artwork(li_title, li_channel, li_genre) all_props = prepare_win_props(pvrart, u"SkinHelper.Player.") # pvr channellogo all_props.append(("SkinHelper.Player.ChannelLogo", self.metadatautils.get_channellogo(li_channel))) if last_title == li_title: process_method_on_list(self.set_win_prop, all_props) self.waitForAbort(2) self.monitoring_stream = False
def set_music_properties(self): '''sets the window props for a playing song''' li_title = xbmc.getInfoLabel("MusicPlayer.Title").decode('utf-8') li_title_org = li_title li_artist = xbmc.getInfoLabel("MusicPlayer.Artist").decode('utf-8') li_album = xbmc.getInfoLabel("MusicPlayer.Album").decode('utf-8') li_disc = xbmc.getInfoLabel("MusicPlayer.DiscNumber").decode('utf-8') li_plot = xbmc.getInfoLabel("MusicPlayer.Comment").decode('utf-8') # fix for internet streams if not li_artist and xbmc.getCondVisibility("Player.IsInternetStream"): for splitchar in [" - ", "-", ":", ";"]: if splitchar in li_title: li_artist = li_title.split(splitchar)[0].strip() li_title = li_title.split(splitchar)[1].strip() break if xbmc.getCondVisibility("Skin.HasSetting(SkinHelper.EnableMusicArt)") and li_artist and( li_title or li_album): result = self.metadatautils.get_music_artwork(li_artist, li_album, li_title, li_disc) if result.get("extendedplot") and li_plot: li_plot = li_plot.replace('\n', ' ').replace('\r', '').rstrip() result["extendedplot"] = "%s -- %s" % (result["extendedplot"], li_plot) all_props = prepare_win_props(result, u"SkinHelper.Player.") if li_title_org == xbmc.getInfoLabel("MusicPlayer.Title").decode('utf-8'): process_method_on_list(self.set_win_prop, all_props)
def set_video_properties(self, mediatype, li_dbid): '''sets the window props for a playing video item''' if not mediatype: mediatype = self.get_mediatype() details = self.get_player_infolabels() li_title = details["title"] li_year = details["year"] li_imdb = details["imdbnumber"] li_showtitle = details["tvshowtitle"] details = {"art": {}} # video content if mediatype in ["movie", "episode", "musicvideo"]: # get imdb_id li_imdb, li_tvdb = self.metadatautils.get_imdbtvdb_id( li_title, mediatype, li_year, li_imdb, li_showtitle) # generic video properties (studio, streamdetails, omdb, top250) details = self.metadatautils.extend_dict( details, self.metadatautils.get_omdb_info(li_imdb)) if li_dbid: details = self.metadatautils.extend_dict( details, self.metadatautils.get_streamdetails(li_dbid, mediatype)) details = self.metadatautils.extend_dict( details, self.metadatautils.get_top250_rating(li_imdb)) # tvshows-only properties (tvdb) if mediatype == "episode": details = self.metadatautils.extend_dict( details, self.metadatautils.get_tvdb_details(li_imdb, li_tvdb)) # movies-only properties (tmdb, animated art) if mediatype == "movie": details = self.metadatautils.extend_dict( details, self.metadatautils.get_tmdb_details(li_imdb)) if li_imdb and getCondVisibility( "Skin.HasSetting(SkinHelper.EnableAnimatedPosters)"): details = self.metadatautils.extend_dict( details, self.metadatautils.get_animated_artwork(li_imdb)) # extended art if getCondVisibility( "Skin.HasSetting(SkinHelper.EnableExtendedArt)"): tmdbid = details.get("tmdb_id", "") details = self.metadatautils.extend_dict( details, self.metadatautils.get_extended_artwork( li_imdb, li_tvdb, tmdbid, mediatype)) if li_title == xbmc.getInfoLabel("Player.Title").decode('utf-8'): all_props = prepare_win_props(details, u"SkinHelper.Player.") self.metadatautils.process_method_on_list(self.set_win_prop, all_props)
def set_video_properties(self, mediatype, li_dbid): '''sets the window props for a playing video item''' if not mediatype: mediatype = self.get_mediatype() details = self.get_player_infolabels() li_title = details["title"] li_year = details["year"] li_imdb = details["imdbnumber"] li_showtitle = details["tvshowtitle"] details = {"art": {}} # video content if mediatype in ["movie", "episode", "musicvideo"]: # get imdb_id li_imdb, li_tvdb = self.metadatautils.get_imdbtvdb_id(li_title, mediatype, li_year, li_imdb, li_showtitle) # generic video properties (studio, streamdetails, omdb, top250) details = extend_dict(details, self.metadatautils.get_omdb_info(li_imdb)) if li_dbid: details = extend_dict(details, self.metadatautils.get_streamdetails(li_dbid, mediatype)) details = extend_dict(details, self.metadatautils.get_top250_rating(li_imdb)) # tvshows-only properties (tvdb) if mediatype == "episode": details = extend_dict(details, self.metadatautils.get_tvdb_details(li_imdb, li_tvdb)) # movies-only properties (tmdb, animated art) if mediatype == "movie": details = extend_dict(details, self.metadatautils.get_tmdb_details(li_imdb)) if li_imdb and xbmc.getCondVisibility("Skin.HasSetting(SkinHelper.EnableAnimatedPosters)"): details = extend_dict(details, self.metadatautils.get_animated_artwork(li_imdb)) # extended art if xbmc.getCondVisibility("Skin.HasSetting(SkinHelper.EnableExtendedArt)"): tmdbid = details.get("tmdb_id", "") details = extend_dict(details, self.metadatautils.get_extended_artwork( li_imdb, li_tvdb, tmdbid, mediatype)) if li_title == xbmc.getInfoLabel("Player.Title").decode('utf-8'): all_props = prepare_win_props(details, u"SkinHelper.Player.") process_method_on_list(self.set_win_prop, all_props)
def set_listitem_details(self, cur_listitem, content_type, prefix): '''set the window properties based on the current listitem''' try: if cur_listitem in self.listitem_details: # data already in memory all_props = self.listitem_details[cur_listitem] else: # prefer listitem's contenttype over container's contenttype dbtype = xbmc.getInfoLabel("%sListItem.DBTYPE" % prefix) if not dbtype: dbtype = xbmc.getInfoLabel("%sListItem.Property(DBTYPE)" % prefix) if dbtype: content_type = dbtype + "s" # collect all details from listitem listitem = self.get_listitem_details(content_type, prefix) if prefix and cur_listitem == self.last_listitem: # for widgets we immediately set all normal properties as window prop self.set_win_props(prepare_win_props(listitem)) # if another lookup for the same listitem already in progress... wait for it to complete while self.lookup_busy.get(cur_listitem): xbmc.sleep(250) if self.exit: return self.lookup_busy[cur_listitem] = True # music content if content_type in ["albums", "artists", "songs"] and self.enable_musicart: listitem = extend_dict(listitem, self.artutils.get_music_artwork( listitem["artist"], listitem["album"], listitem["title"], listitem["discnumber"])) # moviesets elif listitem["path"].startswith("videodb://movies/sets/") and listitem["dbid"]: listitem = extend_dict(listitem, self.artutils.get_moviesetdetails(listitem["dbid"])) content_type = "sets" # video content elif content_type in ["movies", "setmovies", "tvshows", "seasons", "episodes", "musicvideos"]: # get imdb and tvdbid listitem["imdbnumber"], tvdbid = self.artutils.get_imdbtvdb_id( listitem["title"], content_type, listitem["year"], listitem["imdbnumber"], listitem["tvshowtitle"]) # generic video properties (studio, streamdetails, omdb, top250) listitem = extend_dict(listitem, self.get_directors_writers(listitem["director"], listitem["writer"])) if self.enable_extrafanart: if not listitem["filenameandpath"]: listitem["filenameandpath"] = listitem["path"] listitem = extend_dict(listitem, self.artutils.get_extrafanart(listitem["filenameandpath"])) listitem = extend_dict(listitem, self.get_genres(listitem["genre"])) listitem = extend_dict(listitem, self.artutils.get_duration(listitem["duration"])) listitem = extend_dict(listitem, self.artutils.get_studio_logo(listitem["studio"])) listitem = extend_dict(listitem, self.artutils.get_omdb_info(listitem["imdbnumber"])) listitem = extend_dict( listitem, self.get_streamdetails( listitem["dbid"], listitem["path"], content_type)) if self.exit: return listitem = extend_dict(listitem, self.artutils.get_top250_rating(listitem["imdbnumber"])) if self.enable_extendedart: if not (listitem["art"]["clearlogo"] or listitem["art"]["landscape"]): listitem = extend_dict(listitem, self.artutils.get_extended_artwork( listitem["imdbnumber"], tvdbid, content_type)) if self.exit: return # tvshows-only properties (tvdb) if content_type in ["tvshows", "seasons", "episodes"]: listitem = extend_dict(listitem, self.artutils.get_tvdb_details(listitem["imdbnumber"], tvdbid)) # movies-only properties (tmdb, animated art) if content_type in ["movies", "setmovies"]: listitem = extend_dict(listitem, self.artutils.get_tmdb_details(listitem["imdbnumber"])) if listitem["imdbnumber"] and self.enable_animatedart: listitem = extend_dict(listitem, self.artutils.get_animated_artwork(listitem["imdbnumber"])) if self.exit: return # monitor listitem props when PVR is active elif content_type in ["tvchannels", "tvrecordings", "channels", "recordings", "timers", "tvtimers"]: listitem = self.get_pvr_artwork(listitem, prefix) # process all properties all_props = prepare_win_props(listitem) if content_type not in ["weathers", "systeminfos", "sets"]: self.listitem_details[cur_listitem] = all_props self.lookup_busy.pop(cur_listitem, None) if cur_listitem == self.last_listitem: self.set_win_props(all_props) except Exception as exc: log_exception(__name__, exc)
def set_listitem_details(self, cur_listitem, content_type, prefix): '''set the window properties based on the current listitem''' self.bgtasks += 1 try: if cur_listitem in self.listitem_details: # data already in memory all_props = self.listitem_details[cur_listitem] else: # prefer listitem's contenttype over container's contenttype dbtype = xbmc.getInfoLabel("%sListItem.DBTYPE" % prefix) if not dbtype: dbtype = xbmc.getInfoLabel("%sListItem.Property(DBTYPE)" % prefix) if dbtype: content_type = dbtype + "s" # collect all details from listitem listitem = self.get_listitem_details(content_type, prefix) if prefix and cur_listitem == self.last_listitem: # for widgets we immediately set all normal properties as window prop self.set_win_props(prepare_win_props(listitem)) # if another lookup for the same listitem already in progress... wait for it to complete while self.lookup_busy.get(cur_listitem): xbmc.sleep(250) if self.exit: return self.lookup_busy[cur_listitem] = True # music content if content_type in ["albums", "artists", "songs" ] and self.enable_musicart: listitem = extend_dict( listitem, self.metadatautils.get_music_artwork( listitem["artist"], listitem["album"], listitem["title"], listitem["discnumber"])) # moviesets elif listitem["path"].startswith( "videodb://movies/sets/") and listitem["dbid"]: listitem = extend_dict( listitem, self.metadatautils.get_moviesetdetails( listitem["title"], listitem["dbid"])) content_type = "sets" # video content elif content_type in [ "movies", "setmovies", "tvshows", "seasons", "episodes", "musicvideos" ]: # get imdb and tvdbid listitem[ "imdbnumber"], tvdbid = self.metadatautils.get_imdbtvdb_id( listitem["title"], content_type, listitem["year"], listitem["imdbnumber"], listitem["tvshowtitle"]) # generic video properties (studio, streamdetails, omdb, top250) listitem = extend_dict( listitem, self.get_directors_writers(listitem["director"], listitem["writer"])) if self.enable_extrafanart: if not listitem["filenameandpath"]: listitem["filenameandpath"] = listitem["path"] if "videodb://" not in listitem["filenameandpath"]: listitem = extend_dict( listitem, self.metadatautils.get_extrafanart( listitem["filenameandpath"])) listitem = extend_dict(listitem, self.get_genres(listitem["genre"])) listitem = extend_dict( listitem, self.metadatautils.get_duration(listitem["duration"])) listitem = extend_dict( listitem, self.metadatautils.get_studio_logo(listitem["studio"])) listitem = extend_dict( listitem, self.metadatautils.get_omdb_info( listitem["imdbnumber"])) listitem = extend_dict( listitem, self.get_streamdetails(listitem["dbid"], listitem["path"], content_type)) if self.exit: return listitem = extend_dict( listitem, self.metadatautils.get_top250_rating( listitem["imdbnumber"])) if self.exit: return # tvshows-only properties (tvdb) if content_type in ["tvshows", "seasons", "episodes"]: listitem = extend_dict( listitem, self.metadatautils.get_tvdb_details( listitem["imdbnumber"], tvdbid)) # movies-only properties (tmdb, animated art) if content_type in ["movies", "setmovies"]: listitem = extend_dict( listitem, self.metadatautils.get_tmdb_details( listitem["imdbnumber"])) if listitem["imdbnumber"] and self.enable_animatedart: listitem = extend_dict( listitem, self.metadatautils.get_animated_artwork( listitem["imdbnumber"])) # extended art if self.enable_extendedart: tmdbid = listitem.get("tmdb_id", "") listitem = extend_dict( listitem, self.metadatautils.get_extended_artwork( listitem["imdbnumber"], tvdbid, tmdbid, content_type), ["posters", "clearlogos", "banners"]) if self.exit: return # monitor listitem props when PVR is active elif content_type in [ "tvchannels", "tvrecordings", "channels", "recordings", "timers", "tvtimers" ]: listitem = self.get_pvr_artwork(listitem, prefix) # process all properties all_props = prepare_win_props(listitem) if content_type not in ["weathers", "systeminfos", "sets"]: self.listitem_details[cur_listitem] = all_props self.lookup_busy.pop(cur_listitem, None) if cur_listitem == self.last_listitem: self.set_win_props(all_props) except Exception as exc: log_exception(__name__, exc) self.bgtasks -= 1
def set_listitem_details(self, cur_listitem, content_type, prefix): '''set the window properties based on the current listitem''' try: if cur_listitem in self.listitem_details: # data already in memory all_props = self.listitem_details[cur_listitem] else: # skip if another lookup for the same listitem is already in progress... if self.lookup_busy.get(cur_listitem): return self.lookup_busy[cur_listitem] = True # clear all window props, do this delayed to prevent flickering of the screen thread.start_new_thread(self.delayed_flush, (cur_listitem, )) # wait if we already have more than 5 items in the queue while len(self.lookup_busy) > 5: xbmc.sleep(100) if self.exit or cur_listitem != self.last_listitem: self.lookup_busy.pop(cur_listitem, None) return # prefer listitem's contenttype over container's contenttype dbtype = xbmc.getInfoLabel("%sListItem.DBTYPE" % prefix) if not dbtype: dbtype = xbmc.getInfoLabel("%sListItem.Property(DBTYPE)" % prefix) if dbtype: content_type = dbtype + "s" # collect details from listitem details = self.get_listitem_details(content_type, prefix) # music content if content_type in ["albums", "artists", "songs" ] and self.enable_musicart: details = extend_dict( details, self.metadatautils.get_music_artwork( details["artist"], details["album"], details["title"], details["discnumber"])) # moviesets elif details["path"].startswith( "videodb://movies/sets/") and details["dbid"]: details = extend_dict( details, self.metadatautils.get_moviesetdetails( details["title"], details["dbid"]), ["year"]) content_type = "sets" # video content elif content_type in [ "movies", "setmovies", "tvshows", "seasons", "episodes", "musicvideos" ]: # get imdb and tvdbid details[ "imdbnumber"], tvdbid = self.metadatautils.get_imdbtvdb_id( details["title"], content_type, details["year"], details["imdbnumber"], details["tvshowtitle"]) # generic video properties (studio, streamdetails, omdb, top250) details = merge_dict( details, self.get_directors_writers(details["director"], details["writer"])) if self.enable_extrafanart: if not details["filenameandpath"]: details["filenameandpath"] = details["path"] if "videodb://" not in details["filenameandpath"]: efa = self.metadatautils.get_extrafanart( details["filenameandpath"]) if efa: details["art"] = merge_dict( details["art"], efa["art"]) details = merge_dict( details, self.metadatautils.get_duration(details["duration"])) details = merge_dict(details, self.get_genres(details["genre"])) details = merge_dict( details, self.metadatautils.get_studio_logo(details["studio"])) details = merge_dict( details, self.metadatautils.get_omdb_info( details["imdbnumber"])) details = merge_dict( details, self.get_streamdetails(details["dbid"], details["path"], content_type)) details = merge_dict( details, self.metadatautils.get_top250_rating( details["imdbnumber"])) if self.exit: return # tvshows-only properties (tvdb) if content_type in ["tvshows", "seasons", "episodes"]: details = merge_dict( details, self.metadatautils.get_tvdb_details( details["imdbnumber"], tvdbid)) # movies-only properties (tmdb, animated art) if content_type in ["movies", "setmovies"]: details = merge_dict( details, self.metadatautils.get_tmdb_details( details["imdbnumber"])) if details["imdbnumber"] and self.enable_animatedart: details = extend_dict( details, self.metadatautils.get_animated_artwork( details["imdbnumber"])) if self.exit: return # extended art if self.enable_extendedart: tmdbid = details.get("tmdb_id", "") details = extend_dict( details, self.metadatautils.get_extended_artwork( details["imdbnumber"], tvdbid, tmdbid, content_type), [ "posters", "clearlogos", "banners", "discarts", "cleararts", "characterarts" ]) if self.exit: return # monitor listitem props when PVR is active elif content_type in [ "tvchannels", "tvrecordings", "channels", "recordings", "timers", "tvtimers" ]: details = self.get_pvr_artwork(details, prefix) # process all properties all_props = prepare_win_props(details) if "sets" not in content_type: self.listitem_details[cur_listitem] = all_props self.lookup_busy.pop(cur_listitem, None) if cur_listitem == self.last_listitem: self.set_win_props(all_props) except Exception as exc: log_exception(__name__, exc) self.lookup_busy.pop(cur_listitem, None)