Пример #1
0
 def add_navigation(list_items, bottom=False):
     list_items.insert(
         0, MainMenuFolderItem(url=router_url_from_string(ROUTE.MAIN_MENU)))
     if bottom:
         list_items.append(
             MainMenuFolderItem(
                 url=router_url_from_string(ROUTE.MAIN_MENU)))
Пример #2
0
 def a_to_z_menu(self, collection):
     import string
     filter_type = FILTER_TYPE.STARTS_WITH_LETTER
     with self.start_directory(self.handle):
         DirectoryItem(title=get_string(30251),
                       url=router_url_from_string(ROUTE.FILTER, collection,
                                                  filter_type,
                                                  '0-9'))(self.handle)
         for c in string.ascii_uppercase:
             DirectoryItem(title=c,
                           url=router_url_from_string(
                               ROUTE.FILTER, collection, filter_type,
                               c))(self.handle)
Пример #3
0
    def genre_menu(self, collection):
        genres = [
            LANG.ACTION, LANG.ANIMATED, LANG.ADVENTURE, LANG.DOCUMENTARY,
            LANG.DRAMA, LANG.FANTASY, LANG.HISTORICAL, LANG.HORROR, LANG.MUSIC,
            LANG.IMAX, LANG.CATASTROPHIC, LANG.COMEDY, LANG.SHORT, LANG.CRIME,
            LANG.MUSICAL, LANG.MYSTERIOUS, LANG.EDUCATIONAL, LANG.FAIRYTALE,
            LANG.PSYCHOLOGICAL, LANG.JOURNALISTIC, LANG.REALITY, LANG.TRAVEL,
            LANG.FAMILY, LANG.ROMANTIC, LANG.SCI_FI, LANG.COMPETITION,
            LANG.SPORTS, LANG.STAND_UP, LANG.TALK_SHOW, LANG.TELENOVELA,
            LANG.THRILLER, LANG.MILITARY, LANG.WESTERN, LANG.BIOGRAPHICAL
        ]

        if settings.as_bool(SETTINGS.EXPLICIT_CONTENT):
            genres = genres + explicit_genres
        genre_pairs = {}
        lang_genres = []
        for genre in genres:
            lang_genre = get_string(genre)
            api_genre = api_genres[genre]
            genre_pairs[lang_genre] = api_genre
            lang_genres.append(lang_genre)
        lang_genres.sort()
        with self.start_directory(self.handle):
            for lang_genre in lang_genres:
                DirectoryItem(title=lang_genre,
                              url=router_url_from_string(
                                  ROUTE.FILTER, collection, FILTER_TYPE.GENRE,
                                  genre_pairs[lang_genre]))(self.handle)
Пример #4
0
    def genre_menu(self, collection):
        genres = [
            LANG.ACTION, LANG.ANIMATED, LANG.ADVENTURE, LANG.DOCUMENTARY,
            LANG.DRAMA, LANG.FANTASY, LANG.HISTORICAL, LANG.HORROR, LANG.MUSIC,
            LANG.IMAX, LANG.CATASTROPHIC, LANG.COMEDY, LANG.SHORT, LANG.CRIME,
            LANG.MUSICAL, LANG.MYSTERIOUS, LANG.EDUCATIONAL, LANG.FAIRYTALE,
            LANG.PSYCHOLOGICAL, LANG.JOURNALISTIC, LANG.REALITY, LANG.TRAVEL,
            LANG.FAMILY, LANG.ROMANTIC, LANG.SCI_FI, LANG.COMPETITION,
            LANG.SPORTS, LANG.STAND_UP, LANG.TALK_SHOW, LANG.TELENOVELA,
            LANG.THRILLER, LANG.MILITARY, LANG.WESTERN, LANG.BIOGRAPHICAL
        ]

        if settings.as_bool(SETTINGS.EXPLICIT_CONTENT):
            genres = genres + explicit_genres
        genres = [{
            'lang_id': genre,
            'string': get_string(genre)
        } for genre in genres]
        genres.sort(key=operator.itemgetter('string'))
        with self.start_directory(self.handle):
            for genre in genres:
                DirectoryItem(title=genre.get('string'),
                              url=router_url_from_string(
                                  ROUTE.FILTER, collection, FILTER_TYPE.GENRE,
                                  Url.encode_param(
                                      [api_genres[genre.get('lang_id')]]),
                                  ORDER.DESCENDING))(self.handle)
 def select_episode(self, collection, media_id, season_id):
     logger.debug('Showing episode list')
     MainMenuFolderItem(url=router_url_from_string(ROUTE.CLEAR_PATH))(
         self.handle)
     episode_list = self.get_season(int(season_id)).get('episodes')
     if episode_list:
         list_items = [
             movie.build() for movie in self.build_episode_list_gui(
                 media_id, episode_list, season_id)
         ]
         self.render(collection, list_items)
