Пример #1
0
 def play_episode_by_whatson_id(self, whatson_id):
     """Play an episode of a program given the whatson_id"""
     video = self._apihelper.get_single_episode(whatson_id=whatson_id)
     if not video:
         log_error('Play episode by whatson_id failed, whatson_id {whatson_id}', whatson_id=whatson_id)
         ok_dialog(message=localize(30954))
         end_of_directory()
         return
     self.play(video)
Пример #2
0
 def play_upnext(self, video_id):
     """Play the next episode of a program by video_id"""
     video = self._apihelper.get_single_episode(video_id=video_id)
     if not video:
         log_error('Play Up Next with video_id {video_id} failed', video_id=video_id)
         ok_dialog(message=localize(30954))
         end_of_directory()
         return
     self.play(video)
Пример #3
0
 def play_latest_episode(self, program):
     """A hidden feature in the VRT NU add-on to play the latest episode of a program"""
     video = self._apihelper.get_latest_episode(program)
     if not video:
         log_error('Play latest episode failed, program {program}', program=program)
         ok_dialog(message=localize(30954))
         end_of_directory()
         return
     self.play(video)
Пример #4
0
 def play_whatson(self, whatson_id):
     ''' Play a video by whatson_id '''
     video = self._apihelper.get_single_episode(whatson_id)
     if not video:
         log_error('Play by whatson_id {id} failed', id=whatson_id)
         ok_dialog(message=localize(30954))
         end_of_directory()
         return
     self.play(video)
Пример #5
0
 def play(video):
     """A wrapper for playing video items"""
     from tokenresolver import TokenResolver
     from streamservice import StreamService
     _tokenresolver = TokenResolver()
     _streamservice = StreamService(_tokenresolver)
     stream = _streamservice.get_stream(video)
     if stream is None:
         end_of_directory()
         return
     play(stream, video.get('listitem'))
Пример #6
0
 def play_episode_by_air_date(self, channel, start_date, end_date):
     """Play an episode of a program given the channel and the air date in iso format (2019-07-06T19:35:00)"""
     video = self._apihelper.get_episode_by_air_date(channel, start_date, end_date)
     if video and video.get('errorlabel'):
         ok_dialog(message=localize(30986, title=video.get('errorlabel')))
         end_of_directory()
         return
     if not video:
         log_error('Play episode by air date failed, channel {channel}, start_date {start}', channel=channel, start=start_date)
         ok_dialog(message=localize(30954))
         end_of_directory()
         return
     self.play(video)
Пример #7
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 _handle_bad_stream_error(protocol, code=None, reason=None):
     """Show a localized error message in Kodi GUI for a failing VRT NU stream based on protocol: hls, hls_aes, mpeg_dash)
         message: VRT NU stream <stream_type> problem, try again with (InputStream Adaptive) (and) (DRM) enabled/disabled:
             30959=and DRM, 30960=disabled, 30961=enabled
    """
     # HLS AES DRM failed
     if protocol == 'hls_aes' and not supports_drm():
         message = localize(30962, protocol=protocol.upper(), version=kodi_version_major())
     elif protocol == 'hls_aes' and not has_inputstream_adaptive() and not get_setting_bool('usedrm', default=True):
         message = localize(30958, protocol=protocol.upper(), component=localize(30959), state=localize(30961))
     elif protocol == 'hls_aes' and has_inputstream_adaptive():
         message = localize(30958, protocol=protocol.upper(), component='Widevine DRM', state=localize(30961))
     elif protocol == 'hls_aes' and get_setting_bool('usedrm', default=True):
         message = localize(30958, protocol=protocol.upper(), component='InputStream Adaptive', state=localize(30961))
     else:
         message = localize(30958, protocol=protocol.upper(), component='InputStream Adaptive', state=localize(30960))
     heading = 'HTTP Error {code}: {reason}'.format(code=code, reason=reason) if code and reason else None
     log_error('Unable to play stream. {error}', error=heading)
     ok_dialog(heading=heading, message=message)
     end_of_directory()
Пример #9
0
    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)
Пример #10
0
 def _handle_stream_api_error(message, video_json=None):
     ''' Show localized stream api error messages in Kodi GUI '''
     if video_json:
         log_error(video_json.get('message'))
     ok_dialog(message=message)
     end_of_directory()
Пример #11
0
 def clear(self):
     """Clear the search history"""
     self.write_history([])
     end_of_directory()
Пример #12
0
def noop():
    """The API interface to do nothing"""
    end_of_directory()
Пример #13
0
 def clear(self):
     ''' Clear the search history '''
     self.write_history([])
     end_of_directory()