def show_tvshow_menu(self, use_favorites=False):
     """The VRT NU add-on 'All programs' listing menu"""
     # My favorites menus may need more up-to-date favorites
     self._favorites.refresh(ttl=ttl('direct' if use_favorites else 'indirect'))
     self._resumepoints.refresh(ttl=ttl('direct' if use_favorites else 'indirect'))
     tvshow_items = self._apihelper.list_tvshows(use_favorites=use_favorites)
     show_listing(tvshow_items, category=30440, sort='label', content='tvshows')  # A-Z
 def show_episodes_menu(self, program, season=None):
     """The VRT NU add-on episodes listing menu"""
     self._favorites.refresh(ttl=ttl('indirect'))
     self._resumepoints.refresh(ttl=ttl('indirect'))
     episode_items, sort, ascending, content = self._apihelper.list_episodes(program=program, season=season)
     # FIXME: Translate program in Program Title
     show_listing(episode_items, category=program.title(), sort=sort, ascending=ascending, content=content, cache=False)
    def show_offline_menu(self, page=0, use_favorites=False):
        ''' The VRT NU add-on 'Soon offline' and 'My soon offline' listing menu '''
        from statichelper import realpage

        # My favorites menus may need more up-to-date favorites
        self._favorites.refresh(ttl=5 * 60 if use_favorites else 60 * 60)
        self._resumepoints.refresh(ttl=5 * 60 if use_favorites else 60 * 60)
        page = realpage(page)
        episode_items, sort, ascending, content = self._apihelper.list_episodes(
            page=page, use_favorites=use_favorites, variety='offline')

        # Add 'More...' entry at the end
        if len(episode_items) == 50:
            if use_favorites:
                offline = 'favorites_offline'
            else:
                offline = 'offline'
            episode_items.append(
                TitleItem(
                    title=localize(30300),
                    path=url_for(offline, page=page + 1),
                    art_dict=dict(thumb='DefaultYear.png'),
                    info_dict=dict(),
                ))

        show_listing(episode_items,
                     category=30022,
                     sort=sort,
                     ascending=ascending,
                     content=content,
                     cache=False)
    def show_favorites_menu(self):
        ''' The VRT NU addon 'My programs' menu '''
        self._favorites.refresh(ttl=60 * 60)
        favorites_items = [
            TitleItem(
                title=localize(30040),  # My programs
                path=url_for('favorites_programs'),
                art_dict=dict(thumb='DefaultMovieTitle.png'),
                info_dict=dict(plot=localize(30041))),
            TitleItem(
                title=localize(30046),  # My recent items
                path=url_for('favorites_recent'),
                art_dict=dict(thumb='DefaultRecentlyAddedEpisodes.png'),
                info_dict=dict(plot=localize(30047))),
            TitleItem(
                title=localize(30048),  # My soon offline
                path=url_for('favorites_offline'),
                art_dict=dict(thumb='DefaultYear.png'),
                info_dict=dict(plot=localize(30049))),
        ]

        # Only add 'My watch later' and 'Continue watching' when it has been activated
        if self._resumepoints.is_activated():
            favorites_items.append(
                TitleItem(
                    title=localize(30050),  # My watch later
                    path=url_for('resumepoints_watchlater'),
                    art_dict=dict(thumb='DefaultVideoPlaylists.png'),
                    info_dict=dict(plot=localize(30051)),
                ))
            favorites_items.append(
                TitleItem(
                    title=localize(30052),  # Continue Watching
                    path=url_for('resumepoints_continue'),
                    art_dict=dict(thumb='DefaultInProgressShows.png'),
                    info_dict=dict(plot=localize(30053)),
                ))

        if get_setting('addmymovies', 'true') == 'true':
            favorites_items.append(
                TitleItem(
                    title=localize(30042),  # My movies
                    path=url_for('categories', category='films'),
                    art_dict=dict(thumb='DefaultAddonVideo.png'),
                    info_dict=dict(plot=localize(30043))), )

        if get_setting('addmydocu', 'true') == 'true':
            favorites_items.append(
                TitleItem(
                    title=localize(30044),  # My documentaries
                    path=url_for('favorites_docu'),
                    art_dict=dict(thumb='DefaultMovies.png'),
                    info_dict=dict(plot=localize(30045))), )

        show_listing(favorites_items, category=30010,
                     cache=False)  # My favorites

        # Show dialog when no favorites were found
        if not self._favorites.titles():
            ok_dialog(heading=localize(30415), message=localize(30416))
    def show_offline_menu(self, page=0, use_favorites=False):
        """The VRT NU add-on 'Soon offline' and 'My soon offline' listing menu"""

        # My favorites menus may need more up-to-date favorites
        self._favorites.refresh(
            ttl=ttl('direct' if use_favorites else 'indirect'))
        self._resumepoints.refresh(
            ttl=ttl('direct' if use_favorites else 'indirect'))
        page = realpage(page)
        items_per_page = get_setting_int('itemsperpage', default=50)
        sort_key = 'assetOffTime'
        episode_items, sort, ascending, content = self._apihelper.list_episodes(
            page=page,
            items_per_page=items_per_page,
            use_favorites=use_favorites,
            variety='offline',
            sort_key=sort_key)

        # Add 'More...' entry at the end
        if len(episode_items) == items_per_page:
            offline = 'favorites_offline' if use_favorites else 'offline'
            episode_items.append(
                TitleItem(
                    label=localize(30300),
                    path=url_for(offline, page=page + 1),
                    art_dict=dict(thumb='DefaultYear.png'),
                    info_dict=dict(),
                ))

        show_listing(episode_items,
                     category=30022,
                     sort=sort,
                     ascending=ascending,
                     content=content,
                     cache=False)
    def show_recent_menu(self, page=0, use_favorites=False):
        """The VRT NU add-on 'Most recent' and 'My most recent' listing menu"""

        # My favorites menus may need more up-to-date favorites
        self._favorites.refresh(
            ttl=ttl('direct' if use_favorites else 'indirect'))
        self._resumepoints.refresh(
            ttl=ttl('direct' if use_favorites else 'indirect'))
        page = realpage(page)
        episode_items, sort, ascending, content = self._apihelper.list_episodes(
            page=page, use_favorites=use_favorites, variety='recent')

        # Add 'More...' entry at the end
        if len(episode_items) == get_setting_int('itemsperpage', default=50):
            recent = 'favorites_recent' if use_favorites else 'recent'
            episode_items.append(
                TitleItem(
                    label=colour(localize(30300)),
                    path=url_for(recent, page=page + 1),
                    art_dict=dict(thumb='DefaultRecentlyAddedEpisodes.png'),
                    info_dict=dict(),
                ))

        show_listing(episode_items,
                     category=30020,
                     sort=sort,
                     ascending=ascending,
                     content=content,
                     cache=False)
    def show_continue_menu(self, page=0):
        """The VRT NU add-on 'Continue waching' listing menu"""

        # Continue watching menu may need more up-to-date favorites
        self._favorites.refresh(ttl=ttl('direct'))
        self._resumepoints.refresh(ttl=ttl('direct'))
        page = realpage(page)
        episode_items, sort, ascending, content = self._apihelper.list_episodes(page=page, variety='continue')
        show_listing(episode_items, category=30054, sort=sort, ascending=ascending, content=content, cache=False)
    def show_main_menu(self):
        """The VRT NU add-on main menu"""
        # self._favorites.refresh(ttl=ttl('indirect'))
        main_items = []

        # Only add 'My favorites' when it has been activated
        if self._favorites.is_activated():
            main_items.append(TitleItem(
                label=localize(30010),  # My favorites
                path=url_for('favorites_menu'),
                art_dict=dict(thumb='DefaultFavourites.png'),
                info_dict=dict(plot=localize(30011)),
            ))

        main_items.extend([
            TitleItem(label=localize(30012),  # All programs
                      path=url_for('programs'),
                      art_dict=dict(thumb='DefaultMovieTitle.png'),
                      info_dict=dict(plot=localize(30013))),
            TitleItem(label=localize(30014),  # Categories
                      path=url_for('categories'),
                      art_dict=dict(thumb='DefaultGenre.png'),
                      info_dict=dict(plot=localize(30015))),
            TitleItem(label=localize(30016),  # Channels
                      path=url_for('channels'),
                      art_dict=dict(thumb='DefaultTags.png'),
                      info_dict=dict(plot=localize(30017))),
            TitleItem(label=localize(30018),  # Live TV
                      path=url_for('livetv'),
                      art_dict=dict(thumb='DefaultTVShows.png'),
                      info_dict=dict(plot=localize(30019))),
            TitleItem(label=localize(30020),  # Recent items
                      path=url_for('recent'),
                      art_dict=dict(thumb='DefaultRecentlyAddedEpisodes.png'),
                      info_dict=dict(plot=localize(30021))),
            TitleItem(label=localize(30022),  # Soon offline
                      path=url_for('offline'),
                      art_dict=dict(thumb='DefaultYear.png'),
                      info_dict=dict(plot=localize(30023))),
            TitleItem(label=localize(30024),  # Featured content
                      path=url_for('featured'),
                      art_dict=dict(thumb='DefaultCountry.png'),
                      info_dict=dict(plot=localize(30025))),
            TitleItem(label=localize(30026),  # TV guide
                      path=url_for('tvguide'),
                      art_dict=dict(thumb='DefaultAddonTvInfo.png'),
                      info_dict=dict(plot=localize(30027))),
            TitleItem(label=localize(30028),  # Search
                      path=url_for('search'),
                      art_dict=dict(thumb='DefaultAddonsSearch.png'),
                      info_dict=dict(plot=localize(30029))),
        ])
        show_listing(main_items, cache=False)  # No category
        self._version_check()
 def show_category_menu(self, category=None):
     """The VRT NU add-on 'Categories' listing menu"""
     if category:
         self._favorites.refresh(ttl=ttl('indirect'))
         self._resumepoints.refresh(ttl=ttl('indirect'))
         tvshow_items = self._apihelper.list_tvshows(category=category)
         from data import CATEGORIES
         category_msgctxt = find_entry(CATEGORIES, 'id', category).get('msgctxt')
         show_listing(tvshow_items, category=category_msgctxt, sort='label', content='tvshows')
     else:
         category_items = self._apihelper.list_categories()
         show_listing(category_items, category=30014, sort='unsorted', content='files')  # Categories
 def show_featured_menu(self, feature=None):
     """The VRT NU add-on 'Featured content' listing menu"""
     if feature:
         self._favorites.refresh(ttl=ttl('indirect'))
         self._resumepoints.refresh(ttl=ttl('indirect'))
         tvshow_items = self._apihelper.list_tvshows(feature=feature)
         from data import FEATURED
         feature_msgctxt = find_entry(FEATURED, 'id', feature).get('msgctxt')
         show_listing(tvshow_items, category=feature_msgctxt, sort='label', content='tvshows', cache=False)
     else:
         featured_items = self._apihelper.list_featured()
         show_listing(featured_items, category=30024, sort='label', content='files')
 def show_favorites_docu_menu(self):
     ''' The VRT NU add-on 'My documentaries' listing menu '''
     self._favorites.refresh(ttl=60 * 60)
     self._resumepoints.refresh(ttl=60 * 60)
     episode_items, sort, ascending, content = self._apihelper.list_episodes(
         category='docu', season='allseasons', programtype='oneoff')
     show_listing(episode_items,
                  category=30044,
                  sort=sort,
                  ascending=ascending,
                  content=content,
                  cache=False)
 def show_favorites_music_menu(self):
     """The VRT NU add-on 'My music' listing menu"""
     self._favorites.refresh(ttl=ttl('indirect'))
     self._resumepoints.refresh(ttl=ttl('indirect'))
     episode_items, sort, ascending, content = self._apihelper.list_episodes(
         category='muziek', season='allseasons', programtype='oneoff')
     show_listing(episode_items,
                  category=30046,
                  sort=sort,
                  ascending=ascending,
                  content=content,
                  cache=False)