Пример #6
0
 def a_to_z_submenu(self, collection, previous_letter,
                    previous_letter_count):
     import string
     filter_type = FILTER_TYPE.STARTS_WITH
     letter_counts = self._on_a_to_z_menu(
         collection, filter_type,
         [previous_letter + c for c in string.ascii_lowercase])
     with self.start_directory(self.handle):
         MainMenuFolderItem(url=router_url_from_string(ROUTE.CLEAR_PATH))(
             self.handle)
         SearchItem(title=self._a_to_z_title(
             get_string(LANG.SEARCH_FOR_LETTERS).format(
                 letters=previous_letter.upper()), previous_letter_count),
                    url=router_url_from_string(
                        ROUTE.FILTER, collection, filter_type,
                        Url.encode_param([previous_letter]),
                        ORDER.ASCENDING))(self.handle)
         self._a_to_z_submenu_items(collection, filter_type,
                                    previous_letter, letter_counts,
                                    previous_letter_count)
Пример #7
0
 def media_menu(self, collection):
     with self.start_directory(self.handle):
         DirectoryItem(title=get_string(LANG.POPULAR),
                       url=router_url_from_string(ROUTE.POPULAR,
                                                  collection))(self.handle)
         DirectoryItem(title=get_string(LANG.NEWS),
                       url=router_url_from_string(
                           ROUTE.SORT, collection, SORT_TYPE.AIRED,
                           ORDER.DESCENDING))(self.handle)
         DirectoryItem(title=get_string(LANG.LAST_ADDED),
                       url=router_url_from_string(
                           ROUTE.SORT, collection, SORT_TYPE.DATE_ADDED,
                           ORDER.DESCENDING))(self.handle)
         DirectoryItem(title=get_string(LANG.A_Z),
                       url=self._url_for(self.a_to_z_menu,
                                         collection))(self.handle)
         DirectoryItem(title=get_string(LANG.GENRE),
                       url=self._url_for(self.genre_menu,
                                         collection))(self.handle)
         self.add_extra_items(collection)
    def build(self):
        """Creates the ListItem together with metadata."""
        item = xbmcgui.ListItem(
            label=self._title,
            path=self._url,
        )
        menu = []

        if self._art:
            # Without this it clutters the logs with:
            # CreateLoader - unsupported protocol(plugin) in plugin://plugin.video.stream-cinema-2/select_stream/5eb4691439a9578cbf25d7f4
            # InputStream: Error opening, plugin://plugin.video.stream-cinema-2/select_stream/5eb4691439a9578cbf25d7f4
            # Kodi for some reason tries to load the Art from the movie.
            # We have to set only some attributes of the Art.
            item.setArt({
                'fanart': self._art.get('fanart'),
                'poster': self._art.get('poster'),
            })
        if self._info_labels:
            item.setInfo('video', self._info_labels)
        if self._stream_info:
            menu.append((get_string(30404),
                         'PlayMedia({}?force=true)'.format(self._url)))
            for key, value in self._stream_info.items():
                item.addStreamInfo(key, value)
        if self._services:
            item.setUniqueIDs({'imdb': 'tt' + str(self._services.get('imdb'))},
                              'imdb')

        item.setProperty('IsPlayable', 'true')

        logger.debug(router_url_from_string(ROUTE.ADD_TO_LIBRARY))

        if settings[SETTINGS.MOVIE_LIBRARY_FOLDER] != '':
            menu.append((get_string(LANG.ADD_TO_LIBRARY), "RunPlugin(%s)" %
                         router_url_from_string(ROUTE.ADD_TO_LIBRARY)))

        item.addContextMenuItems(menu)

        return self._url, item, self.DIRECTORY,
 def select_season(self, collection, media_id):
     logger.debug('Showing season list')
     MainMenuFolderItem(url=router_url_from_string(ROUTE.CLEAR_PATH))(
         self.handle)
     media = self._on_media_selected(collection, media_id)
     self.set_cached_media(media)
     season_list = API.get_source(media).get('seasons')
     if season_list:
         list_items = [
             movie.build() for movie in self.build_season_list_gui(
                 collection, media_id, season_list)
         ]
         self.render(collection, list_items)
Пример #10
0
 def media_menu(self, collection):
     with self.start_directory(self.handle):
         SearchItem(url=self._router.url_for(self.search, collection))(
             self.handle)
         DirectoryItem(title=get_string(30211),
                       url=router_url_from_string(ROUTE.POPULAR,
                                                  collection))(self.handle)
         DirectoryItem(title=get_string(30210),
                       url=self._url_for(self.a_to_z_menu,
                                         collection))(self.handle)
         DirectoryItem(title=get_string(30209),
                       url=self._url_for(self.genre_menu,
                                         collection))(self.handle)
