Beispiel #1
0
def website_entry(params):
    """
    website_entry is the bridge between the
    simpleplegin behavior and each webiste files
    """
    if 'item_id' in params:
        params['module_name'] = params.item_id
        params['module_path'] = params.item_path
        params['next'] = 'root'

    website = utils.get_module(params)

    # Let's go to the website python file ...
    return website.website_entry(params)
Beispiel #2
0
def download_video(params):
    # Here we only have the webpage link of the video
    # We have to call get_video_url function from the module
    # to get the final video URL
    params['next'] = 'replay_entry'

    # Legacy fix (il faudrait remplacer channel_name par
    # module_name dans tous les .py des chaines)
    params['channel_name'] = params.module_name

    channel = utils.get_module(params)

    params['next'] = 'download_video'
    url_video = channel.get_video_url(params)

    #  Now that we have video URL we can try to download this one
    YDStreamUtils = __import__('YDStreamUtils')
    YDStreamExtractor = __import__('YDStreamExtractor')

    quality_string = {
        'SD': 0,
        '720p': 1,
        '1080p': 2,
        'Highest available': 3
    }

    vid = YDStreamExtractor.getVideoInfo(
        url_video,
        quality=quality_string[common.PLUGIN.get_setting('dl_quality')],
        resolve_redirects=True
    )

    path = common.PLUGIN.get_setting('dl_folder')
    path = path.decode(
        "utf-8").encode(common.FILESYSTEM_CODING)

    with YDStreamUtils.DownloadProgress() as prog:
        try:
            YDStreamExtractor.setOutputCallback(prog)
            YDStreamExtractor.handleDownload(
                vid,
                bg=common.PLUGIN.get_setting('dl_background'),
                path=path
            )
        finally:
            YDStreamExtractor.setOutputCallback(None)
    return None
Beispiel #3
0
def start_live_tv_stream(params):
    """
    Once the user chooses a Live TV channel
    start_live_tv_stream does the bridge in the channel file
    to load the streaming media
    """

    # Legacy fix (il faudrait remplacer channel_name par
    # module_name dans tous les .py des chaines)
    params['channel_name'] = params.module_name

    channel = utils.get_module(params)

    # Fix tempo pour le XMLTV de France
    if "'fr'," in params.module_path:
        return channel.start_live_tv_stream(params)
    else:
        return channel.get_video_url(params)
Beispiel #4
0
def replay_entry(params):
    """
    replay_entry is the bridge between the
    simpleplegin behavior and each channel files
    """
    if 'item_id' in params:
        params['module_name'] = params.item_id  # w9
        module_path = eval(params.item_path)
        module_path.pop()
        module_path.append(skeleton.CHANNELS[params.module_name])

        # ['root', 'channels', 'fr', '6play']
        params['module_path'] = str(module_path)
        params['next'] = 'replay_entry'

    channel = utils.get_module(params)

    # Legacy fix (il faudrait remplacer channel_name par
    # module_name dans tous les .py des chaines)
    params['channel_name'] = params.module_name

    # Let's go to the channel python file ...
    return channel.channel_entry(params)
Beispiel #5
0
def build_live_tv_menu(params):
    """
    build_live_tv_menu asks each channel for current live TV
    information and display the concatenation of this to Kodi
    """
    folder_path = eval(params.item_path)

    country = folder_path[-1]
    if country == "fr":
        return live_tv_fr.build_live_tv_menu(params)

    else:

        # First we sort channels
        menu = []
        for channel in eval(params.item_skeleton):
            channel_name = channel[0]
            # If channel isn't disable
            if common.PLUGIN.get_setting(channel_name):
                # Get order value in settings file
                channel_order = common.PLUGIN.get_setting(
                    channel_name + '.order')
                channel_path = list(folder_path)
                channel_path.append(skeleton.CHANNELS[channel_name])

                item = (channel_order, channel_name, channel_path)
                menu.append(item)

        menu = sorted(menu, key=lambda x: x[0])

        listing = []
        for index, (channel_order, channel_name, channel_path) in \
                enumerate(menu):
            params['module_path'] = str(channel_path)
            params['module_name'] = channel_name
            params['channel_label'] = skeleton.LABELS[channel_name]

            channel = utils.get_module(params)

            # Legacy fix (il faudrait remplacer channel_name par
            # module_name dans tous les .py des chaines)
            params['channel_name'] = params.module_name

            item = {}
            # Build context menu (Move up, move down, ...)
            context_menu = []

            item_down = (
                common.GETTEXT('Move down'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='move',
                    direction='down',
                    item_id_order=channel_name + '.order',
                    displayed_items=menu) + ')'
            )
            item_up = (
                common.GETTEXT('Move up'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='move',
                    direction='up',
                    item_id_order=channel_name + '.order',
                    displayed_items=menu) + ')'
            )

            if index == 0:
                context_menu.append(item_down)
            elif index == len(menu) - 1:
                context_menu.append(item_up)
            else:
                context_menu.append(item_up)
                context_menu.append(item_down)

            hide = (
                common.GETTEXT('Hide'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='hide',
                    item_id=channel_name) + ')'
            )
            context_menu.append(hide)

            try:
                item = channel.get_live_item(params)
                if item is not None:
                    if type(item) is dict:
                        item['context_menu'] = context_menu
                        listing.append(item)
                    elif type(item) is list:
                        for subitem in item:
                            subitem['context_menu'] = context_menu
                            listing.append(subitem)
            except Exception:
                title = params['channel_label'] + ' broken'
                utils.send_notification(
                    '', title=title, time=2000)

        return common.PLUGIN.create_listing(
            listing,
            sort_methods=(
                common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                common.sp.xbmcplugin.SORT_METHOD_LABEL
            ),
            category=common.get_window_title()
        )