예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
 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
예제 #4
0
파일: main.py 프로젝트: camster1/RTOTV
    def show_widget_listing(self):
        '''display the listing for the provided action and mediatype'''
        media_type = self.options["mediatype"]
        action = self.options["action"]
        # set widget content type
        xbmcplugin.setContent(ADDON_HANDLE, media_type)

        # try to get from cache first...
        # we use a checksum based on the options to make sure the cache is ignored when needed
        all_items = []
        cache_str = "SkinHelper.Widgets.%s.%s" % (media_type, action)
        if not self.win.getProperty("widgetreload2"):
            # at startup we simply accept whatever is in the cache
            cache_checksum = None
        else:
            cache_checksum = ""
            for key in sorted(self.options):
                cache_checksum += "%s.%s" % (key, self.options[key])
        cache = self.cache.get(cache_str, checksum=cache_checksum)
        if cache and not self.options.get("skipcache") == "true":
            log_msg("MEDIATYPE: %s - ACTION: %s -- got items from cache - CHECKSUM: %s"
                    % (media_type, action, cache_checksum))
            all_items = cache

        # Call the correct method to get the content from json when no cache
        if not all_items:
            log_msg("MEDIATYPE: %s - ACTION: %s -- no cache, quering kodi api to get items - CHECKSUM: %s"
                    % (media_type, action, cache_checksum))

            # dynamically import and load the correct module, class and function
            try:
                media_module = __import__(media_type)
                media_class = getattr(
                    media_module,
                    media_type.capitalize())(self.addon, self.metadatautils, self.options)
                all_items = getattr(media_class, action)()
                del media_class
            except AttributeError:
                log_exception(__name__, "Incorrect widget action or type called")
            except Exception as exc:
                log_exception(__name__, exc)

            # randomize output if requested by skinner or user
            if self.options.get("randomize", "") == "true":
                all_items = sorted(all_items, key=lambda k: random.random())

            # prepare listitems and store in cache
            all_items = process_method_on_list(self.metadatautils.kodidb.prepare_listitem, all_items)
            self.cache.set(cache_str, all_items, checksum=cache_checksum)

        # fill that listing...
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)
        all_items = process_method_on_list(self.metadatautils.kodidb.create_listitem, all_items)
        xbmcplugin.addDirectoryItems(ADDON_HANDLE, all_items, len(all_items))

        # end directory listing
        xbmcplugin.endOfDirectory(handle=ADDON_HANDLE)
예제 #5
0
 def getcastmedia(self):
     '''helper to display get all media for a specific actor'''
     name = self.params.get("name")
     if name:
         all_items = self.kodi_db.castmedia(name)
         all_items = process_method_on_list(self.kodi_db.prepare_listitem, all_items)
         all_items = process_method_on_list(self.kodi_db.create_listitem, all_items)
         xbmcplugin.addDirectoryItems(int(sys.argv[1]), all_items, len(all_items))
     xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
예제 #6
0
 def set_win_props(self, prop_tuples):
     '''set multiple window properties from list of tuples'''
     process_method_on_list(self.set_win_prop, prop_tuples)
     # cleanup remaining properties
     new_keys = [item[0] for item in prop_tuples]
     for key, value in self.all_window_props.iteritems():
         if value and key not in new_keys:
             self.all_window_props[key] = ""
             self.win.clearProperty(key)
예제 #7
0
    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)
