def make_category_list(url):
    utils.log("Making category list")
    try:
        params = utils.get_url(url)
        category = params.get('category')
        categories = comm.get_category(category)
        utils.log(categories)

        ok = True
        for c in categories.get('rows'):
            
            if c.get('layout', {}).get('itemType') == 'genre':
                genre = 'True'
            else:
                genre = 'False'
            
            url = "%s?%s" % (sys.argv[0], utils.make_url({
                                 'category': category,
                                 'genre': genre,
                                 'feed_url': c.get('feedUrl')}))
            
            thumbnail = c.get('thumbnail', '')
            listitem = xbmcgui.ListItem(label=c['name'],
                                        thumbnailImage=thumbnail)
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                             url=url,
                                             listitem=listitem,
                                             isFolder=True)

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except Exception:
        utils.handle_error('Unable to build categories list')
Exemple #2
0
def play(url):
    try:
        params = utils.get_url(url)
        v = classes.Video()
        v.parse_xbmc_url(url)

        if 'ooyalaid' in params:
            login_token = None
            if params.get('subscription_required') == 'True':
                login_token = ooyalahelper.get_user_token()

            stream_url = ooyalahelper.get_m3u8_playlist(
                params['ooyalaid'], v.live, login_token)
        else:
            stream_url = v.get_url()

        listitem = xbmcgui.ListItem(label=v.get_title(),
                                    iconImage=v.get_thumbnail(),
                                    thumbnailImage=v.get_thumbnail(),
                                    path=stream_url)

        listitem.addStreamInfo('video', v.get_kodi_stream_info())
        listitem.setInfo('video', v.get_kodi_list_item())

        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem)

    except Exception:
        utils.handle_error('Unable to play video')
Exemple #3
0
def make_entries_list(url):
    utils.log('Making entries list')
    try:
        params = utils.get_url(url)
        programs = comm.get_entries(params['feed_url'])

        ok = True
        for p in sorted(programs):
            listitem = xbmcgui.ListItem(label=p.get_list_title(),
                                        iconImage=p.get_thumbnail(),
                                        thumbnailImage=p.get_thumbnail())
            if type(p) is classes.Program:
                listitem.setInfo('video', p.get_kodi_list_item())
                listitem.setProperty('IsPlayable', 'true')

            #if hasattr(listitem, 'addStreamInfo'):
                listitem.addStreamInfo('audio', p.get_kodi_audio_stream_info())
                listitem.addStreamInfo('video', p.get_kodi_video_stream_info())

                # Build the URL for the program, including the list_info
                url = "%s?play=true&%s" % (sys.argv[0], p.make_xbmc_url())
            else:
                url = "%s?%s" % (sys.argv[0], utils.make_url({
                                 'feed_url': p.feed_url}))
            # Add the program item to the list
            isFolder = type(p) is classes.Series
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url,
                                             listitem=listitem, isFolder=isFolder,
                                             totalItems=len(programs))

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except Exception:
        utils.handle_error('Unable to fetch program list')
Exemple #4
0
def make_programs_list(url):
    try:
        params = utils.get_url(url)
        programs = comm.get_series_from_feed(params['series_url'],
                                             params['episode_count'])

        ok = True
        for p in programs:
            listitem = xbmcgui.ListItem(label=p.get_list_title(),
                                        iconImage=p.get_thumbnail(),
                                        thumbnailImage=p.get_thumbnail())
            listitem.setInfo('video', p.get_kodi_list_item())
            listitem.setProperty('IsPlayable', 'true')

            if hasattr(listitem, 'addStreamInfo'):
                listitem.addStreamInfo('audio', p.get_kodi_audio_stream_info())
                listitem.addStreamInfo('video', p.get_kodi_video_stream_info())

            # Build the URL for the program, including the list_info
            url = "%s?play=true&%s" % (sys.argv[0], p.make_xbmc_url())

            # Add the program item to the list
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                             url=url,
                                             listitem=listitem,
                                             isFolder=False,
                                             totalItems=len(programs))

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except Exception:
        utils.handle_error('Unable to fetch program list')