Пример #11
0
 def main_menu(self):
     logger.debug('Rendering main menu')
     with self.start_directory(self.handle):
         SearchItem(url=self._router.url_for(self.search, COLLECTION.ALL))(
             self.handle)
         DirectoryItem(title=get_string(LANG.NEWS),
                       url=router_url_from_string(
                           ROUTE.SORT, COLLECTION.ALL, SORT_TYPE.AIRED,
                           ORDER.DESCENDING))(self.handle)
         DirectoryItem(title=get_string(LANG.LAST_ADDED),
                       url=router_url_from_string(
                           ROUTE.SORT, COLLECTION.ALL, SORT_TYPE.DATE_ADDED,
                           ORDER.DESCENDING))(self.handle)
         MoviesItem(
             url=self._router.url_for(self.media_menu, COLLECTION.MOVIES))(
                 self.handle)
         TvShowsItem(url=self._router.url_for(
             self.media_menu, COLLECTION.TV_SHOWS))(self.handle)
         WatchHistoryItem(url=router_url_from_string(ROUTE.WATCHED))(
             self.handle)
         SettingsItem(
             url=self._router.url_for(self.command, COMMAND.OPEN_SETTINGS))(
                 self.handle)
     return
 def csfd_tips(self, collection):
     logger.debug('CSFD tips search opened')
     with DirectoryRenderer.start_directory(self.handle,
                                            as_type=collection):
         for tip in get_csfd_tips():
             name = tip[0][:-7]
             name_quoted = tip[0][:-7].replace(' ', '%20')
             year = tip[0][-7:]
             year = year[2:-1]
             tip_joined = STRINGS.TITLE_GENRE_YEAR.format(title=name,
                                                          genre=tip[1],
                                                          year=year)
             info_labels = {'title': name, 'year': int(year)}
             MediaItem(title=tip_joined,
                       url=router_url_from_string(ROUTE.SEARCH_CSFD_ITEM,
                                                  collection,
                                                  Url.quote(name_quoted)),
                       info_labels=info_labels)(self.handle)
Пример #13
0
    def _a_to_z_submenu_items(self, collection, filter_type, previous_letter,
                              letter_counts, previous_letter_count):
        import string
        for c in string.ascii_lowercase:
            letters = previous_letter + c
            count = letter_counts.get(letters)

            if count > 0:
                if count <= a_z_threshold_options[settings.as_int(
                        SETTINGS.A_Z_THRESHOLD)]:
                    url = router_url_from_string(ROUTE.FILTER, collection,
                                                 filter_type,
                                                 Url.encode_param([letters]),
                                                 ORDER.ASCENDING)
                else:
                    url = self._url_for(self.a_to_z_submenu, collection,
                                        letters, previous_letter_count)
                DirectoryItem(title=self._a_to_z_title(letters.upper(), count),
                              url=url)(self.handle)
Пример #14
0
 def a_to_z_menu(self, collection):
     import string
     filter_type = FILTER_TYPE.STARTS_WITH
     zero_nine = [i for i in range(10)]
     _0_9 = get_string(LANG.ZERO_NINE)
     letter_counts = self._on_a_to_z_menu(
         collection, filter_type,
         [c for c in string.ascii_lowercase] + zero_nine)
     with self.start_directory(self.handle):
         DirectoryItem(title=self._a_to_z_title(
             _0_9, sum([letter_counts[str(i)] for i in range(10)])),
                       url=router_url_from_string(
                           ROUTE.FILTER, collection, filter_type,
                           Url.encode_param(zero_nine),
                           ORDER.ASCENDING))(self.handle)
         for c in string.ascii_lowercase:
             letter_count = letter_counts.get(c)
             DirectoryItem(title=self._a_to_z_title(c.upper(),
                                                    letter_count),
                           url=self._url_for(self.a_to_z_submenu,
                                             collection, c,
                                             letter_count))(self.handle)
Пример #15
0
 def replace_route(self, *args):
     self.replace(router_url_from_string(*args))
 def next_page_item(collection, pagination):
     body = json.dumps(pagination['body'])
     return DirectoryItem(
         title=MediaListRenderer.next_page_title(pagination['page'], pagination['pageCount']),
         url=router_url_from_string(ROUTE.NEXT_PAGE, collection, Url.quote_plus(pagination['next']), Url.encode_param(body)))
Пример #17
0
 def add_extra_items(self, collection):
     if collection == COLLECTION.MOVIES:
         DirectoryItem(title=get_string(LANG.CSFD_TIPS),
                       url=router_url_from_string(ROUTE.CSFD_TIPS,
                                                  collection))(self.handle)
Пример #18
0
 def next_page_item(self, media_list):
     return DirectoryItem(
         title=self.next_page_title(media_list['page'],
                                    media_list['pageCount']),
         url=router_url_from_string(ROUTE.NEXT_PAGE, self.get_collection(),
                                    Url.quote_plus(media_list['next'])))
Пример #19
0
 def replace_route(self, *args):
     xbmcplugin.endOfDirectory(self.handle, cacheToDisc=False)
     self.replace(router_url_from_string(*args))
Пример #20
0
 def go_to_route(self, *args):
     self.go(router_url_from_string(*args))