예제 #8
0
 def getcastmedia(self):
     '''helper to display get all media for a specific actor'''
     name = self.params.get("name")
     if name:
         all_items = self.kodi_db.castmedia(name)
         all_items = process_method_on_list(self.kodi_db.prepare_listitem,
                                            all_items)
         all_items = process_method_on_list(self.kodi_db.create_listitem,
                                            all_items)
         xbmcplugin.addDirectoryItems(int(sys.argv[1]), all_items,
                                      len(all_items))
     xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
    def do_search(self, search_term):
        '''scrape results for search query'''

        movies_list = self.dialog.getControl(3110)
        series_list = self.dialog.getControl(3111)
        cast_list = self.dialog.getControl(3112)

        # clear current values
        movies_list.reset()
        series_list.reset()
        cast_list.reset()

        if len(search_term) == 0:
            return

        filters = [{
            "operator": "contains",
            "field": "title",
            "value": search_term
        }]

        # Process movies
        items = self.kodidb.movies(filters=filters)
        items = process_method_on_list(self.kodidb.prepare_listitem, items)
        result = []
        for item in items:
            result.append(self.kodidb.create_listitem(item, False))
        movies_list.addItems(result)

        # Process tvshows
        items = self.kodidb.tvshows(filters=filters)
        items = process_method_on_list(self.kodidb.prepare_listitem, items)
        result = []
        for item in items:
            item["file"] = 'videodb://tvshows/titles/%s' % item['tvshowid']
            item["isFolder"] = True
            result.append(self.kodidb.create_listitem(item, False))
        series_list.addItems(result)

        # Process cast
        result = []
        for item in self.actors:
            if search_term.lower() in item["label"].lower():
                item = self.kodidb.prepare_listitem(item)
                item[
                    "file"] = "RunScript(script.skin.helper.service,action=getcastmedia,name=%s)" % item[
                        "label"]
                result.append(self.kodidb.create_listitem(item, False))
        cast_list.addItems(result)
예제 #10
0
 def similar(self):
     ''' get similar albums for recent played album'''
     all_items = []
     all_titles = list()
     ref_album = self.get_random_played_album()
     if not ref_album:
         ref_album = self.get_random_highrated_album()
     if ref_album:
         # get all albums for the genres in the album
         genres = ref_album["genre"]
         similar_title = ref_album["title"]
         for genre in genres:
             genre = genre.split(";")[0]
             self.options["genre"] = genre
             genre_albums = self.get_genre_albums(genre)
             for item in genre_albums:
                 # prevent duplicates so skip reference album and titles already in the list
                 if not item["title"] in all_titles and not item[
                         "title"] == similar_title:
                     item["extraproperties"] = {
                         "similartitle": similar_title
                     }
                     all_items.append(item)
                     all_titles.append(item["title"])
     # return the list capped by limit and sorted by rating
     all_items = sorted(all_items, key=itemgetter("rating"),
                        reverse=True)[:self.options["limit"]]
     return process_method_on_list(self.process_album, all_items)
예제 #11
0
 def recentplayed(self):
     ''' get in progress albums '''
     all_items = self.metadatautils.kodidb.albums(
         sort=kodi_constants.SORT_LASTPLAYED,
         filters=[],
         limits=(0, self.options["limit"]))
     return process_method_on_list(self.process_album, all_items)
예제 #12
0
 def random(self):
     ''' get random albums '''
     all_items = self.metadatautils.kodidb.albums(
         sort=kodi_constants.SORT_RANDOM,
         filters=[],
         limits=(0, self.options["limit"]))
     return process_method_on_list(self.process_album, all_items)
예제 #13
0
 def recent(self):
     ''' get recently added albums '''
     all_items = self.metadatautils.kodidb.albums(
         sort=kodi_constants.SORT_DATEADDED,
         filters=[],
         limits=(0, self.options["limit"]))
     return process_method_on_list(self.process_album, all_items)
예제 #14
0
 def recommended(self):
     ''' get recommended albums - library albums with sorted by rating '''
     all_items = self.metadatautils.kodidb.albums(
         sort=kodi_constants.SORT_RATING,
         filters=[],
         limits=(0, self.options["limit"]))
     return process_method_on_list(self.process_album, all_items)