def make_series_list(url):
    params = utils.get_url(url)

    try:
        category = params["category"]
        series_list = comm.get_programme_from_feed(category)
        series_list.sort()

        ok = True
        for s in series_list:
            p = utils.make_url({
                'series_url': s.series_url,
                'category': category,
                'episode_count': s.num_episodes
            })
            url = "{0}?{1}".format(sys.argv[0], p)

            thumbnail = s.get_thumbnail()
            listitem = xbmcgui.ListItem(s.get_list_title(),
                                        iconImage=thumbnail,
                                        thumbnailImage=thumbnail)
            listitem.setInfo('video', {'plot': s.get_description()})

            # add the item to the media list
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                             url=url,
                                             listitem=listitem,
                                             isFolder=True)

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='tvshows')
    except Exception:
        utils.handle_error('Unable to fetch program list. '
                           'Please try again later.')
Exemple #6
0
def make_category_list(url):
    utils.log("Making category list")
    try:
        params = utils.get_url(url)
        categories = comm.get_category(params['category'])

        ok = True
        if 'children' in categories:
            for c in categories.get('children', []):
                if 'children' in c:
                    url = "%s?%s" % (sys.argv[0], utils.make_url({
                                     'category': params['category'],
                                     'section': c['name']}))
                elif 'url' in c:
                    url = "%s?%s" % (sys.argv[0], utils.make_url({
                                     'entries_url': c['url']}))
                else:
                    continue

                # If no thumbnail, make it an empty string as None makes
                # XBMC v12 with a TypeError must be unicode or str
                thumbnail = c.get('thumbnail', '')
                listitem = xbmcgui.ListItem(label=c['name'],
                                            thumbnailImage=thumbnail)
                ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                 url=url,
                                                 listitem=listitem,
                                                 isFolder=True)
        else:
            # 'Coming soon' has no children
            jsonurl = categories['url']
            programs = comm.get_entries(jsonurl)
            for p in sorted(programs):
                thumbnail = p.get_thumbnail()
                listitem = xbmcgui.ListItem(label=p.get_list_title(),
                                            iconImage=thumbnail,
                                            thumbnailImage=thumbnail)
                listitem.setInfo('video', p.get_kodi_list_item())

                if hasattr(listitem, 'addStreamInfo'):
                    listitem.addStreamInfo('audio',
                                           p.get_kodi_audio_stream_info())
                    listitem.addStreamInfo('video',
                                           p.get_kodi_video_stream_info())

                # Build the URL for the program, including the list_info
                url = "%s?play=true&%s" % (sys.argv[0], p.make_xbmc_url())

                # Add the program item to the list
                ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                 url=url,
                                                 listitem=listitem,
                                                 isFolder=False,
                                                 totalItems=len(programs))

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except Exception:
        utils.handle_error('Unable to build categories list')
def play(url):
    try:
        params = utils.get_url(url)
        v = classes.Video()
        v.parse_xbmc_url(url)
        if params.get('isdummy'):
            xbmcgui.Dialog().ok(
                    'Dummy item',
                    'This item is not playable, it is used only to display '
                    'the upcoming schedule. Please check back once the match '
                    'has started. Playable matches will have "LIVE NOW" in '
                    'green next to the title.')
        if 'ooyalaid' in params:
            login_token = None
            if params.get('subscription_required') == 'True':
                login_token = ooyalahelper.get_user_token()

            stream_data = ooyalahelper.get_m3u8_playlist(params['ooyalaid'],
                                                         v.live, login_token)
        else:
            stream_data = {'stream_url': v.get_url()}

        listitem = xbmcgui.ListItem(label=v.get_title(),
                                    iconImage=v.get_thumbnail(),
                                    thumbnailImage=v.get_thumbnail(),
                                    path=stream_data.get('stream_url'))

        inputstream = drmhelper.check_inputstream(drm=v.live)
        if not inputstream:
            utils.dialog_message(
                'Failed to play stream. Please visit our website at '
                'http://aussieaddons.com/addons/afl/ for more '
                'information.')
            return

        widevine_url = stream_data.get('widevine_url')

        if inputstream and (not v.live or not widevine_url):
            listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
            listitem.setProperty('inputstream.adaptive.manifest_type', 'hls')
            listitem.setProperty('inputstream.adaptive.license_key',
                                 stream_data.get('stream_url'))
        elif v.live:
            listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
            listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd')
            listitem.setProperty('inputstream.adaptive.license_type',
                                 'com.widevine.alpha')
            listitem.setProperty('inputstream.adaptive.license_key',
                                 widevine_url +
                                 '|Content-Type=application%2F'
                                 'x-www-form-urlencoded|A{SSM}|')
        listitem.addStreamInfo('video', v.get_kodi_stream_info())
        listitem.setInfo('video', v.get_kodi_list_item())

        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem)

    except Exception:
        utils.handle_error('Unable to play video')
