示例#1
0
    def choose_video_stream(streams):
        stream_labels = []
        streams.sort(key=operator.itemgetter('size'),
                     reverse=settings.as_bool(SETTINGS.SORT_DESCENDING))
        audio_info_list = []
        for stream in streams:
            # Fix audio string that begins with the comma.
            audio_info = []
            for audio in stream.get('audio'):
                audio_info.append('[I][{} {} {}][/I]'.format(
                    audio.get('codec'), format(audio.get('channels'), '.1f'),
                    audio.get('language')))
            audio_info_list.append(' '.join(audio_info))
            quality = STRINGS.STREAM_TITLE_BRACKETS.format(
                stream.get('quality'))
            size = STRINGS.BOLD.format(convert_size(stream.get('size')))
            stream_labels.append([quality, size])

        table = make_table(stream_labels)
        table = append_list_items_to_nested_list_items(table, audio_info_list)

        ret = Dialog().select('Choose the stream',
                              ["   ".join(item) for item in table])
        if ret < 0:
            return None
        return streams[ret]
示例#2
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)
示例#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
        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)
示例#4
0
 def show_search_results(self, media_list, callback, *args):
     if media_list:
         num_media = media_list.get('totalCount')
         if num_media == 0:
             InfoDialog(get_string(30302)).notify()
             # if collection == COLLECTION.TV_SHOWS:
             #     self.router.back(steps=1, skip_search=True)
         else:
             if not settings.as_bool(SETTINGS.EXPLICIT_CONTENT):
                 MediaListRenderer.explicit_filter(media_list)
             if settings.as_bool(
                     SETTINGS.SHOW_RESULTS_COUNT
             ) and not MediaListRenderer.is_same_list(self.router):
                 pagination = media_list.get('pagination')
                 first_page = pagination.get(
                     'page') == 1 if pagination else True
                 if first_page:
                     InfoDialog(
                         get_string(30303).format(
                             number=str(num_media))).notify()
             return callback(media_list, *args)
 def show_search_results(self, collection, media_list):
     if media_list:
         num_media = media_list.get('totalCount')
         if num_media == 0:
             InfoDialog(get_string(30302)).notify()
             # if collection == COLLECTION.TV_SHOWS:
             #     self.router.back(steps=1, skip_search=True)
         else:
             if not settings.as_bool(SETTINGS.EXPLICIT_CONTENT):
                 self.vulgar_filter(media_list)
             self.render_media_list(collection, media_list)
             if not self.renderers[collection].is_same_list():
                 InfoDialog(get_string(30303).format(number=str(num_media))).notify()
    def choose_video_stream(streams):
        stream_labels = []
        streams.sort(key=operator.itemgetter('size'),
                     reverse=settings.as_int(SETTINGS.FILE_SIZE_SORT))
        audio_info_list = []
        for stream in streams:
            # Fix audio string that begins with the comma.
            audio_info = []
            for audio in stream.get('audio'):
                audio_info.append(
                    STRINGS.AUDIO_INFO.format(
                        audio.get('codec'),
                        format(audio.get('channels'), '.1f'),
                        audio.get('language')))
            audio_info_list.append(' '.join(audio_info))
            quality = STRINGS.STREAM_TITLE_BRACKETS.format(
                stream.get('quality'))
            size = STRINGS.BOLD.format(convert_size(stream.get('size')))
            bitrate = STRINGS.STREAM_BITRATE_BRACKETS.format(
                convert_bitrate(stream.get('bitrate'))) if settings.as_bool(
                    SETTINGS.SHOW_BITRATE) else ''
            codec = STRINGS.STREAM_TITLE_BRACKETS.format(
                codecs[stream.get('codec')]) if settings.as_bool(
                    SETTINGS.SHOW_CODEC) else ''
            duration = STRINGS.BOLD.format(
                str(datetime.timedelta(
                    seconds=int(stream.get('duration'))))) if settings.as_bool(
                        SETTINGS.SHOW_DURATION) else ''
            stream_labels.append([quality, codec, size, duration, bitrate])

        table = make_table(stream_labels)
        table = append_list_items_to_nested_list_items(table, audio_info_list)

        ret = Dialog().select(
            get_string(LANG.CHOOSE_STREAM),
            [STRINGS.TABLE_SPACES.join(item) for item in table])
        if ret < 0:
            return None
        return streams[ret]