예제 #15
0
    def recent(self):
        ''' get recently added episodes '''
        tvshow_episodes = {}
        total_count = 0
        unique_count = 0
        filters = []
        if self.options["hide_watched"]:
            filters.append(kodi_constants.FILTER_UNWATCHED)
        if self.options.get("tag"):
            filters.append({"operator": "contains", "field": "tag", "value": self.options["tag"]})
        while unique_count < self.options["limit"]:
            recent_episodes = self.metadatautils.kodidb.episodes(
                sort=kodi_constants.SORT_DATEADDED, filters=filters, limits=(
                    total_count, self.options["limit"] + total_count))
            if not self.options["group_episodes"]:
                # grouping is not enabled, just return the result
                return recent_episodes

            if len(recent_episodes) < self.options["limit"]:
                # break the loop if there are no more episodes
                unique_count = self.options["limit"]

            # if multiple episodes for the same show with same addition date, we combine them into one
            # to do that we build a dict with recent episodes for all episodes of the same season added on the same date
            for episode in recent_episodes:
                total_count += 1
                unique_key = "%s-%s-%s" % (episode["tvshowid"], episode["dateadded"].split(" ")[0], episode["season"])
                if unique_key not in tvshow_episodes:
                    tvshow_episodes[unique_key] = []
                    unique_count += 1
                tvshow_episodes[unique_key].append(episode)

        # create our entries and return the result sorted by dateadded
        all_items = process_method_on_list(self.create_grouped_entry, tvshow_episodes.itervalues())
        return sorted(all_items, key=itemgetter("dateadded"), reverse=True)[:self.options["limit"]]
예제 #16
0
 def getcastmedia(self):
     '''helper to show a dialog with all media for a specific actor'''
     xbmc.executebuiltin("ActivateWindow(busydialog)")
     name = self.params.get("name", "")
     window_header = self.params.get("name", "")
     results = []
     items = self.kodidb.castmedia(name)
     items = process_method_on_list(self.kodidb.prepare_listitem, items)
     for item in items:
         if item["file"].startswith("videodb://"):
             item["file"] = "ActivateWindow(Videos,%s,return)" % item["file"]
         else:
             item["file"] = 'PlayMedia("%s")' % item["file"]
         results.append(self.kodidb.create_listitem(item, False))
     # finished lookup - display listing with results
     xbmc.executebuiltin("dialog.Close(busydialog)")
     dialog = DialogSelect("DialogSelect.xml", "", listing=results, windowtitle=window_header, richlayout=True)
     dialog.doModal()
     result = dialog.result
     del dialog
     if result:
         while xbmc.getCondVisibility("System.HasModalDialog"):
             xbmc.executebuiltin("Action(Back)")
             xbmc.sleep(300)
         xbmc.executebuiltin(result.getfilename())
         del result
예제 #17
0
파일: tvshows.py 프로젝트: camster1/RTOTV
 def similar(self):
     ''' get similar tvshows for given imdbid or just from random watched title if no imdbid'''
     imdb_id = self.options.get("imdbid", "")
     all_items = []
     all_titles = list()
     # lookup tvshow by imdbid or just pick a random watched tvshow
     ref_tvshow = None
     if imdb_id:
         # get tvshow by imdbid
         ref_tvshow = self.metadatautils.kodidb.tvshow_by_imdbid(imdb_id)
     if not ref_tvshow:
         # just get a random watched tvshow
         ref_tvshow = self.get_random_watched_tvshow()
     if ref_tvshow:
         # get all tvshows for the genres in the tvshow
         genres = ref_tvshow["genre"]
         similar_title = ref_tvshow["title"]
         for genre in genres:
             self.options["genre"] = genre
             genre_tvshows = self.forgenre()
             for item in genre_tvshows:
                 # prevent duplicates so skip reference tvshow and titles already in the list
                 if not item["title"] in all_titles and not item[
                         "title"] == similar_title:
                     item["extraproperties"] = {
                         "similartitle": similar_title,
                         "originalpath": item["file"]
                     }
                     all_items.append(item)
                     all_titles.append(item["title"])
     # return the list capped by limit and sorted by rating
     tvshows = sorted(all_items, key=itemgetter("rating"),
                      reverse=True)[:self.options["limit"]]
     return process_method_on_list(self.process_tvshow, tvshows)