def main():
    params_str = sys.argv[2]
    params = utils.get_url(params_str)
    addon = xbmcaddon.Addon()
    if (len(params) == 0):
        categories.make_category_list()

    elif 'action' in params:
        action = params.get('action')

        if action in ['program_list', 'livestreams']:
            play.play(params_str)
        elif action in ['series_list']:
            if params.get('type') == 'Series':
                if params.get('dummy') == 'True':
                    return
                else:
                    programs.make_programs_list(params)
            else:
                play.play(params_str)
        elif action == 'collect_list':
            series.make_series_list(params, atoz=False)
        elif action == 'category_list':
            category = params.get('category')
            if category == 'settings':
                addon.openSettings()
            elif category == 'livestreams':
                live.make_livestreams_list()
            elif category == 'search':
                search.make_search_history_list()
            else:
                if addon.getSetting('SHOW_COLLECTIONS') == '1':
                    collect.make_collect_list(params)
                else:
                    series.make_series_list(params)
        elif action == 'searchhistory':
            if params.get('name') == 'New Search':
                search.get_search_input()
            else:
                search.make_search_list(params)
        elif action == 'removesearch':
            search.remove_from_search_history(params.get('name'))
        elif action == 'sendreport':
            utils.user_report()
        elif action == 'open_ia_settings':
            try:
                import drmhelper
                if drmhelper.check_inputstream(drm=False):
                    ia = drmhelper.get_addon()
                    ia.openSettings()
                else:
                    utils.dialog_message(
                        "Can't open inputstream.adaptive settings")
            except Exception:
                utils.dialog_message(
                    "Can't open inputstream.adaptive settings")
Exemple #9
0
    def parse_xbmc_url(self, string):
        """Parse XBMC URL

        Takes a string input which is a URL representation of the
        program object
        """
        d = utils.get_url(string)
        for k, v in d.iteritems():
            if k in vars(self):
                setattr(self, k, v)
        if self.thumb:
            self.thumb = urllib.unquote_plus(d.get('thumb'))
Exemple #10
0
def main():
    addon = xbmcaddon.Addon()
    if addon.getSetting('firstrun') == 'true':
        utils.dialog_message(
            'Welcome to the new On Demand add-on. An SBS On Demand account '
            'is now required to use this service. Please sign up at '
            'sbs.com.au or in the mobile app, then enter your details in '
            'the add-on settings.')
        comm.get_login_token()
        addon.setSetting('firstrun', 'false')
    params_str = sys.argv[2]
    params = utils.get_url(params_str)
    utils.log(str(params))
    if len(params) == 0:
        index.make_index_list()
    elif params.get('obj_type') == 'Program':
        play.play(params_str)
    elif 'feed_url' in params:
        index.make_entries_list(params)
    elif 'category' in params or params.get('item_type') in [
            'ProgramGenre', 'FilmGenre', 'Channel'
    ]:
        if params.get('category') == 'Search':
            index.make_search_history_list()
        else:
            index.make_category_list(params)
    elif 'action' in params:
        action = params.get('action')
        if action == 'favouritescategories':
            index.make_favourites_categories_list()
        elif action == 'addfavourites':
            comm.add_to_favourites(params)
        elif action == 'removefavourites':
            comm.remove_from_favourites(params)
            xbmc.executebuiltin('Container.Refresh')
        elif action == 'searchhistory':
            if params.get('name') == 'New Search':
                search.get_search_input()
            else:
                index.make_search_list(params)
        elif action == 'removesearch':
            search.remove_from_search_history(params.get('name'))
        elif action == 'sendreport':
            utils.user_report()
        elif action == 'settings':
            xbmcaddon.Addon().openSettings()
        elif action == 'logout':
            comm.clear_login_token()
        elif action == 'login':
            comm.get_login_token()
            xbmc.executebuiltin('Container.Refresh')
Exemple #11
0
 def parse_xbmc_url(self, string):
     d = utils.get_url(string)
     self.id = d.get('id')
     self.title = d.get('title')
     self.episode_title = d.get('episode_title')
     self.description = d.get('description')
     self.duration = d.get('duration')
     self.category = d.get('category')
     self.rating = d.get('rating')
     self.url = d.get('url')
     self.thumbnail = d.get('thumbnail')
     self.subfilename = d.get('subfilename')
     if 'date' in d:
         timestamp = time.mktime(
             time.strptime(d['date'], '%Y-%m-%d %H:%M:%S'))
         self.date = datetime.date.fromtimestamp(timestamp)