def index():
    """ Show the main menu """
    listing = [
        TitleItem(
            title=localize(30010),  # A-Z
            path=plugin.url_for(iptv_play),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon()),
            info_dict=dict(plot=localize(30228), ),
            is_playable=True),
        TitleItem(
            title=localize(30011),  # A-Z
            path=plugin.url_for(browse_product, 'discover'),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon())),
        TitleItem(
            title=localize(30012),  # A-Z
            path=plugin.url_for(
                browse_collection,
                'playlists::d554f1ca-5a8a-4d5c-a562-419185d57979'),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon())),
        TitleItem(
            title=localize(30013),  # A-Z
            path=plugin.url_for(browse_product, 'events'),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon()))
    ]

    if has_addon('plugin.video.youtube'):
        listing.append(
            TitleItem(
                title='YouTube',  # A-Z
                path=
                'plugin://plugin.video.youtube/channel/UCblfuW_4rakIf2h6aqANefA/',
                art_dict=dict(icon='DefaultMovieTitle.png',
                              fanart=addon_fanart(),
                              poster=addon_icon())))

    listing.append(
        TitleItem(
            title=localize(30014),  # A-Z
            path=plugin.url_for(search),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon())))

    show_listing(listing, content='videos', sort=['unsorted'])
    def show_tvguide(self, date=None, channel=None):
        """Offer a menu depending on the information provided"""

        if not date and not channel:
            date_items = self.get_date_items()
            show_listing(date_items, category=30026,
                         content='files')  # TV guide

        elif not channel:
            channel_items = self.get_channel_items(date=date)
            entry = find_entry(RELATIVE_DATES, 'id', date)
            date_name = localize(entry.get('msgctxt')) if entry else date
            show_listing(channel_items, category=date_name)

        elif not date:
            date_items = self.get_date_items(channel=channel)
            channel_name = find_entry(CHANNELS, 'name', channel).get('label')
            show_listing(date_items,
                         category=channel_name,
                         content='files',
                         selected=7)

        else:
            episode_items = self.get_episode_items(date, channel)
            channel_name = find_entry(CHANNELS, 'name', channel).get('label')
            entry = find_entry(RELATIVE_DATES, 'id', date)
            date_name = localize(entry.get('msgctxt')) if entry else date
            show_listing(episode_items,
                         category='%s / %s' % (channel_name, date_name),
                         content='episodes',
                         cache=False)
 def show_channels_menu(self, channel=None):
     """The VRT NU add-on 'Channels' listing menu"""
     if channel:
         from tvguide import TVGuide
         self._favorites.refresh(ttl=ttl('indirect'))
         self._resumepoints.refresh(ttl=ttl('indirect'))
         channel_items = self._apihelper.list_channels(channels=[channel])  # Live TV
         channel_items.extend(TVGuide().get_channel_items(channel=channel))  # TV guide
         channel_items.extend(self._apihelper.list_youtube(channels=[channel]))  # YouTube
         channel_items.extend(self._apihelper.list_tvshows(channel=channel))  # TV shows
         from data import CHANNELS
         channel_name = find_entry(CHANNELS, 'name', channel).get('label')
         show_listing(channel_items, category=channel_name, sort='unsorted', content='tvshows', cache=False)  # Channel
     else:
         channel_items = self._apihelper.list_channels(live=False)
         show_listing(channel_items, category=30016, cache=False)
    def show_continue_menu(self, page=0):
        ''' The VRT NU add-on 'Continue waching' listing menu '''
        from statichelper import realpage

        # Continue watching menu may need more up-to-date favorites
        self._favorites.refresh(ttl=5 * 60)
        self._resumepoints.refresh(ttl=5 * 60)
        page = realpage(page)
        episode_items, sort, ascending, content = self._apihelper.list_episodes(
            page=page, variety='continue')
        show_listing(episode_items,
                     category=30052,
                     sort=sort,
                     ascending=ascending,
                     content=content,
                     cache=False)