예제 #18
0
 def listing(self):
     '''main listing with all our movie nodes'''
     tag = self.options.get("tag", "")
     if tag:
         label_prefix = "%s - " % tag
     else:
         label_prefix = ""
     icon = "DefaultMovies.png"
     all_items = [
         (label_prefix + self.addon.getLocalizedString(32028), "inprogress&mediatype=movies&tag=%s" % tag, icon),
         (label_prefix + self.addon.getLocalizedString(32038), "recent&mediatype=movies&tag=%s" % tag, icon),
         (label_prefix + self.addon.getLocalizedString(32003), "recommended&mediatype=movies&tag=%s" % tag, icon),
         (label_prefix + self.addon.getLocalizedString(32029),
             "inprogressandrecommended&mediatype=movies&tag=%s" % tag, icon),
         (label_prefix + self.addon.getLocalizedString(32048), "random&mediatype=movies&tag=%s" % tag, icon),
         (label_prefix + self.addon.getLocalizedString(32066), "unwatched&mediatype=movies&tag=%s" % tag, icon),
         (label_prefix + self.addon.getLocalizedString(32046), "top250&mediatype=movies&tag=%s" % tag, icon),
         (label_prefix + xbmc.getLocalizedString(135),
             "browsegenres&mediatype=movies&tag=%s" % tag, "DefaultGenres.png")
     ]
     if not tag:
         all_items += [
             (self.addon.getLocalizedString(32006), "similar&mediatype=movies&tag=%s" % tag, icon),
             (xbmc.getLocalizedString(10134), "favourites&mediatype=movies&tag=%s" % tag, icon),
             (xbmc.getLocalizedString(20459), "tags&mediatype=movies", icon)
         ]
     return process_method_on_list(create_main_entry, all_items)
예제 #19
0
 def getcastmedia(self):
     '''helper to show a dialog with all media for a specific actor'''
     xbmc.executebuiltin("ActivateWindow(busydialog)")
     name = self.params.get("name", "")
     window_header = self.params.get("name", "")
     results = []
     items = self.kodidb.castmedia(name)
     items = process_method_on_list(self.kodidb.prepare_listitem, items)
     for item in items:
         if item["file"].startswith("videodb://"):
             item[
                 "file"] = "ActivateWindow(Videos,%s,return)" % item["file"]
         else:
             item["file"] = 'PlayMedia("%s")' % item["file"]
         results.append(self.kodidb.create_listitem(item, False))
     # finished lookup - display listing with results
     xbmc.executebuiltin("dialog.Close(busydialog)")
     dialog = DialogSelect("DialogSelect.xml",
                           "",
                           listing=results,
                           windowtitle=window_header,
                           richlayout=True)
     dialog.doModal()
     result = dialog.result
     del dialog
     if result:
         while xbmc.getCondVisibility("System.HasModalDialog"):
             xbmc.executebuiltin("Action(Back)")
             xbmc.sleep(300)
         xbmc.executebuiltin(result.getfilename())
         del result
예제 #20
0
 def listing(self):
     '''main listing with all our episode nodes'''
     all_items = [
         (self.addon.getLocalizedString(32027),
          "inprogress&mediatype=episodes", "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32002), "next&mediatype=episodes",
          "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32039), "recent&mediatype=episodes",
          "DefaultRecentlyAddedEpisodes.png"),
         (self.addon.getLocalizedString(32009),
          "recommended&mediatype=episodes", "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32010),
          "inprogressandrecommended&mediatype=episodes",
          "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32049),
          "inprogressandrandom&mediatype=episodes", "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32008), "random&mediatype=episodes",
          "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32042),
          "unaired&mediatype=episodes", "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32043),
          "nextaired&mediatype=episodes", "DefaultTvShows.png"),
         (self.addon.getLocalizedString(32068),
          "airingtoday&mediatype=episodes", "DefaultTvShows.png"),
         (xbmc.getLocalizedString(10134), "favourites&mediatype=episodes",
          "DefaultMovies.png")
     ]
     return process_method_on_list(create_main_entry, all_items)
예제 #21
0
 def listing(self):
     '''main listing with only our favourites nodes'''
     all_items = [(xbmc.getLocalizedString(10134),
                   "favourites&mediatype=favourites", "DefaultFile.png"),
                  (self.addon.getLocalizedString(32001),
                   "favourites&mediatype=favourites&mediafilter=media",
                   "DefaultMovies.png")]
     return process_method_on_list(create_main_entry, all_items)