Exemple #12
0
 def parse_xbmc_url(self, string):
     d = utils.get_url(string)
     self.id = d.get('id')
     self.title = d.get('title')
     self.episode_title = d.get('episode_title')
     self.description = d.get('description')
     self.duration = d.get('duration')
     self.category = d.get('category')
     self.rating = d.get('rating')
     self.url = d.get('url')
     self.thumbnail = d.get('thumbnail')
     self.subfilename = d.get('subfilename')
     if 'date' in d:
         timestamp = time.mktime(time.strptime(d['date'],
                                               '%Y-%m-%d %H:%M:%S'))
         self.date = datetime.date.fromtimestamp(timestamp)
def main():
    params_str = sys.argv[2]
    params = utils.get_url(params_str)
    utils.log('Loading with params: {0}'.format(params))

    if len(params) == 0:
        index.make_list()
    elif 'category' in params:
        if params['category'] == 'Settings':
            xbmcaddon.Addon().openSettings()
        elif params['category'] == 'Team Video':
            teams.make_list()
        elif params['category'] == 'All Match Replays':
            index.make_seasons_list()
        else:
            videos.make_list(params)
    elif 'season' in params:
        rounds.make_rounds(params)
    elif 'team' in params:
        videos.make_list(params)
    elif 'round_id' in params:
        videos.make_list(params)
    elif 'title' in params:
        play.play(params_str)
    elif 'action' in params:
        if params['action'] == 'cleartoken':
            stream_auth.clear_token()
        elif params['action'] == 'sendreport':
            utils.user_report()
        elif params['action'] == 'iap_help':
            stream_auth.iap_help()
        elif params['action'] == 'open_ia_settings':
            try:
                import drmhelper
                if drmhelper.check_inputstream(drm=False):
                    ia = drmhelper.get_addon()
                    ia.openSettings()
                else:
                    utils.dialog_message(
                        "Can't open inputstream.adaptive settings")
            except Exception:
                utils.dialog_message(
                    "Can't open inputstream.adaptive settings")