Example #17
0
    def search(self, keywords=None, page=None):
        ''' The VRT NU add-on Search functionality and results '''
        if keywords is None:
            keywords = get_search_string()

        if not keywords:
            end_of_directory()
            return

        from statichelper import realpage
        page = realpage(page)

        self.add(keywords)

        from apihelper import ApiHelper
        search_items, sort, ascending, content = ApiHelper(
            self._favorites, self._resumepoints).list_search(keywords,
                                                             page=page)
        if not search_items:
            ok_dialog(heading=localize(30135),
                      message=localize(30136, keywords=keywords))
            end_of_directory()
            return

        # Add 'More...' entry at the end
        from helperobjects import TitleItem
        if len(search_items) == 50:
            search_items.append(
                TitleItem(
                    title=localize(30300),
                    path=url_for('search_query',
                                 keywords=keywords,
                                 page=page + 1),
                    art_dict=dict(thumb='DefaultAddonSearch.png'),
                    info_dict=dict(),
                ))

        self._favorites.refresh(ttl=60 * 60)
        show_listing(search_items,
                     category=30032,
                     sort=sort,
                     ascending=ascending,
                     content=content,
                     cache=False)
 def show_featured_menu(self, feature=None):
     """The VRT NU add-on 'Featured content' listing menu"""
     if feature:
         self._favorites.refresh(ttl=ttl('indirect'))
         self._resumepoints.refresh(ttl=ttl('indirect'))
         programs = None
         sort = 'label'
         content = 'tvshows'
         ascending = True
         if feature.startswith('jcr_'):
             media = self._apihelper.get_featured_media_from_web(
                 feature.split('jcr_')[1])
             if media.get('mediatype') == 'episodes':
                 variety = 'featured.{name}'.format(name=media.get(
                     'name').strip().lower().replace(' ', '_'))
                 media_items, sort, ascending, content = self._apihelper.list_episodes(
                     whatson_id=media.get('medialist'), variety=variety)
             elif media.get('mediatype') == 'tvshows':
                 feature = None
                 media_items = self._apihelper.list_tvshows(
                     feature=feature, programs=media.get('medialist'))
         else:
             media_items = self._apihelper.list_tvshows(feature=feature,
                                                        programs=programs)
         from data import FEATURED
         feature_msgctxt = None
         feature = find_entry(FEATURED, 'id', feature)
         if feature:
             feature_msgctxt = feature.get('msgctxt')
         show_listing(media_items,
                      category=feature_msgctxt,
                      sort=sort,
                      ascending=ascending,
                      content=content,
                      cache=False)
     else:
         featured_items = self._apihelper.list_featured()
         show_listing(featured_items,
                      category=30024,
                      sort='label',
                      content='files')
    def search_menu(self):
        """Main search menu"""
        from helperobjects import TitleItem
        menu_items = [
            TitleItem(
                label=localize(30424),  # New search...
                path=url_for('search_query'),
                art_dict=dict(thumb='DefaultAddonsSearch.png'),
                info_dict=dict(plot=localize(30425)),
                is_playable=False,
            )
        ]

        history = self.read_history()
        for keywords in history:
            menu_items.append(TitleItem(
                label=keywords,
                path=url_for('search_query', keywords=keywords),
                is_playable=False,
                context_menu=[(
                    localize(30033),  # Edit
                    'RunPlugin(%s)' % url_for('edit_search', keywords=keywords),
                ), (
                    localize(30030),  # Remove
                    'RunPlugin(%s)' % url_for('remove_search', keywords=keywords),
                )],
            ))

        if history:
            menu_items.append(TitleItem(
                label=localize(30426),  # Clear search history
                path=url_for('clear_search'),
                info_dict=dict(plot=localize(30427)),
                art_dict=dict(thumb='icons/infodialogs/uninstall.png'),
                is_playable=False,
            ))

        show_listing(menu_items, category=30031, cache=False)
    def search(self, keywords=None, page=0, edit=False):
        """The VRT NU add-on Search functionality and results"""
        if keywords is None or edit is True:
            keywords = get_search_string(keywords)

        if not keywords:
            end_of_directory()
            return
        if edit is True:
            container_update(url_for('search_query', keywords=keywords))
            return

        from apihelper import ApiHelper
        from utils import realpage
        page = realpage(page)

        self.add(keywords)

        search_items, sort, ascending, content = ApiHelper(self._favorites, self._resumepoints).list_search(keywords, page=page)
        if not search_items:
            ok_dialog(heading=localize(30135), message=localize(30136, keywords=keywords))
            end_of_directory()
            return

        # Add 'More…' entry at the end
        from helperobjects import TitleItem
        if len(search_items) == get_setting_int('itemsperpage', default=50):
            search_items.append(TitleItem(
                label=colour(localize(30300)),  # More…
                path=url_for('search_query', keywords=keywords, page=page + 1),
                art_dict=dict(thumb='DefaultAddonSearch.png'),
                info_dict={},
            ))

        self._favorites.refresh(ttl=ttl('indirect'))
        show_listing(search_items, category=30032, sort=sort, ascending=ascending, content=content, cache=False)
 def show_livetv_menu(self):
     """The VRT NU add-on 'Live TV' listing menu"""
     channel_items = self._apihelper.list_channels()
     show_listing(channel_items, category=30018, cache=False)