예제 #22
0
파일: songs.py 프로젝트: camster1/RTOTV
 def recommended(self):
     ''' get recommended songs - library songs with score higher than 7 '''
     filters = [kodi_constants.FILTER_RATING_MUSIC]
     items = self.metadatautils.kodidb.songs(
         sort=kodi_constants.SORT_RATING,
         filters=filters,
         limits=(0, self.options["limit"]))
     return process_method_on_list(self.process_song, items)
예제 #23
0
 def channels(self):
     ''' get all channels '''
     all_items = []
     if xbmc.getCondVisibility("Pvr.HasTVChannels"):
         all_items = self.metadatautils.kodidb.channels(
             limits=(0, self.options["limit"]))
         all_items = process_method_on_list(self.process_channel, all_items)
     return all_items
예제 #24
0
 def timers(self):
     '''get pvr timers'''
     all_items = []
     if xbmc.getCondVisibility("Pvr.HasTVChannels"):
         all_items = sorted(self.metadatautils.kodidb.timers(),
                            key=itemgetter('starttime'))
         all_items = process_method_on_list(self.process_timer, all_items)
     return all_items
예제 #25
0
파일: tvshows.py 프로젝트: camster1/RTOTV
 def browsegenres(self):
     '''
         special entry which can be used to create custom genre listings
         returns each genre with poster/fanart artwork properties from 5
         random tvshows in the genre.
         TODO: get auto generated collage pictures from skinhelper's metadatautils ?
     '''
     all_genres = self.metadatautils.kodidb.genres("tvshow")
     return process_method_on_list(self.get_genre_artwork, all_genres)
예제 #26
0
파일: songs.py 프로젝트: camster1/RTOTV
 def recent(self):
     ''' get recently added songs '''
     items = self.metadatautils.kodidb.get_json(
         "AudioLibrary.GetRecentlyAddedSongs",
         filters=[],
         fields=kodi_constants.FIELDS_SONGS,
         limits=(0, self.options["limit"]),
         returntype="songs")
     return process_method_on_list(self.process_song, items)
예제 #27
0
    def do_search(self, search_term):
        '''scrape results for search query'''

        movies_list = self.dialog.getControl(3110)
        series_list = self.dialog.getControl(3111)
        cast_list = self.dialog.getControl(3112)

        # clear current values
        movies_list.reset()
        series_list.reset()
        cast_list.reset()

        if len(search_term) == 0:
            return

        filters = [{"operator": "contains", "field": "title", "value": search_term}]

        # Process movies
        items = self.kodidb.movies(filters=filters)
        items = process_method_on_list(self.kodidb.prepare_listitem, items)
        result = []
        for item in items:
            result.append(self.kodidb.create_listitem(item, False))
        movies_list.addItems(result)

        # Process tvshows
        items = self.kodidb.tvshows(filters=filters)
        items = process_method_on_list(self.kodidb.prepare_listitem, items)
        result = []
        for item in items:
            item["file"] = 'videodb://tvshows/titles/%s' % item['tvshowid']
            item["isFolder"] = True
            result.append(self.kodidb.create_listitem(item, False))
        series_list.addItems(result)

        # Process cast
        result = []
        for item in self.actors:
            if search_term.lower() in item["label"].lower():
                item = self.kodidb.prepare_listitem(item)
                item["file"] = "RunScript(script.skin.helper.service,action=getcastmedia,name=%s)" % item["label"]
                result.append(self.kodidb.create_listitem(item, False))
        cast_list.addItems(result)
예제 #28
0
    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)
예제 #29
0
 def next(self):
     ''' get next episodes '''
     filters = [kodi_constants.FILTER_UNWATCHED]
     if self.options["next_inprogress_only"]:
         filters = [kodi_constants.FILTER_INPROGRESS]
     if self.options.get("tag"):
         filters.append({"operator": "contains", "field": "tag", "value": self.options["tag"]})
     # First we get a list of all the inprogress/unwatched TV shows ordered by lastplayed
     all_shows = self.metadatautils.kodidb.tvshows(sort=kodi_constants.SORT_LASTPLAYED, filters=filters,
                                              limits=(0, self.options["limit"]))
     return process_method_on_list(self.get_next_episode_for_show, [d['tvshowid'] for d in all_shows])