Exemple #14
0
    def parse_xbmc_url(self, string):
        """Parse XBMC URL

        Takes a string input which is a URL representation of the
        program object
        """
        d = utils.get_url(string)
        self.id = d.get('id')
        self.title = d.get('title')
        self.episode_title = d.get('episode_title')
        self.description = d.get('description')
        self.duration = d.get('duration')
        self.category = d.get('category')
        self.rating = d.get('rating')
        self.url = d.get('url')
        self.thumbnail = urllib.unquote_plus(d.get('thumbnail'))
        self.subtitle_url = d.get('subtitle_url')
        self.house_number = d.get('house_number')
        self.hq = d.get('hq')
        if 'date' in d:
            timestamp = time.mktime(
                time.strptime(d['date'], '%Y-%m-%d %H:%M:%S'))
            self.date = datetime.date.fromtimestamp(timestamp)
    def parse_xbmc_url(self, string):
        """Parse XBMC URL

        Takes a string input which is a URL representation of the
        program object
        """
        d = utils.get_url(string)
        self.id = d.get('id')
        self.title = d.get('title')
        self.episode_title = d.get('episode_title')
        self.description = d.get('description')
        self.duration = d.get('duration')
        self.category = d.get('category')
        self.rating = d.get('rating')
        self.url = d.get('url')
        self.thumbnail = urllib.unquote_plus(d.get('thumbnail'))
        self.subtitle_url = d.get('subtitle_url')
        self.house_number = d.get('house_number')
        self.hq = d.get('hq')
        if 'date' in d:
            timestamp = time.mktime(time.strptime(d['date'],
                                                  '%Y-%m-%d %H:%M:%S'))
            self.date = datetime.date.fromtimestamp(timestamp)
    def parse_xbmc_url(self, string):
        """Get XBMC URL

        Takes a string input which is a URL representation of the
        program object
        """
        d = utils.get_url(string)
        if 'id' in d:
            self.id = d.get('id')
        if 'title' in d:
            self.title = d.get('title')
        if 'description' in d:
            self.description = d.get('description')
        if 'genre' in d:
            self.genre = d.get('genre')
        if 'season' in d:
            self.season = d.get('season')
        if 'duration' in d:
            self.duration = d.get('duration')
        if 'url' in d:
            self.url = urllib.unquote_plus(d.get('url'))
        if 'thumbnail' in d:
            self.thumbnail = urllib.unquote_plus(d.get('thumbnail'))
        if 'date' in d:
            ts = time.strptime(d.get('date'), '%Y-%m-%d %H:%M:%S')
            timestamp = time.mktime(ts)
            self.date = datetime.date.fromtimestamp(timestamp)
        if 'ooyalaid' in d:
            self.ooyalaid = d.get('ooyalaid')
        if 'isdummy' in d:
            self.isdummy = d.get('isdummy')
        if 'live' in d:
            self.live = d.get('live')
        if 'subscription_required' in d:
            if d.get('subscription_required') == 'True':
                self.subscription_required = True
    def parse_xbmc_url(self, string):
        """Get XBMC URL

        Takes a string input which is a URL representation of the
        program object
        """
        d = utils.get_url(string)
        if 'id' in d:
            self.id = d.get('id')
        if 'title' in d:
            self.title = d.get('title')
        if 'description' in d:
            self.description = d.get('description')
        if 'genre' in d:
            self.genre = d.get('genre')
        if 'season' in d:
            self.season = d.get('season')
        if 'duration' in d:
            self.duration = d.get('duration')
        if 'url' in d:
            self.url = urllib.unquote_plus(d.get('url'))
        if 'thumbnail' in d:
            self.thumbnail = urllib.unquote_plus(d.get('thumbnail'))
        if 'date' in d:
            ts = time.strptime(d.get('date'), '%Y-%m-%d %H:%M:%S')
            timestamp = time.mktime(ts)
            self.date = datetime.date.fromtimestamp(timestamp)
        if 'ooyalaid' in d:
            self.ooyalaid = d.get('ooyalaid')
        if 'isdummy' in d:
            self.isdummy = d.get('isdummy')
        if 'live' in d:
            self.live = d.get('live')
        if 'subscription_required' in d:
            if d.get('subscription_required') == 'True':
                self.subscription_required = True
# Add our resources/lib to the python path
addon_dir = xbmcaddon.Addon().getAddonInfo('path')
sys.path.insert(0, os.path.join(addon_dir, 'resources', 'lib'))

import categories  # noqa: E402
import play  # noqa: E402
import programs  # noqa: E402
import series  # noqa: E402

# Print our platform/version debugging information
utils.log_kodi_platform_version()

if __name__ == '__main__':
    params_str = sys.argv[2]
    params = utils.get_url(params_str)

    if (len(params) == 0):
        categories.make_category_list()
    elif 'series' in params:
        xbmcgui.Dialog().ok(
            'Outdated Favourites Link',
            'The Kodi Favourite item being accessed was created with an '
            'earlier version of the iView add-on and is no longer '
            'compatible. Please remove this link and update with a new '
            'one')
    elif 'play' in params:
        play.play(params_str)
    elif 'series_url' in params:
        programs.make_programs_list(params_str)
    elif 'category' in params:
# Add our resources/lib to the python path
addon_dir = xbmcaddon.Addon().getAddonInfo('path')
sys.path.insert(0, os.path.join(addon_dir, 'resources', 'lib'))

import categories  # noqa: E402
import play  # noqa: E402
import programs  # noqa: E402
import series  # noqa: E402

# Print our platform/version debugging information
utils.log_kodi_platform_version()

if __name__ == '__main__':
    params_str = sys.argv[2]
    params = utils.get_url(params_str)

    if (len(params) == 0):
        categories.make_category_list()
    elif 'series' in params:
        xbmcgui.Dialog().ok(
            'Outdated Favourites Link',
            'The Kodi Favourite item being accessed was created with an '
            'earlier version of the iView add-on and is no longer '
            'compatible. Please remove this link and update with a new '
            'one')
    elif 'play' in params:
        play.play(params_str)
    elif 'series_url' in params:
        programs.make_programs_list(params_str)
    elif 'category' in params:
Exemple #20
0
def make_section_list(url):
    utils.log("Making section list")
    try:
        params = utils.get_url(url)
        section = comm.get_section(params['category'], params['section'])

        ok = True
        if 'children' in section and len(section['children']) > 0:
            for s in section['children']:
                entries_url = s.get('url')
                if entries_url:
                    url = "%s?%s" % (
                        sys.argv[0],
                        utils.make_url({'entries_url': entries_url}))

                    thumbnail = s.get('thumbnail')
                    listitem = xbmcgui.ListItem(s.get('name'),
                                                iconImage=thumbnail,
                                                thumbnailImage=thumbnail)

                    listitem.setInfo('video',
                                     {'title': s.get('name'),
                                      'genre': s.get('genre'),
                                      'plot': s.get('description'),
                                      'plotoutline': s.get('description')})

                    # Add the program item to the list
                    ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                     url=url,
                                                     listitem=listitem,
                                                     isFolder=True)

        elif 'url' in section:
            # no children, so fetch children by URL
            programs = comm.get_entries(section['url'])
            for p in sorted(programs):
                thumbnail = p.get_thumbnail()
                listitem = xbmcgui.ListItem(label=p.get_list_title(),
                                            iconImage=thumbnail,
                                            thumbnailImage=thumbnail)
                listitem.setInfo('video', p.get_kodi_list_item())

                if hasattr(listitem, 'addStreamInfo'):
                    listitem.addStreamInfo('audio',
                                           p.get_kodi_audio_stream_info())
                    listitem.addStreamInfo('video',
                                           p.get_kodi_video_stream_info())

                # Build the URL for the program, including the list_info
                url = "%s?play=true&%s" % (sys.argv[0], p.make_xbmc_url())

                # Add the program item to the list
                ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                 url=url,
                                                 listitem=listitem,
                                                 isFolder=False,
                                                 totalItems=len(programs))
        else:
            utils.log("No children or url found for %s" % section)

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except Exception:
        utils.handle_error('Unable to build section list')
Exemple #21
0
 def test_get_url(self):
     url = fakes.PLUGIN_URL_STRING
     expected = fakes.PLUGIN_URL_DICT
     self.assertEqual(expected, utils.get_url(url))
Exemple #22
0
def play(url):
    try:
        params = utils.get_url(url)
        v = classes.Video()
        v.parse_kodi_url(url)
        live = v.live == 'True'
        if params.get('isdummy'):
            xbmcgui.Dialog().ok(
                'Dummy item',
                'This item is not playable, it is used only to display '
                'the upcoming schedule. Please check back once the match '
                'has started. Playable matches will have "LIVE NOW" in '
                'green next to the title.')
            return
        if live:
            media_auth_token = None
            if params.get('subscription_required') == 'True':
                media_auth_token = stream_auth.get_media_auth_token(
                    stream_auth.get_user_token(), v.video_id)
            stream_url = comm.get_stream_url(v, media_auth_token)
            stream_data = {'stream_url': str(stream_url)}
        else:
            stream_url = comm.get_bc_url(v)
            stream_data = {'stream_url': str(stream_url)}

        thumb = v.get_thumbnail()
        listitem = xbmcgui.ListItem(label=v.get_title(),
                                    path=stream_data.get('stream_url'))
        listitem.setArt({'icon': thumb, 'thumb': thumb})

        if not live:
            listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
            listitem.setProperty('inputstream.adaptive.manifest_type', 'hls')
            listitem.setProperty('inputstream.adaptive.license_key',
                                 stream_data.get('stream_url'))

        else:
            drm_helper = drmhelper.helper.DRMHelper()
            addon = drm_helper.get_addon()
            if addon:
                ia_ver = addon.getAddonInfo('version')
                kodi_ver = utils.get_kodi_major_version()
                ia_capable = False
                if kodi_ver == 18:
                    if LooseVersion(ia_ver) >= LooseVersion('2.4.3'):
                        ia_capable = True
                elif kodi_ver == 19:
                    if LooseVersion(ia_ver) >= LooseVersion('2.5.4'):
                        ia_capable = True
                if ia_capable:
                    listitem.setProperty('inputstreamaddon',
                                         'inputstream.adaptive')
                    listitem.setProperty('inputstream.adaptive.manifest_type',
                                         'hls')
                    listitem.setProperty('inputstream.adaptive.license_key',
                                         stream_data.get('stream_url'))

        listitem.addStreamInfo('video', v.get_kodi_stream_info())
        listitem.setInfo('video', v.get_kodi_list_item())

        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem)

    except Exception:
        utils.handle_error('Unable to play video')