예제 #30
0
파일: main.py 프로젝트: camster1/RTOTV
    def mainlisting(self):
        '''main listing'''
        all_items = []

        # movie node
        if xbmc.getCondVisibility("Library.HasContent(movies)"):
            all_items.append((xbmc.getLocalizedString(342), "movieslisting", "DefaultMovies.png"))

        # tvshows and episodes nodes
        if xbmc.getCondVisibility("Library.HasContent(tvshows)"):
            all_items.append((xbmc.getLocalizedString(20343), "tvshowslisting", "DefaultTvShows.png"))
            all_items.append((xbmc.getLocalizedString(20360), "episodeslisting", "DefaultTvShows.png"))

        # pvr node
        if xbmc.getCondVisibility("Pvr.HasTVChannels"):
            all_items.append((self.addon.getLocalizedString(32054), "pvrlisting", "DefaultAddonPVRClient.png"))

        # music nodes
        if xbmc.getCondVisibility("Library.HasContent(music)"):
            all_items.append((xbmc.getLocalizedString(132), "albumslisting", "DefaultAlbumCover.png"))
            all_items.append((xbmc.getLocalizedString(134), "songslisting", "DefaultMusicSongs.png"))
            all_items.append((xbmc.getLocalizedString(133), "artistslisting", "DefaultArtist.png"))

        # musicvideo node
        if xbmc.getCondVisibility("Library.HasContent(musicvideos)"):
            all_items.append((xbmc.getLocalizedString(20389), "musicvideoslisting", "DefaultAddonAlbumInfo.png"))

        # media node
        if xbmc.getCondVisibility(
                "Library.HasContent(movies) | Library.HasContent(tvshows) | Library.HasContent(music)"):
            all_items.append((self.addon.getLocalizedString(32057), "medialisting", "DefaultAddonAlbumInfo.png"))

        # favourites node
        all_items.append((xbmc.getLocalizedString(10134), "favouriteslisting", "DefaultAddonAlbumInfo.png"))

        # process the listitems and display listing
        all_items = process_method_on_list(create_main_entry, all_items)
        all_items = process_method_on_list(self.metadatautils.kodidb.prepare_listitem, all_items)
        all_items = process_method_on_list(self.metadatautils.kodidb.create_listitem, all_items)
        xbmcplugin.addDirectoryItems(ADDON_HANDLE, all_items, len(all_items))
        xbmcplugin.endOfDirectory(handle=ADDON_HANDLE)
예제 #31
0
파일: artists.py 프로젝트: camster1/RTOTV
 def listing(self):
     '''main listing with all our artist nodes'''
     all_items = [
         (self.addon.getLocalizedString(32063), "recent&mediatype=artists",
          "DefaultMusicArtists.png"),
         (self.addon.getLocalizedString(32065),
          "recommended&mediatype=artists", "DefaultMusicArtists.png"),
         (self.addon.getLocalizedString(32064), "random&mediatype=artists",
          "DefaultMusicArtists.png"),
         (xbmc.getLocalizedString(10134), "favourites&mediatype=artists",
          "DefaultMusicArtists.png")
     ]
     return process_method_on_list(create_main_entry, all_items)
예제 #32
0
파일: tvshows.py 프로젝트: camster1/RTOTV
 def random(self):
     ''' get random tvshows '''
     filters = []
     if self.options.get("tag"):
         filters.append({
             "operator": "contains",
             "field": "tag",
             "value": self.options["tag"]
         })
     tvshows = self.metadatautils.kodidb.tvshows(
         sort=kodi_constants.SORT_RANDOM,
         filters=filters,
         limits=(0, self.options["limit"]))
     return process_method_on_list(self.process_tvshow, tvshows)
예제 #33
0
파일: tvshows.py 프로젝트: camster1/RTOTV
 def inprogress(self):
     ''' get in progress tvshows '''
     filters = [kodi_constants.FILTER_INPROGRESS]
     if self.options.get("tag"):
         filters.append({
             "operator": "contains",
             "field": "tag",
             "value": self.options["tag"]
         })
     tvshows = self.metadatautils.kodidb.tvshows(
         sort=kodi_constants.SORT_LASTPLAYED,
         filters=filters,
         limits=(0, self.options["limit"]))
     return process_method_on_list(self.process_tvshow, tvshows)
예제 #34
0
파일: songs.py 프로젝트: camster1/RTOTV
 def listing(self):
     '''main listing with all our song nodes'''
     all_items = [(self.addon.getLocalizedString(32013),
                   "recentplayed&mediatype=songs", "DefaultMusicSongs.png"),
                  (self.addon.getLocalizedString(32012),
                   "recent&mediatype=songs", "DefaultMusicSongs.png"),
                  (self.addon.getLocalizedString(32016),
                   "recommended&mediatype=songs", "DefaultMusicSongs.png"),
                  (self.addon.getLocalizedString(32055),
                   "similar&mediatype=songs", "DefaultMusicSongs.png"),
                  (self.addon.getLocalizedString(32034),
                   "random&mediatype=songs", "DefaultMusicSongs.png"),
                  (xbmc.getLocalizedString(10134),
                   "favourites&mediatype=songs", "DefaultMusicAlbums.png")]
     return process_method_on_list(create_main_entry, all_items)
예제 #35
0
 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
예제 #36
0
 def listing(self):
     '''main listing with all our musicvideo nodes'''
     tag = self.options.get("tag", "")
     all_items = [(self.addon.getLocalizedString(32061),
                   "inprogress&mediatype=musicvideos&tag=%s" % tag,
                   "DefaultTvShows.png"),
                  (self.addon.getLocalizedString(32040),
                   "recent&mediatype=musicvideos&tag=%s" % tag,
                   "DefaultRecentlyAddedmusicvideos.png"),
                  (self.addon.getLocalizedString(32062),
                   "random&mediatype=musicvideos&tag=%s" % tag,
                   "DefaultTvShows.png"),
                  (xbmc.getLocalizedString(10134),
                   "favourites&mediatype=musicvideos&tag=%s" % tag,
                   "DefaultMovies.png")]
     return process_method_on_list(create_main_entry, all_items)
예제 #37
0
 def open_item(self):
     '''open selected item'''
     control_id = self.getFocusId()
     listitem = self.getControl(control_id).getSelectedItem()
     if "videodb:" in listitem.getfilename():
         # tvshow: open path
         xbmc.executebuiltin('ReplaceWindow(Videos,"%s")' % self.listitem.getfilename())
         self.close_dialog()
     elif "actor" in listitem.getProperty("DBTYPE"):
         # cast dialog
         xbmc.executebuiltin("ActivateWindow(busydialog)")
         from dialogselect import DialogSelect
         results = []
         kodidb = KodiDb()
         name = listitem.getLabel().decode("utf-8")
         items = kodidb.castmedia(name)
         items = process_method_on_list(kodidb.prepare_listitem, items)
         for item in items:
             if item["file"].startswith("videodb://"):
                 item["file"] = "ActivateWindow(Videos,%s,return)" % item["file"]
             else:
                 item["file"] = 'PlayMedia("%s")' % item["file"]
             results.append(kodidb.create_listitem(item, False))
         # finished lookup - display listing with results
         xbmc.executebuiltin("dialog.Close(busydialog)")
         dialog = DialogSelect("DialogSelect.xml", "", listing=results, windowtitle=name, richlayout=True)
         dialog.doModal()
         result = dialog.result
         del dialog
         if result:
             xbmc.executebuiltin(result.getfilename())
             self.close_dialog()
     else:
         # video file: start playback
         xbmc.executebuiltin('PlayMedia("%s")' % listitem.getfilename())
         self.close_dialog()
예제 #38
0
 def set_win_props(self, prop_tuples):
     '''set multiple window properties from list of tuples'''
     process_method_on_list(self.set_win_prop, prop_tuples)
예제 #39
0
 def reset_win_props(self):
     '''reset all window props set by the script...'''
     process_method_on_list(self.win.clearProperty, self.all_window_props)
     self.all_window_props = []