示例#1
0
def list_shows(params):
    """Build shows listing"""
    shows = []

    if params.next == 'list_shows_1':

        all_video = common.ADDON.get_localized_string(30701)

        shows.append({
            'label': common.GETTEXT('All videos'),
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                next='list_videos_1',
                page=1,
                all_video=all_video,
                window_title=all_video
            )
        })
    
    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#2
0
def root(params):
    """Add modes in the listing"""
    modes = []

    for category_name, category_url in CATEGORIES.iteritems():

        if 'series' in category_url or 'films' in category_url:
            next_value = 'list_shows_films_series_1'
        else:
            next_value = 'list_shows_emissions_1'

        modes.append({
            'label': category_name,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                category_url=category_url,
                category_name=category_name,
                next=next_value,
                window_title=category_name
            )
        })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_LABEL,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#3
0
def list_shows(params):
    """Build shows listing"""
    shows = []

    if params.next == 'list_shows_1':

        for category_url, category_name in CATEGORIES.iteritems():

            shows.append({
                'label': category_name,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    category_url=category_url,
                    category_name=category_name,
                    page='0',
                    next='list_videos_1',
                    window_title=category_name
                )
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#4
0
def root(params):
    """Add modes in the listing"""
    modes = []

    category_title = common.GETTEXT('All videos')

    modes.append({
        'label': category_title,
        'url': common.PLUGIN.get_url(
            module_path=params.module_path,
            module_name=params.module_name,
            action='website_entry',
            next='list_videos_1',
            title=category_title,
            page='1',
            window_title=category_title
        )
    })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_LABEL,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#5
0
def root(params):
    """Add Replay and Live in the listing"""
    modes = []

    # Add Replay
    modes.append({
        'label': 'Replay',
        'url': common.PLUGIN.get_url(
            module_path=params.module_path,
            module_name=params.module_name,
            action='replay_entry',
            next='list_shows_1',
            category='%s Replay' % params.channel_name.upper(),
            window_title='%s Replay' % params.channel_name
        )
    })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#6
0
def list_videos_categories(params):
    """Build videos categories listing"""
    videos_categories = []
    url = ''.join((
        params.program_url,
        '/videos'))
    program_html = utils.get_webcontent(url)
    program_soup = bs(program_html, 'html.parser')

    filters_1_soup = program_soup.find(
        'ul',
        class_='filters_1')
    if filters_1_soup is not None:
        for li in filters_1_soup.find_all('li'):
            category_title = li.get_text().encode('utf-8')
            category_id = li.find('a')['data-filter'].encode('utf-8')

            # Get Last Page of each categorie
            # Get First page :
            url_first_page = ''.join((
                params.program_url,
                '/videos',
                '?filter=',
                category_id))
            program_first_page_html = utils.get_webcontent(url_first_page)
            program_first_page_soup = bs(
                program_first_page_html, 'html.parser')
            # Get Last page :
            last_page = '0'
            if program_first_page_soup.find(
                    'a', class_='icon i-chevron-right-double trackXiti'
            ) is not None:
                last_page = program_first_page_soup.find(
                    'a',
                    class_='icon i-chevron-right-double trackXiti'
                ).get('href').rsplit('/')[-1].split('?')[0]

            videos_categories.append({
                'label': category_title,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    program_url=params.program_url,
                    page='1',
                    last_page=last_page,
                    next='list_videos',
                    window_title=category_title,
                    category_id=category_id
                )
            })
    return common.PLUGIN.create_listing(
        videos_categories,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#7
0
def root(params):
    """Add modes in the listing"""
    modes = []

    category_title = common.GETTEXT('All videos')
    category_url = URL_ROOT + '/search?types=video&page=%s&sort=-origin_date'

    modes.append({
        'label': category_title,
        'url': common.PLUGIN.get_url(
            module_path=params.module_path,
            module_name=params.module_name,
            action='website_entry',
            next='list_videos_1',
            title=category_title,
            category_url=category_url,
            page='1',
            window_title=category_title
        )
    })

    categories_html = utils.get_webcontent(
        URL_ROOT + '/search?types=video')
    categories_soup = bs(categories_html, 'html.parser')
    categories = categories_soup.find(
        'div', class_='facet-group facet-group--tags open').find_all(
            'label')

    for category in categories:
        category_title = category.get_text().strip().encode('utf-8')
        category_id = category.find('input').get('value')
        category_url = URL_ROOT + '/search?types=video' + \
            '&tags=%s&sort=-origin_date' % category_id + \
            '&page=%s'

        modes.append({
            'label': category_title,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                next='list_videos_1',
                title=category_title,
                category_url=category_url,
                page='1',
                window_title=category_title
            )
        })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#8
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':
        file_path = utils.download_catalog(
            URL_PROGRAMS,
            '%s_programs.html' % params.channel_name)
        programs_html = open(file_path).read()

        programs_soup = bs(programs_html, 'html.parser')
        list_js = programs_soup.find_all("script")
        # 7ème script contient la liste des categories au format json
        json_categories = list_js[6].prettify().replace(
            '</script>', ''
        ).replace(
            '<script>', ''
        ).replace(
            'var programList = ', ''
        ).replace(
            '\n', ''
        ).replace(
            '\r', ''
        ).replace(
            ',]', ']')
        json_categories_jsonparser = json.loads(json_categories)

        for category in json_categories_jsonparser["programmings"]:
            category_name = category["title"]
            category_img = URL_ROOT + category["image"]
            category_url = URL_ROOT + '/programma/' + category["description"]

            shows.append({
                'label': category_name,
                'thumb': category_img,
                'fanart': category_img,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='list_videos_cat',
                    category_url=category_url,
                    window_title=category_name,
                    category_name=category_name,
                )
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#9
0
def list_shows(params):
    """Build shows listing"""
    shows = []

    if params.next == 'list_shows_1':

        all_video = common.ADDON.get_localized_string(30701)

        shows.append({
            'label': common.GETTEXT('All videos'),
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                next='list_videos_cat',
                category_id=0,
                all_video=all_video,
                window_title=all_video
            )
        })

        file_path = utils.download_catalog(
            URL_CATEGORIES_NHK % (params.channel_name, get_api_key(params)),
            '%s_categories.json' % (params.channel_name)
        )
        file_categories = open(file_path).read()
        json_parser = json.loads(file_categories)

        for category in json_parser["vod_categories"]:

            name_category = category["name"].encode('utf-8')
            category_id = category["category_id"]

            shows.append({
                'label': name_category,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='list_videos_cat',
                    category_id=category_id,
                    name_category=name_category,
                    window_title=name_category
                )
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#10
0
def root(params):
    """Add modes in the listing"""
    modes = []

    list_categories_html = utils.get_webcontent(URL_ROOT)
    list_categories_soup = bs(list_categories_html, 'html.parser')
    list_categories = list_categories_soup.find(
        'ul', class_='nav').find_all('a', class_='dropdown-toggle')

    for category in list_categories:

        if 'emissions' in category.get('href'):
            category_title = category.get_text().strip()
            category_url = URL_ROOT + category.get('href')

            modes.append({
                'label': category_title,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='website_entry',
                    next='list_shows_1',
                    title=category_title,
                    category_url=category_url,
                    window_title=category_title
                )
            })

        elif 'videos' in category.get('href'):
            category_title = category.get_text().strip()
            category_url = URL_ROOT + category.get('href')

            modes.append({
                'label': category_title,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='website_entry',
                    next='list_videos_1',
                    title=category_title,
                    page='1',
                    category_url=category_url,
                    window_title=category_title
                )
            })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_LABEL,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#11
0
def root(params):
    modes = []

    if params.channel_name == 'skynews':
        next_value = 'list_videos_youtube'
    elif params.channel_name == 'skysports':
        next_value = 'list_shows_sports'

    if params.next == "replay_entry":
        params['next'] = next_value
        params['page'] = '1'
        return channel_entry(params)

    # Add Replay
    modes.append({
        'label': 'Replay',
        'url': common.PLUGIN.get_url(
            module_path=params.module_path,
            module_name=params.module_name,
            action='replay_entry',
            next=next_value,
            page='1',
            category='%s Replay' % params.channel_name.upper(),
            window_title='%s Replay' % params.channel_name.upper()
        ),
    })

    # Add Live
    if params.channel_name == 'skynews':
        modes.append({
            'label': common.GETTEXT('Live TV'),
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                next='live_cat',
                category='%s Live TV' % params.channel_name.upper(),
                window_title='%s Live TV' % params.channel_name.upper()
            ),
        })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#12
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':

        # Get Emission :
        root_html = utils.get_webcontent(
            URL_EMISSION)
        root_soup = bs(root_html, 'html.parser')
        emissions_soup = root_soup.find_all(
            'div', class_="fusion-column-wrapper")

        for emission in emissions_soup:

            if emission.find('h3'):
                emission_name = emission.find('h3').find(
                    'a').get_text().encode('utf-8')
                emission_img = emission.find('img').get(
                    'src').encode('utf-8')
                emission_url = emission.find('a').get(
                    'href').encode('utf-8')

                if 'http' not in emission_url:
                    emission_url = URL_ROOT + '/' + emission_url

                shows.append({
                    'label': emission_name,
                    'thumb': emission_img,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        emission_url=emission_url,
                        category_name=emission_name,
                        next='list_videos_1',
                        window_title=emission_name
                    )
                })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#13
0
def root(params):
    """Add modes in the listing"""
    modes = []

    list_categories_html = utils.get_webcontent(URL_ROOT)
    list_categories_soup = bs(list_categories_html, 'html.parser')
    list_categories = list_categories_soup.find(
        'ul', class_='nav navbar-nav').find_all('a')

    for category in list_categories:

        category_title = category.get_text()
        category_url = URL_ROOT + category.get('href')

        value_next = ''
        if 'taratata' in category.get('href'):
            value_next = 'list_shows_taratata'
        elif 'artistes' in category.get('href'):
            value_next = 'list_shows_artistes_1'
        elif 'bonus' in category.get('href'):
            value_next = 'list_shows_bonus'
        else:
            return None

        modes.append({
            'label': category_title,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                next=value_next,
                title=category_title,
                page='1',
                category_url=category_url,
                window_title=category_title
            )
        })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_LABEL,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#14
0
def list_shows(params):
    """Build shows listing"""
    shows = []
    if params.next == 'list_shows_1':
        file_path = utils.download_catalog(
            URL_REPLAY,
            params.channel_name + '.html')
        root_html = open(file_path).read()
        root_soup = bs(root_html, 'html.parser')

        categories_soup = root_soup.find(
            'div',
            class_='nav-programs'
        )

        for category in categories_soup.find_all('a'):
            category_name = category.find(
                'span').get_text().encode('utf-8').replace(
                '\n', ' ').replace('\r', ' ').rstrip('\r\n')
            category_hash = common.sp.md5(category_name).hexdigest()

            url = category.get('href').encode('utf-8')

            shows.append({
                'label': category_name,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    category_hash=category_hash,
                    next='list_videos_cat',
                    url=url,
                    window_title=category_name,
                    category_name=category_name,
                )
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#15
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    # Get categories :
    file_path = utils.download_catalog(
        URL_ROOT_BRF,
        '%s_categories.html' % (
            params.channel_name))
    root_html = open(file_path).read()
    root_soup = bs(root_html, 'html.parser')

    menu_soup = root_soup.find('ul', class_="off-canvas-list")
    categories_soup = menu_soup.find_all('a')

    for category in categories_soup:

        category_name = category.get_text().encode('utf-8')
        category_url = category.get('href')

        if 'http' in category_url:
            shows.append({
                'label': category_name,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    category_url=category_url,
                    page='1',
                    category_name=category_name,
                    next='list_videos',
                    window_title=category_name
                )
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#16
0
def root(params):
    """Add modes in the listing"""
    modes = []

    category_name = 'ELLE Girl TV'

    modes.append({
        'label': category_name,
        'url': common.PLUGIN.get_url(
            module_path=params.module_path,
            module_name=params.module_name,
            action='website_entry',
            category_name=category_name,
            page='0',
            next='list_videos_2',
            window_title=category_name
        )
    })

    for category_name, category_url in CATEGORIES.iteritems():
        modes.append({
            'label': category_name,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                category_url=category_url,
                category_name=category_name,
                page='1',
                next='list_videos_1',
                window_title=category_name
            )
        })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#17
0
def root(params):
    """Add modes in the listing"""
    modes = []

    list_categories_html = utils.get_webcontent(URL_ROOT)
    list_categories_soup = bs(list_categories_html, 'html.parser')
    list_categories = list_categories_soup.find(
        'div', class_='jqueryslidemenu').find('ul').find('ul').find_all('li')

    for category in list_categories:

        if 'personnages' in category.find('a').get('href'):
            value_next = 'list_shows_1'
        else:
            value_next = 'list_videos_1'
        category_title = category.find('a').get_text()
        category_url = URL_ROOT + '/' + category.find('a').get('href')

        modes.append({
            'label': category_title,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                next=value_next,
                title=category_title,
                page='1',
                category_url=category_url,
                window_title=category_title
            )
        })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_LABEL,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#18
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':

        replay_categories_html = utils.get_webcontent(URL_EMISSIONS)
        replay_categories_soup = bs(replay_categories_html, 'html.parser')
        categories = replay_categories_soup.find(
            'div', class_='list').find_all('li')

        for category in categories:

            category_name = category.find('a').get_text()
            category_url = URL_ROOT + category.find(
                "a").get("href")
            shows.append({
                'label': category_name,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    category_url=category_url,
                    category_name=category_name,
                    next='list_videos_1',
                    window_title=category_name
                )
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#19
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    list_shows_html = utils.get_webcontent(params.category_url)
    list_shows_soup = bs(list_shows_html, 'html.parser')
    list_shows = list_shows_soup.find(
        'div', class_='personnages').find_all('a')

    for personnage in list_shows:

        show_title = personnage.get('title')
        show_img = URL_ROOT + personnage.find('img').get('src')
        show_url = URL_ROOT + personnage.get('href').encode('utf-8')

        shows.append({
            'label': show_title,
            'thumb': show_img,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                next='list_videos_2',
                title=show_title,
                category_url=show_url,
                window_title=show_title
            )
        })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_LABEL,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#20
0
def root(params):
    """Add modes in the listing"""
    modes = []

    categories_html = utils.get_webcontent(
        URL_ROOT + '/actualites/videos')
    categories_soup = bs(categories_html, 'html.parser')
    categories = categories_soup.find(
            'select', class_='selecttourl').find_all(
            'option')

    for category in categories:
        category_title = category.get_text().strip().encode('utf-8')
        category_url = category.get('value')

        modes.append({
            'label': category_title,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                next='list_videos_1',
                title=category_title,
                category_url=category_url,
                page='0',
                window_title=category_title
            )
        })

    return common.PLUGIN.create_listing(
        modes,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#21
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    list_shows_html = utils.get_webcontent(params.category_url)
    list_shows_soup = bs(list_shows_html, 'html.parser')
    list_shows = list_shows_soup.find_all(
        'div',
        class_='widget-header')

    for show in list_shows:

        show_title = show.find('h3').get_text()
        show_url = show.find('a').get('href').encode('utf-8')

        shows.append({
            'label': show_title,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                next='list_videos_1',
                title=show_title,
                page='1',
                category_url=show_url,
                window_title=show_title
            )
        })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        category=common.get_window_title()
    )
示例#22
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    file_path = utils.download_catalog(
        params.show_url,
        '%s_show_%s.html' % (
            params.channel_name, params.title)
    )
    replay_show_season_html = open(file_path).read()
    seasons_episodes_soup = bs(replay_show_season_html, 'html.parser')

    # Get data-account
    data_account = re.compile(
        r'data-account="(.*?)"').findall(replay_show_season_html)[0]
    data_player = re.compile(
        r'data-player="(.*?)"').findall(replay_show_season_html)[0]

    if "Series" in params.title:
        # GET VideoId for each episode of season selected
        seasons_episodes = seasons_episodes_soup.find_all(
            'div', class_='spanOneThird vod-episode clearfix ')
        for episode in seasons_episodes:
            if episode.get('data-series') == \
                    params.title.split('Series')[1].strip():

                data_vidid = episode.get('data-vidid')

                video_title = episode.get('data-title')
                video_title = video_title + ' S%sE%s' % (
                    episode.get('data-series'), episode.get('data-episode'))
                video_duration = 0

                video_plot = 'Expire '
                video_plot = video_plot + episode.get(
                    'data-publishend').split('T')[0]
                video_plot = video_plot + '\n' + episode.get(
                    'data-teaser').encode('utf-8')

                video_img = episode.find('img').get('src')

                date_value = episode.get("data-publishstart")
                date_value_list = date_value.split('T')[0].split('-')
                day = date_value_list[2]
                mounth = date_value_list[1]
                year = date_value_list[0]

                date = '.'.join((day, mounth, year))
                aired = '-'.join((year, mounth, day))

                info = {
                    'video': {
                        'title': video_title,
                        'aired': aired,
                        'date': date,
                        'duration': video_duration,
                        'plot': video_plot,
                        'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'),
                    'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                        action='download_video',
                        module_path=params.module_path,
                        module_name=params.module_name,
                        data_vidid=data_vidid,
                        data_account=data_account,
                        data_player=data_player) + ')'
                )
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label': video_title,
                    'thumb': video_img,
                    'fanart': video_img,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        next='play_r',
                        data_vidid=data_vidid,
                        data_account=data_account,
                        data_player=data_player
                    ),
                    'is_playable': True,
                    'info': info,
                    'context_menu': context_menu
                })

        play_episode = seasons_episodes_soup.find(
            'div', class_='spanOneThird vod-episode clearfix playing in')
        if play_episode.get('data-series') == \
                params.title.split('Series')[1].strip():

            data_vidid = play_episode.get('data-vidid')

            video_title = play_episode.get('data-title')
            video_title = video_title + ' S%sE%s' % (
                play_episode.get('data-series'),
                play_episode.get('data-episode')
            )
            video_duration = 0
            video_plot = 'Expire '
            video_plot = video_plot + play_episode.get(
                'data-publishend').split('T')[0] + '\n '
            video_plot = video_plot + play_episode.get(
                'data-teaser').encode('utf-8')
            video_img = play_episode.find('img').get('src')

            date_value = play_episode.get("data-publishstart")
            date_value_list = date_value.split('T')[0].split('-')
            day = date_value_list[2]
            mounth = date_value_list[1]
            year = date_value_list[0]

            date = '.'.join((day, mounth, year))
            aired = '-'.join((year, mounth, day))

            info = {
                'video': {
                    'title': video_title,
                    'aired': aired,
                    'date': date,
                    'duration': video_duration,
                    'plot': video_plot,
                    'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='download_video',
                    module_path=params.module_path,
                    module_name=params.module_name,
                    data_vidid=data_vidid,
                    data_account=data_account,
                    data_player=data_player) + ')'
            )
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label': video_title,
                'thumb': video_img,
                'fanart': video_img,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='play_r',
                    data_vidid=data_vidid,
                    data_account=data_account,
                    data_player=data_player
                ),
                'is_playable': True,
                'info': info,
                'context_menu': context_menu
            })

    else:
        play_episode = seasons_episodes_soup.find(
            'div', class_='vod-video-container')

        data_vidid = play_episode.find('a').get('data-vidid')

        video_title = play_episode.find('img').get('alt')
        video_duration = 0
        video_plot = seasons_episodes_soup.find(
            'p', class_='teaser').get_text().encode('utf-8')
        video_img = re.compile(
            'itemprop="image" content="(.*?)"'
        ).findall(replay_show_season_html)[0]

        date_value = re.compile(
            'itemprop="uploadDate" content="(.*?)"'
        ).findall(replay_show_season_html)[0]
        date_value_list = date_value.split(',')[0].split(' ')
        if len(date_value_list[0]) == 1:
            day = '0' + date_value_list[0]
        else:
            day = date_value_list[0]
        try:
            mounth = CORRECT_MOUNTH[date_value_list[1]]
        except Exception:
            mounth = '00'
        year = date_value_list[2]

        date = '.'.join((day, mounth, year))
        aired = '-'.join((year, mounth, day))

        info = {
            'video': {
                'title': video_title,
                'aired': aired,
                'date': date,
                'duration': video_duration,
                'plot': video_plot,
                'year': year,
                'mediatype': 'tvshow'
            }
        }

        download_video = (
            common.GETTEXT('Download'),
            'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                action='download_video',
                module_path=params.module_path,
                module_name=params.module_name,
                data_vidid=data_vidid,
                data_account=data_account,
                data_player=data_player) + ')'
        )
        context_menu = []
        context_menu.append(download_video)

        videos.append({
            'label': video_title,
            'thumb': video_img,
            'fanart': video_img,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                next='play_r',
                data_vidid=data_vidid,
                data_account=data_account,
                data_player=data_player
            ),
            'is_playable': True,
            'info': info,
            'context_menu': context_menu
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_DURATION,
            common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
            common.sp.xbmcplugin.SORT_METHOD_GENRE,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        content='tvshows',
        category=common.get_window_title()
    )
示例#23
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':

        emission_title = 'Émissions'

        shows.append({
            'label':
            emission_title,
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  emission_title=emission_title,
                                  action='replay_entry',
                                  next='list_shows_emissions_1',
                                  window_title=emission_title)
        })

        file_path = utils.get_webcontent(URL_CATEGORIES)
        categories_json = json.loads(file_path)

        for category in categories_json["item"]:
            if category["@attributes"]["id"] == 'category':
                for category_sub in category["item"]:
                    if 'category-' in category_sub["@attributes"]["id"]:
                        category_name = category_sub["@attributes"]["name"]
                        category_url = category_sub["@attributes"]["url"]

                        shows.append({
                            'label':
                            category_name,
                            'url':
                            common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                category_url=category_url,
                                category_name=category_name,
                                next='list_shows_categories_1',
                                window_title=category_name)
                        })

    elif params.next == 'list_shows_emissions_1':

        file_path = utils.download_catalog(URL_EMISSIONS_AUVIO,
                                           'url_emissions_auvio.html')
        emissions_html = open(file_path).read()
        emissions_soup = bs(emissions_html, 'html.parser')
        list_emissions = emissions_soup.find_all(
            'article',
            class_="rtbf-media-item col-xxs-12 col-xs-6 col-md-4 col-lg-3 ")

        for emission in list_emissions:

            emission_id = emission.get('data-id')
            emission_title = emission.find('h4').get_text().encode('utf-8')
            list_emission_image = emission.find('img').get(
                'data-srcset').split(' ')
            emission_image = ''
            for image_datas in list_emission_image:
                if 'jpg' in image_datas:
                    if ',' in image_datas:
                        emission_image = image_datas.split(',')[1]
                    else:
                        emission_image = image_datas

            shows.append({
                'label':
                emission_title,
                'thumb':
                emission_image,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      emission_title=emission_title,
                                      action='replay_entry',
                                      emission_id=emission_id,
                                      next='list_videos_emission',
                                      window_title=emission_title)
            })

    elif params.next == 'list_shows_categories_1':

        sub_categories_html = utils.get_webcontent(params.category_url)
        sub_categories_soup = bs(sub_categories_html, 'html.parser')
        list_sub_categories = sub_categories_soup.find_all(
            'section', class_="js-item-container")

        for sub_category in list_sub_categories:

            sub_category_title = " ".join(
                sub_category.find('h2').get_text().encode('utf-8').split())
            sub_category_id = sub_category.get('id')

            shows.append({
                'label':
                sub_category_title,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      sub_category_title=sub_category_title,
                                      action='replay_entry',
                                      sub_category_id=sub_category_id,
                                      category_url=params.category_url,
                                      next='list_videos_categorie',
                                      window_title=sub_category_title)
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        category=common.get_window_title(params))
示例#24
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_1':
        file_path = utils.get_webcontent(URL_REPLAY)
        replay_episodes_soup = bs(file_path, 'html.parser')
        episodes = replay_episodes_soup.find_all(
            'div', class_='modal fade replaytv_modal')

        for episode in episodes:

            video_title = episode.find('h4',
                                       class_='m-t-30').get_text().strip()
            video_duration = 0
            video_plot = episode.find('p').get_text().strip()
            video_url = episode.find('div',
                                     class_='replaytv_video').get('video-src')
            # TO DO Get IMG
            video_img = ''

            info = {
                'video': {
                    'title': video_title,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': video_duration,
                    'plot': video_plot,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (_('Download'), 'XBMC.RunPlugin(' +
                              common.PLUGIN.get_url(action='download_video',
                                                    video_url=video_url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                video_title,
                'thumb':
                video_img,
                'fanart':
                video_img,
                'url':
                common.PLUGIN.get_url(action='channel_entry',
                                      next='play_r',
                                      video_url=video_url),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_DURATION,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      common.sp.xbmcplugin.SORT_METHOD_GENRE,
                      common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        category=common.get_window_title())
示例#25
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':

        file_path = utils.download_catalog(
            URL_SHOWS % (params.channel_name),
            '%s_show.html' % (params.channel_name))
        replay_shows_html = open(file_path).read()

        replay_shows_soup = bs(replay_shows_html, 'html.parser')
        replay_shows = replay_shows_soup.find_all('div', class_='span2')

        for show in replay_shows:

            show_title = show.find('a').find('img').get('alt').encode('utf-8')
            show_img = show.find('a').find('img').get('src')
            show_url = URL_ROOT + show.find('a').get('href')

            if 'episodes' in show.find('p', class_='series-ep').get_text():
                shows.append({
                    'label':
                    show_title,
                    'thumb':
                    show_img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='list_shows_2',
                                          title=show_title,
                                          show_url=show_url,
                                          window_title=show_title)
                })
            else:
                shows.append({
                    'label':
                    show_title,
                    'thumb':
                    show_img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='list_videos_1',
                                          title=show_title,
                                          show_url=show_url,
                                          window_title=show_title)
                })

    elif params.next == 'list_shows_2':

        file_path = utils.download_catalog(
            params.show_url,
            '%s_show_%s.html' % (params.channel_name, params.title))
        replay_show_html = open(file_path).read()

        replay_show_seasons_soup = bs(replay_show_html, 'html.parser')
        replay_show_seasons = replay_show_seasons_soup.find(
            'ul', class_='clearfix tag-nav')

        get_show_seasons = replay_show_seasons.find_all('li')

        for season in get_show_seasons:

            season_title = 'Series %s' % season.get('id').encode(
                'utf-8').split('nav-series-')[1]

            shows.append({
                'label':
                season_title,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='list_videos_1',
                                      title=params.title + '_' + season_title,
                                      show_url=params.show_url,
                                      window_title=season_title)
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        category=common.get_window_title(params))
示例#26
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_1':

        replay_episodes_html = utils.get_webcontent(params.category_url)
        replay_episodes_soup = bs(replay_episodes_html, 'html.parser')

        episodes = replay_episodes_soup.find_all('div', class_='showcategory')

        for episode in episodes:

            video_title = episode.find('h5').find('a').get_text().strip()
            video_url = URL_ROOT + '/' + episode.find('a').get('href')
            video_img = URL_ROOT + '/' + episode.find('img').get('src')
            video_duration = 0
            video_plot = episode.find('p',
                                      class_='mod-articles-category-introtext'
                                      ).get_text().strip().encode('utf-8')

            info = {
                'video': {
                    'title': video_title,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': video_duration,
                    'plot': video_plot,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                common.PLUGIN.get_url(action='download_video',
                                      module_path=params.module_path,
                                      module_name=params.module_name,
                                      video_url=video_url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                video_title,
                'thumb':
                video_img,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='website_entry',
                                      next='play_r',
                                      video_url=video_url),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_videos_1':
        videos_html = utils.get_webcontent(
            URL_VIDEOS % (params.show_id, params.page))
        videos_soup = bs(videos_html, 'html.parser')
        list_videos_datas = videos_soup.find_all(
            style='float:left; width:160px; height:220px; padding-left:4px; padding-right:31px')
            
        for video_datas in list_videos_datas:
        
            video_title = video_datas.find('b').text + ' - ' + video_datas.text.replace(video_datas.find('b').text, '')[:-5]
            video_duration = 0
            video_url = URL_STREAM % video_datas.find('a').get('href').replace('../', '')
            video_img = video_datas.find('img', class_='thumb').get('src')
                 
            info = {
                'video': {
                    'title': video_title,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': video_duration,
                    # 'plot': video_plot,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='download_video',
                    module_path=params.module_path,
                    module_name=params.module_name,
                    video_url=video_url) + ')'
            )
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label': video_title,
                'thumb': video_img,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='play_r',
                    video_url=video_url
                ),
                'is_playable': True,
                'info': info,
                'context_menu': context_menu
            })
        
        # More videos...
        videos.append({
            'label': '# ' + common.ADDON.get_localized_string(30700),
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                next='list_videos_1',
                page=str(int(params.page) + 1),
                show_id=params.show_id,
                update_listing=True,
                previous_listing=str(videos)
            )
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params)
    )
def list_live(params):
    """Build live listing"""
    lives = []

    title = ''
    subtitle = ' - '
    plot = ''
    duration = 0
    img = ''
    url_live = ''

    title = '%s Live' % (params.channel_name.upper())

    # Get URL Live
    file_path = utils.download_catalog(
        URL_LIVE_NHK % params.channel_name,
        '%s_live.xml' % params.channel_name,
    )
    live_xml = open(file_path).read()
    xmlElements = ET.XML(live_xml)
    url_live = xmlElements.find("tv_url").findtext("wstrm").encode('utf-8')

    # GET Info Live (JSON)
    url_json = URL_LIVE_INFO_NHK % (params.channel_name, LOCATION[0],
                                    get_api_key(params))
    file_path_json = utils.download_catalog(
        url_json,
        '%s_live.json' % params.channel_name,
    )
    live_json = open(file_path_json).read()
    json_parser = json.loads(live_json)

    # Get First Element
    for info_live in json_parser['channel']['item']:
        if info_live["subtitle"] != '':
            subtitle = subtitle + info_live["subtitle"].encode('utf-8')
        title = info_live["title"].encode('utf-8') + subtitle

        start_date = time.strftime(
            '%H:%M', time.localtime(int(str(info_live["pubDate"])[:-3])))
        end_date = time.strftime(
            '%H:%M', time.localtime(int(str(info_live["endDate"])[:-3])))
        plot = start_date + ' - ' + end_date + '\n ' + \
            info_live["description"].encode('utf-8')
        img = URL_ROOT + info_live["thumbnail"].encode('utf-8')
        break

    info = {'video': {'title': title, 'plot': plot, 'duration': duration}}

    lives.append({
        'label':
        title,
        'fanart':
        img,
        'thumb':
        img,
        'url':
        common.PLUGIN.get_url(
            action='channel_entry',
            next='play_l',
            url=url_live,
        ),
        'is_playable':
        True,
        'info':
        info
    })

    return common.PLUGIN.create_listing(
        lives,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        category=common.get_window_title())
示例#29
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.channel_name == 'cnews':

        url_page = params.category_url + '/page/%s' % params.page

        file_path = utils.download_catalog(
            url_page,
            '%s_%s_%s.html' % (
                params.channel_name, params.category_name, params.page))
        root_html = open(file_path).read()
        root_soup = bs(root_html, 'html.parser')

        programs = root_soup.find_all('article', class_='item')

        for program in programs:
            title = program.find('h3').get_text().encode('utf-8')
            thumb = program.find('img').get('src').encode('utf-8')
            # Get Video_ID
            video_html = utils.get_webcontent(
                program.find('a').get('href').encode('utf-8'))
            id = re.compile(r'videoId=(.*?)"').findall(video_html)[0]
            # Get Description
            datas_video = bs(video_html, 'html.parser')
            description = datas_video.find(
                'article', class_='entry-body').get_text().encode('utf-8')
            duration = 0

            date = re.compile(
                r'property="video:release_date" content="(.*?)"'
            ).findall(video_html)[0].split('T')[0].split('-')
            day = date[2]
            mounth = date[1]
            year = date[0]

            date = '.'.join((day, mounth, year))
            aired = '-'.join((year, mounth, day))

            info = {
                'video': {
                    'title': title,
                    'plot': description,
                    'aired': aired,
                    'date': date,
                    'duration': duration,
                    'year': year,
                    # 'genre': category,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='download_video',
                    module_path=params.module_path,
                    module_name=params.module_name,
                    id=id) + ')'
            )
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label': title,
                'thumb': thumb,
                'fanart': thumb,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='play_r',
                    id=id
                ),
                'is_playable': True,
                'info': info,
                'context_menu': context_menu
            })

        # More videos...
        videos.append({
            'label': common.ADDON.get_localized_string(30700),
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                category_url=params.category_url,
                category_name=params.category_name,
                next='list_videos',
                page=str(int(params.page) + 1),
                update_listing=True,
                previous_listing=str(videos)
            )
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_DATE,
            common.sp.xbmcplugin.SORT_METHOD_DURATION,
            common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
            common.sp.xbmcplugin.SORT_METHOD_GENRE,
            common.sp.xbmcplugin.SORT_METHOD_PLAYCOUNT,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title()
    )
示例#30
0
def list_shows(params):
    """Build shows listing"""
    shows = []

    if 'list_shows_without_categories' in params.next:

        # Pour avoir toutes les videos
        state_video = 'Toutes les videos (sans les categories)'

        shows.append({
            'label': state_video,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                state_video=state_video,
                next='list_videos_1',
                # title_category=category_name,
                window_title=state_video
            )
        })

    else:
        unique_item = dict()

        file_path = utils.download_catalog(
            URL_COLLECTION_API % params.channel_name,
            '%s_collection.xml' % params.channel_name,
        )
        collection_xml = open(file_path).read()

        xml_elements = ET.XML(collection_xml)

        if 'list_shows_1' in params.next:
            # Build categories list (Tous les programmes, Séries, ...)
            collections = xml_elements.findall("collection")

            # Pour avoir toutes les videos, certaines videos ont des
            # categories non presentes dans cette URL 'url_collection_api'
            state_video = 'Toutes les videos'

            shows.append({
                'label': state_video,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    state_video=state_video,
                    next='list_videos_1',
                    # title_category=category_name,
                    window_title=state_video
                )
            })

            for collection in collections:

                category_name = collection.findtext("category").encode('utf-8')
                if category_name not in unique_item:
                    if category_name == '':
                        category_name = 'NO_CATEGORY'
                    unique_item[category_name] = category_name
                    shows.append({
                        'label': category_name,
                        'url': common.PLUGIN.get_url(
                            module_path=params.module_path,
                            module_name=params.module_name,
                            action='replay_entry',
                            category_name=category_name,
                            next='list_shows_programs',
                            # title_category=category_name,
                            window_title=category_name
                        )
                    })

        elif 'list_shows_programs' in params.next:
            # Build programm list (Tous les programmes, Séries, ...)
            collections = xml_elements.findall("collection")

            state_video = 'VIDEOS_BY_CATEGORY'

            for collection in collections:
                if params.category_name == collection.findtext(
                        "category").encode('utf-8') \
                        or (params.category_name == 'NO_CATEGORY' and
                            collection.findtext("category").encode('utf-8') == ''):
                    name_program = collection.findtext("name").encode('utf-8')
                    img_program = collection.findtext("picture")
                    id_program = collection.get("id")

                    shows.append({
                        'label': name_program,
                        'thumb': img_program,
                        'url': common.PLUGIN.get_url(
                            module_path=params.module_path,
                            module_name=params.module_name,
                            action='replay_entry',
                            next='list_videos_1',
                            state_video=state_video,
                            id_program=id_program,
                            # title_program=name_program,
                            window_title=name_program
                        )
                    })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE
        ),
        category=common.get_window_title()
    )
示例#31
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':

        emission_title = 'Émissions'

        shows.append({
            'label': emission_title,
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                emission_title=emission_title,
                action='replay_entry',
                next='list_shows_2',
                window_title=emission_title
            )
        })

        file_path = utils.get_webcontent(URL_CATEGORIES)
        categories_json = json.loads(file_path)

        for category in categories_json["item"]:
            if category["@attributes"]["id"] == 'category':
                for category_sub in category["item"]:
                    if 'category-' in category_sub["@attributes"]["id"]:
                        category_name = category_sub["@attributes"]["name"]
                        category_url = category_sub["@attributes"]["url"]

                        shows.append({
                            'label': category_name,
                            'url': common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                category_url=category_url,
                                category_name=category_name,
                                next='list_videos_categorie',
                                window_title=category_name
                            )
                        })

    elif params.next == 'list_shows_2':

        file_path = utils.download_catalog(
            URL_EMISSIONS_AUVIO,
            'url_emissions_auvio.html')
        emissions_html = open(file_path).read()
        emissions_soup = bs(emissions_html, 'html.parser')
        list_emissions = emissions_soup.find_all(
            'article', class_="rtbf-media-item col-xxs-12 col-xs-6 col-md-4 col-lg-3 ")

        for emission in list_emissions:

            emission_id = emission.get('data-id')
            emission_title = emission.find('h4').get_text().encode('utf-8')

            shows.append({
                'label': emission_title,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    emission_title=emission_title,
                    action='replay_entry',
                    emission_id=emission_id,
                    next='list_videos_emission',
                    window_title=emission_title
                )
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#32
0
def list_videos_lci(params):
    """Build videos listing"""
    videos = []

    if params.channel_name == 'lci':
        program_html = utils.get_webcontent(params.program_url)
        program_soup = bs(program_html, 'html.parser')

        list_replay = program_soup.find_all(
            'a', class_='medium-3col-article-block-article-link')

        for replay in list_replay:

            if 'Replay' in replay.find(
                    'span', class_='emission-infos-type').get_text():
                title = replay.find_all('img')[0].get('alt').encode('utf-8')
                duration = 0
                img = replay.find_all('source')[0]
                try:
                    img = img['data-srcset'].encode('utf-8')
                except Exception:
                    img = img['srcset'].encode('utf-8')

                img = img.split(',')[0].split(' ')[0]
                program_id = URL_LCI_ROOT + replay.get('href').encode('utf-8')

                info = {
                    'video': {
                        'title': title,
                        # 'plot': stitle,
                        # 'aired': aired,
                        # 'date': date,
                        'duration': duration,
                        # 'year': int(aired[:4]),
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          program_id=program_id) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    title,
                    'thumb':
                    img,
                    'url':
                    common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        next='play_r',
                        program_id=program_id,
                    ),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        category=common.get_window_title())
示例#33
0
def list_shows(params):
    """Build categories listing"""
    shows = []
    if 'previous_listing' in params:
        shows = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_shows_root':
        show_title = 'Videos'
        shows.append({
            'label':
            show_title,
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  title=show_title,
                                  next='list_shows_videos_1',
                                  window_title=show_title)
        })

        show_title = 'Video On Demand'
        shows.append({
            'label':
            show_title,
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  title=show_title,
                                  page='1',
                                  next='list_shows_video_on_demand_1',
                                  window_title=show_title)
        })

    elif params.next == 'list_shows_videos_1':
        videos_categories_html = utils.get_webcontent(URL_VIDEOS_DATAS)
        context_id = re.compile('contextId\" value=\"(.*?)\"').findall(
            videos_categories_html)[0]
        videos_categories_soup = bs(videos_categories_html, 'html.parser')
        videos_categories_list = videos_categories_soup.find(
            'select',
            class_="filter__input i-arrow-select-small-red").find_all('option')
        for videos_category in videos_categories_list:
            show_title = videos_category.get('label')
            show_id = videos_category.get('value')

            shows.append({
                'label':
                show_title,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      title=show_title,
                                      show_id=show_id,
                                      page='1',
                                      context_id=context_id,
                                      next='list_videos_videos_1',
                                      window_title=show_title)
            })

    elif params.next == 'list_shows_video_on_demand_1':
        shows_datas_html = utils.get_webcontent(URL_SHOWS_DATAS)
        context_id = re.compile('contextId\" value=\"(.*?)\"').findall(
            shows_datas_html)[0]
        shows_datas_json = utils.get_webcontent(URL_SHOWS %
                                                (context_id, params.page))
        shows_datas_jsonparser = json.loads(shows_datas_json)
        for show_data in shows_datas_jsonparser["items"]:
            show_title = show_data["title"]
            show_img = ''
            for img_datas in show_data["image"]["items"][0]["srcset"]:
                show_img = URL_ROOT + img_datas["src"]
            show_url = URL_ROOT + show_data["url"]

            shows.append({
                'label':
                show_title,
                'thumb':
                show_img,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      title=show_title,
                                      show_url=show_url,
                                      page='1',
                                      next='list_videos_on_demand_videos_1',
                                      window_title=show_title)
            })

        # More programs...
        shows.append({
            'label':
            common.ADDON.get_localized_string(30708),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next=params.next,
                                  page=str(int(params.page) + 1),
                                  update_listing=True,
                                  previous_listing=str(shows))
        })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
示例#34
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_videos_videos_1':

        videos_datas_json = utils.get_webcontent(
            URL_VIDEOS % (params.show_id, params.context_id, params.page))
        videos_datas_jsonparser = json.loads(videos_datas_json)

        for video_datas in videos_datas_jsonparser['items']:
            title = video_datas["image"]["alt"].replace(' | Video', '')
            img = video_datas["image"]["src"]
            url = URL_ROOT + video_datas["url"]

            info = {
                'video': {
                    'title': title,
                    # 'aired': aired,
                    # 'date': date,
                    # 'duration': video_duration,
                    # 'year': year,
                    # 'plot': plot,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                common.PLUGIN.get_url(action='download_video',
                                      module_path=params.module_path,
                                      module_name=params.module_name,
                                      url=url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                title,
                'thumb':
                img,
                'fanart':
                img,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='play_r',
                                      url=url),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

        # More videos...
        videos.append({
            'label':
            common.ADDON.get_localized_string(30700),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next=params.next,
                                  page=str(int(params.page) + 1),
                                  show_id=params.show_id,
                                  context_id=params.context_id,
                                  title=params.title,
                                  window_title=params.window_title,
                                  update_listing=True,
                                  previous_listing=str(videos))
        })

    elif params.next == 'list_videos_on_demand_videos_1':

        shows_datas_html = utils.get_webcontent(params.show_url)
        context_id = re.compile('contextId\" value=\"(.*?)\"').findall(
            shows_datas_html)[0]
        videos_datas_json = utils.get_webcontent(URL_SHOWS %
                                                 (context_id, params.page))
        videos_datas_jsonparser = json.loads(videos_datas_json)

        for video_datas in videos_datas_jsonparser['items']:
            title = video_datas["title"]
            img = ''
            if 'src' in video_datas["image"]:
                img = video_datas["image"]["src"]
            else:
                for img_datas in video_datas["image"]["items"][0]["srcset"]:
                    img = URL_ROOT + img_datas["src"]
            url = URL_ROOT + video_datas["url"]

            info = {
                'video': {
                    'title': title,
                    # 'aired': aired,
                    # 'date': date,
                    # 'duration': video_duration,
                    # 'year': year,
                    # 'plot': plot,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                common.PLUGIN.get_url(action='download_video',
                                      module_path=params.module_path,
                                      module_name=params.module_name,
                                      url=url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                title,
                'thumb':
                img,
                'fanart':
                img,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='play_r',
                                      url=url),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

        # More videos...
        videos.append({
            'label':
            common.ADDON.get_localized_string(30700),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next=params.next,
                                  page=str(int(params.page) + 1),
                                  show_url=params.show_url,
                                  title=params.title,
                                  window_title=params.window_title,
                                  update_listing=True,
                                  previous_listing=str(videos))
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
示例#35
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_videos_1':
        list_videos = utils.get_webcontent(URL_VIDEOS %
                                           (params.channel_name, params.page))
        list_videos_soup = bs(list_videos, 'html.parser')

        videos_data = list_videos_soup.find_all('div',
                                                class_=re.compile("views-row"))

        for video in videos_data:

            title = video.find('span',
                               class_='field-content').find('a').get_text()
            plot = video.find('div', class_='field-resume').get_text().strip()
            duration = 0
            img = URL_ROOT % params.channel_name + \
                video.find('img').get('src')
            video_url = URL_ROOT % params.channel_name + '/' + \
                video.find('a').get('href').encode('utf-8')

            info = {
                'video': {
                    'title': title,
                    'plot': plot,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': duration,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                common.PLUGIN.get_url(action='download_video',
                                      module_path=params.module_path,
                                      module_name=params.module_name,
                                      video_url=video_url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                title,
                'thumb':
                img,
                'url':
                common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='play_r',
                    video_url=video_url,
                ),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

        # More videos...
        videos.append({
            'label':
            common.ADDON.get_localized_string(30700),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_videos_1',
                                  page=str(int(params.page) + 1),
                                  update_listing=True,
                                  previous_listing=str(videos))
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
示例#36
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':
        if params.channel_name == 'tv5mondeafrique':
            list_categories_html = utils.get_webcontent(URL_TV5MAF_ROOT +
                                                        '/videos')
            list_categories_soup = bs(list_categories_html, 'html.parser')
            list_categories = list_categories_soup.find_all(
                'h2', class_='tv5-title tv5-title--beta u-color--goblin')

            for category in list_categories:

                category_title = category.find('a').get_text().encode('utf-8')
                category_url = URL_TV5MAF_ROOT + category.find('a').get(
                    'href').encode('utf-8')

                shows.append({
                    'label':
                    category_title,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='list_shows_2',
                                          title=category_title,
                                          category_url=category_url,
                                          window_title=category_title)
                })

        elif params.channel_name == 'tv5monde':

            list_categories_html = utils.get_webcontent(URL_TV5MONDE_ROOT +
                                                        '/toutes-les-videos')
            list_categories_soup = bs(list_categories_html, 'html.parser')
            category_title = list_categories_soup.find(
                'nav', class_='footer__emissions').find(
                    'div', class_='footer__title').get_text().strip()

            shows.append({
                'label':
                category_title,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='list_shows_2',
                                      title=category_title,
                                      window_title=category_title)
            })

            for category_title, category_type in \
                    CATEGORIES_VIDEOS_TV5MONDE.iteritems():

                shows.append({
                    'label':
                    category_title,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='list_videos_2',
                                          page='1',
                                          title=category_title,
                                          category_type=category_type,
                                          window_title=category_title)
                })

        elif params.channel_name == 'tivi5monde':

            for category_context, category_title in \
                    CATEGORIES_VIDEOS_TIVI5MONDE.iteritems():

                category_url = URL_TIVI5MONDE_ROOT + category_context

                if 'REPLAY' in category_title:
                    value_next = 'list_shows_2'
                else:
                    value_next = 'list_videos_1'

                shows.append({
                    'label':
                    category_title,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next=value_next,
                                          page='0',
                                          title=category_title,
                                          category_url=category_url,
                                          window_title=category_title)
                })

    elif params.next == 'list_shows_2':
        if params.channel_name == 'tv5mondeafrique':

            list_shows_html = utils.get_webcontent(params.category_url)
            list_shows_soup = bs(list_shows_html, 'html.parser')
            list_shows = list_shows_soup.find_all(
                'div', class_='grid-col-12 grid-col-m-4')

            for show in list_shows:

                show_title = show.find('h2').get_text().strip().encode('utf-8')
                show_url = URL_TV5MAF_ROOT + show.find('a').get('href').encode(
                    'utf-8')
                if 'http' in show.find('img').get('src'):
                    show_image = show.find('img').get('src').encode('utf-8')
                else:
                    show_image = URL_TV5MAF_ROOT + show.find('img').get(
                        'src').encode('utf-8')

                shows.append({
                    'label':
                    show_title,
                    'thumb':
                    show_image,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='list_videos_1',
                                          title=show_title,
                                          category_url=show_url,
                                          window_title=show_title)
                })

        elif params.channel_name == 'tv5monde':

            list_categories_html = utils.get_webcontent(URL_TV5MONDE_ROOT)
            list_categories_soup = bs(list_categories_html, 'html.parser')
            list_categories = list_categories_soup.find(
                'nav', class_='footer__emissions').find_all('li')

            for category in list_categories:

                category_title = category.find('a').get_text().strip()
                category_url = URL_TV5MONDE_ROOT + category.find('a').get(
                    'href')

                shows.append({
                    'label':
                    category_title,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='list_videos_1',
                                          page='1',
                                          title=category_title,
                                          category_url=category_url,
                                          window_title=category_title)
                })

        elif params.channel_name == 'tivi5monde':

            list_categories_html = utils.get_webcontent(params.category_url)
            list_categories_soup = bs(list_categories_html, 'html.parser')
            list_categories = list_categories_soup.find_all(
                'div', class_='views-field views-field-nothing')

            for category in list_categories:

                category_title = category.find('h3').find(
                    'a').get_text().strip()
                category_url = URL_TIVI5MONDE_ROOT + category.find('a').get(
                    'href')
                category_image = category.find('img').get('src')

                shows.append({
                    'label':
                    category_title,
                    'thumb':
                    category_image,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='list_videos_1',
                                          page='0',
                                          title=category_title,
                                          category_url=category_url,
                                          window_title=category_title)
                })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        category=common.get_window_title(params))
示例#37
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.channel_name == 'rmcdecouverte':

        all_video = common.ADDON.get_localized_string(30701)

        shows.append({
            'label':
            common.GETTEXT('All videos'),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_videos_1',
                                  all_video=all_video,
                                  window_title=all_video)
        })

    elif params.channel_name == 'bfmparis':

        all_video = common.ADDON.get_localized_string(30701)

        shows.append({
            'label':
            common.GETTEXT('All videos'),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_videos_1',
                                  all_video=all_video,
                                  window_title=all_video)
        })

    else:
        if params.next == 'list_shows_1':
            file_path = utils.download_catalog(
                URL_REPLAY %
                (params.channel_name, get_token(params.channel_name)),
                '%s.json' % (params.channel_name))
            file_categories = open(file_path).read()
            json_categories = json.loads(file_categories)
            json_categories = json_categories['page']['contents'][0]
            json_categories = json_categories['elements'][0]['items']

            for categories in json_categories:
                title = categories['title'].encode('utf-8')
                image_url = categories['image_url'].encode('utf-8')
                category = categories['categories'].encode('utf-8')

                shows.append({
                    'label':
                    title,
                    'thumb':
                    image_url,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          category=category,
                                          next='list_videos_1',
                                          title=title,
                                          page='1',
                                          window_title=title)
                })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        category=common.get_window_title(params))
示例#38
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()
        )
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_cat':
        category_id = params.category_id

        file_path = utils.download_catalog(
            URL_ALL_VOD_NHK % (params.channel_name, get_api_key(params)),
            '%s_all_vod.json' % (params.channel_name))
        file_all_vod = open(file_path).read()
        json_parser = json.loads(file_all_vod)

        for episode in json_parser["data"]["episodes"]:

            episode_to_add = False

            if str(params.category_id) == '0':
                episode_to_add = True
            else:
                for category in episode["category"]:
                    if str(category) == str(params.category_id):
                        episode_to_add = True

            if episode_to_add is True:
                title = episode["title_clean"].encode('utf-8') + ' - ' + \
                    episode["sub_title_clean"].encode('utf-8')
                img = URL_ROOT + episode["image"].encode('utf-8')
                video_id = episode["vod_id"].encode('utf-8')
                plot = episode["description_clean"].encode('utf-8')
                duration = 0
                duration = episode["movie_duration"]

                value_date = time.strftime(
                    '%d %m %Y',
                    time.localtime(int(str(episode["onair"])[:-3])))
                date = str(value_date).split(' ')
                day = date[0]
                mounth = date[1]
                year = date[2]

                date = '.'.join((day, mounth, year))
                aired = '-'.join((year, mounth, day))

                info = {
                    'video': {
                        'title': title,
                        'plot': plot,
                        # 'episode': episode_number,
                        # 'season': season_number,
                        # 'rating': note,
                        'aired': aired,
                        'date': date,
                        'duration': duration,
                        'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    _('Download'), 'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                        action='download_video', video_id=video_id) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    title,
                    'thumb':
                    img,
                    'fanart':
                    img,
                    'url':
                    common.PLUGIN.get_url(action='channel_entry',
                                          next='play_r',
                                          video_id=video_id),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_DATE,
                      common.sp.xbmcplugin.SORT_METHOD_DURATION,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      common.sp.xbmcplugin.SORT_METHOD_GENRE,
                      common.sp.xbmcplugin.SORT_METHOD_PLAYCOUNT,
                      common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        category=common.get_window_title())
示例#40
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_videos_1':

        replay_episodes_html = utils.get_webcontent(params.category_url %
                                                    params.page)
        replay_episodes_soup = bs(replay_episodes_html, 'html.parser')
        episodes = replay_episodes_soup.find(
            'div', class_='video-list').find_all('div', class_='video')

        for episode in episodes:
            video_title = episode.find('a', class_='title').get_text().strip()
            video_url = episode.find('a').get('href')
            video_img = episode.find('img').get('src')
            video_duration = 0

            info = {
                'video': {
                    'title': video_title,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': video_duration,
                    # 'plot': video_plot,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (_('Download'), 'XBMC.RunPlugin(' +
                              common.PLUGIN.get_url(action='download_video',
                                                    video_url=video_url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                video_title,
                'thumb':
                video_img,
                'url':
                common.PLUGIN.get_url(action='channel_entry',
                                      next='play_r',
                                      video_url=video_url),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

        # More videos...
        videos.append({
            'label':
            '# ' + common.ADDON.get_localized_string(30100),
            'url':
            common.PLUGIN.get_url(action='channel_entry',
                                  next='list_videos_1',
                                  category_url=params.category_url,
                                  page=str(int(params.page) + 1),
                                  update_listing=True,
                                  previous_listing=str(videos))
        })

    elif params.next == 'list_videos_2':

        replay_episodes_html = utils.get_webcontent(URL_JSON_ELLE_GIRL_TV %
                                                    params.page)
        episodes_jsonparser = json.loads(replay_episodes_html)

        for episode in episodes_jsonparser:
            video_title = episode["titre"]
            video_url = URL_ROOT_ELLE_GIRL_TV + \
                episode["url"].encode('utf-8')
            video_img = URL_ROOT_ELLE_GIRL_TV + \
                episode["imagePaysage"].encode('utf-8')
            video_duration = 0

            info = {
                'video': {
                    'title': video_title,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': video_duration,
                    # 'plot': video_plot,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (_('Download'), 'XBMC.RunPlugin(' +
                              common.PLUGIN.get_url(action='download_video',
                                                    video_url=video_url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                video_title,
                'thumb':
                video_img,
                'url':
                common.PLUGIN.get_url(action='channel_entry',
                                      next='play_r_elle_girl_tv',
                                      video_url=video_url),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

        # More videos...
        videos.append({
            'label':
            '# ' + common.ADDON.get_localized_string(30100),
            'url':
            common.PLUGIN.get_url(action='channel_entry',
                                  next='list_videos_2',
                                  page=str(int(params.page) + 1),
                                  update_listing=True,
                                  previous_listing=str(videos))
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title())
def list_videos(params):
    """Build videos listing"""
    videos = []

    episodes_html = utils.get_webcontent(params.show_url)
    episodes_soup = bs(episodes_html, 'html.parser')
    list_episodes_datas = {}
    if episodes_soup.find('article', class_='carousel-item row-item fe-top'):
        list_episodes_datas = episodes_soup.find(
            'article',
            class_='carousel-item row-item fe-top').find_all('div',
                                                             class_='item')

    for episode_datas in list_episodes_datas:

        video_title = ''
        if episode_datas.find('img').get('alt'):
            video_title = episode_datas.find('img').get('alt').replace(
                'VIDEO: ', '')
        video_duration = 0
        video_id = episode_datas.find('figure').get('data-id')
        video_img = episode_datas.find('img').get('data-src')

        info = {
            'video': {
                'title': video_title,
                # 'aired': aired,
                # 'date': date,
                'duration': video_duration,
                # 'plot': video_plot,
                # 'year': year,
                'mediatype': 'tvshow'
            }
        }

        download_video = (common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                          common.PLUGIN.get_url(action='download_video',
                                                module_path=params.module_path,
                                                module_name=params.module_name,
                                                video_id=video_id) + ')')
        context_menu = []
        context_menu.append(download_video)

        videos.append({
            'label':
            video_title,
            'thumb':
            video_img,
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='play_r',
                                  video_id=video_id),
            'is_playable':
            True,
            'info':
            info,
            'context_menu':
            context_menu
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        category=common.get_window_title(params))
示例#42
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_videos_1':
        list_videos_html = utils.get_webcontent(
            params.category_url + '?lim_un=%s' % params.page)
        list_videos_soup = bs(list_videos_html, 'html.parser')

        videos_data = list_videos_soup.find_all(
            'div', class_='col-sm-4')

        for video in videos_data:

            title = video.find('h3').get_text()
            plot = ''
            duration = 0
            img = video.find('img').get('src')
            video_url = video.find('a').get('href')

            info = {
                'video': {
                    'title': title,
                    'plot': plot,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': duration,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                _('Download'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='download_video',
                    video_url=video_url) + ')'
            )
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label': title,
                'thumb': img,
                'url': common.PLUGIN.get_url(
                    action='channel_entry',
                    next='play_r',
                    video_url=video_url,
                ),
                'is_playable': True,
                'info': info,
                'context_menu': context_menu
            })

        # More videos...
        videos.append({
            'label': common.ADDON.get_localized_string(30100),
            'url': common.PLUGIN.get_url(
                action='channel_entry',
                next='list_videos_1',
                category_url = params.category_url,
                page=str(int(params.page) + 12),
                update_listing=True,
                previous_listing=str(videos)
            )
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title()
    )
示例#43
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    file_path = utils.download_catalog(
        params.show_url,
        '%s_show_%s.html' % (params.channel_name, params.title))
    replay_show_season_html = open(file_path).read()
    seasons_episodes_soup = bs(replay_show_season_html, 'html.parser')

    # Get data-account
    data_account = re.compile(r'data-account="(.*?)"').findall(
        replay_show_season_html)[0]
    data_player = re.compile(r'data-player="(.*?)"').findall(
        replay_show_season_html)[0]

    if "Series" in params.title:
        # GET VideoId for each episode of season selected
        seasons_episodes = seasons_episodes_soup.find_all(
            'div', class_='spanOneThird vod-episode clearfix ')
        for episode in seasons_episodes:
            if episode.get('data-series') == \
                    params.title.split('Series')[1].strip():

                data_vidid = episode.get('data-vidid')

                video_title = episode.get('data-title')
                video_title = video_title + ' S%sE%s' % (
                    episode.get('data-series'), episode.get('data-episode'))
                video_duration = 0

                video_plot = 'Expire '
                video_plot = video_plot + episode.get('data-publishend').split(
                    'T')[0]
                video_plot = video_plot + '\n' + episode.get(
                    'data-teaser').encode('utf-8')

                video_img = episode.find('img').get('src')

                date_value = episode.get("data-publishstart")
                date_value_list = date_value.split('T')[0].split('-')
                day = date_value_list[2]
                mounth = date_value_list[1]
                year = date_value_list[0]

                date = '.'.join((day, mounth, year))
                aired = '-'.join((year, mounth, day))

                info = {
                    'video': {
                        'title': video_title,
                        'aired': aired,
                        'date': date,
                        'duration': video_duration,
                        'plot': video_plot,
                        'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          data_vidid=data_vidid,
                                          data_account=data_account,
                                          data_player=data_player) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    video_title,
                    'thumb':
                    video_img,
                    'fanart':
                    video_img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='play_r',
                                          data_vidid=data_vidid,
                                          data_account=data_account,
                                          data_player=data_player),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })

        play_episode = seasons_episodes_soup.find(
            'div', class_='spanOneThird vod-episode clearfix playing in')
        if play_episode.get('data-series') == \
                params.title.split('Series')[1].strip():

            data_vidid = play_episode.get('data-vidid')

            video_title = play_episode.get('data-title')
            video_title = video_title + ' S%sE%s' % (play_episode.get(
                'data-series'), play_episode.get('data-episode'))
            video_duration = 0
            video_plot = 'Expire '
            video_plot = video_plot + play_episode.get(
                'data-publishend').split('T')[0] + '\n '
            video_plot = video_plot + play_episode.get('data-teaser').encode(
                'utf-8')
            video_img = play_episode.find('img').get('src')

            date_value = play_episode.get("data-publishstart")
            date_value_list = date_value.split('T')[0].split('-')
            day = date_value_list[2]
            mounth = date_value_list[1]
            year = date_value_list[0]

            date = '.'.join((day, mounth, year))
            aired = '-'.join((year, mounth, day))

            info = {
                'video': {
                    'title': video_title,
                    'aired': aired,
                    'date': date,
                    'duration': video_duration,
                    'plot': video_plot,
                    'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                common.PLUGIN.get_url(action='download_video',
                                      module_path=params.module_path,
                                      module_name=params.module_name,
                                      data_vidid=data_vidid,
                                      data_account=data_account,
                                      data_player=data_player) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                video_title,
                'thumb':
                video_img,
                'fanart':
                video_img,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='play_r',
                                      data_vidid=data_vidid,
                                      data_account=data_account,
                                      data_player=data_player),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

    else:
        play_episode = seasons_episodes_soup.find('div',
                                                  class_='vod-video-container')

        data_vidid = play_episode.find('a').get('data-vidid')

        video_title = play_episode.find('img').get('alt')
        video_duration = 0
        video_plot = seasons_episodes_soup.find(
            'p', class_='teaser').get_text().encode('utf-8')
        video_img = re.compile('itemprop="image" content="(.*?)"').findall(
            replay_show_season_html)[0]

        date_value = re.compile('itemprop="uploadDate" content="(.*?)"'
                                ).findall(replay_show_season_html)[0]
        date_value_list = date_value.split(',')[0].split(' ')
        if len(date_value_list[0]) == 1:
            day = '0' + date_value_list[0]
        else:
            day = date_value_list[0]
        try:
            mounth = CORRECT_MOUNTH[date_value_list[1]]
        except Exception:
            mounth = '00'
        year = date_value_list[2]

        date = '.'.join((day, mounth, year))
        aired = '-'.join((year, mounth, day))

        info = {
            'video': {
                'title': video_title,
                'aired': aired,
                'date': date,
                'duration': video_duration,
                'plot': video_plot,
                'year': year,
                'mediatype': 'tvshow'
            }
        }

        download_video = (common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                          common.PLUGIN.get_url(action='download_video',
                                                module_path=params.module_path,
                                                module_name=params.module_name,
                                                data_vidid=data_vidid,
                                                data_account=data_account,
                                                data_player=data_player) + ')')
        context_menu = []
        context_menu.append(download_video)

        videos.append({
            'label':
            video_title,
            'thumb':
            video_img,
            'fanart':
            video_img,
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='play_r',
                                  data_vidid=data_vidid,
                                  data_account=data_account,
                                  data_player=data_player),
            'is_playable':
            True,
            'info':
            info,
            'context_menu':
            context_menu
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_DURATION,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      common.sp.xbmcplugin.SORT_METHOD_GENRE,
                      common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        category=common.get_window_title(params))
def list_videos(params):
    """Build videos listing"""
    videos = []

    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    url = params.category_url + '&page=' + str(params.page)

    file_path = utils.download_catalog(
        url, '%s_%s_%s.html' %
        (params.channel_name, params.category_name, params.page))
    root_html = open(file_path).read()
    root_soup = bs(root_html, 'html.parser')

    if params.category_name == 'Politique':
        video_soup = root_soup.find_all(
            'article',
            class_="node node-episode node-episode-pse-search-result"
            " theme-4127 clearfix")
    elif params.category_name == 'Société':
        video_soup = root_soup.find_all(
            'article',
            class_="node node-episode node-episode-pse-search-result "
            "theme-4126 clearfix")
    elif params.category_name == 'Débat':
        video_soup = root_soup.find_all(
            'article',
            class_="node node-episode node-episode-pse-search-result "
            "theme-4128 clearfix")

    for video in video_soup:

        # Test Existing Video
        if video.find('div', class_="content").find(
                'div', class_="right").find('div', class_="wrapper-duree"):

            title = ''
            if video.find('div', class_="content").find(
                    'div',
                    class_="field field-name-title-field field-type-text "
                    "field-label-hidden"):
                title = video.find(
                    'div',
                    class_="content"
                ).find(
                    'div',
                    class_="field field-name-field-ref-emission"
                           " field-type-entityreference "
                           "field-label-hidden"
                ).find(
                    'div',
                    class_="field-items"
                ).find(
                    'div',
                    class_="field-item even"
                ).get_text().encode('utf-8') + ' - ' \
                    + video.find(
                        'div',
                        class_="content").find(
                            'div',
                        class_="field field-name-title-field "
                               "field-type-text field-label-hidden").find(
                        'div',
                        class_="field-items").find(
                        'div',
                        class_="field-item even").get_text().encode('utf-8')
            else:
                title = video.find('div', class_="content").find(
                    'div',
                    class_="field field-name-field-ref-emission"
                    " field-type-entityreference "
                    "field-label-hidden").find(
                        'div', class_="field-items").find(
                            'div', class_="field-item even").get_text().encode(
                                'utf-8')

            img = ''
            if video.find('div', class_="content").find(
                    'div', class_="wrapper-visuel").find(
                        'div', class_="scald-atom video").find(
                            'div',
                            class_="field field-name-scald-thumbnail"
                            " field-type-image field-label-hidden"):
                img = video.find('div', class_="content").find(
                    'div', class_="wrapper-visuel").find(
                        'div', class_="scald-atom video").find(
                            'div',
                            class_="field field-name-scald-thumbnail"
                            " field-type-image field-label-hidden").find(
                                'div', class_="field-items").find(
                                    'div', class_="field-item even").find(
                                        'img').get('src')

            plot = ''
            if video.find('div', class_="content").find(
                    'div',
                    class_="field field-name-field-contenu"
                    " field-type-text-long field-label-hidden"):
                plot = video.find('div', class_="content").find(
                    'div',
                    class_="field field-name-field-contenu "
                    "field-type-text-long field-label-hidden").find(
                        'div', class_="field-items").find(
                            'div', class_="field-item even").get_text().encode(
                                'utf-8')

            # value_date = video.find(
            # 'div',
            # class_="content"
            # ).find(
            # 'div',
            # class_='replay__contenu field-group-html-element'
            # ).find(
            # 'div',
            # class_="first-diffusion"
            # ).get_text().encode('utf-8')
            # date = value_date.split(' ')
            # day = date[2]
            # try:
            # mounth = CORRECT_MONTH[date[3]]
            # except Exception:
            # mounth = '00'
            # year = date[4]

            # date = '.'.join((day, mounth, year))
            # aired = '-'.join((year, mounth, day))

            duration = 0
            duration = int(
                video.find('div', class_="content").find(
                    'div', class_="right").find('div', class_="wrapper-duree").
                get_text().encode('utf-8')[:-3]) * 60

            url_video = URL_ROOT + video.find(
                'div', class_="content").find('a').get('href').encode('utf-8')

            info = {
                'video': {
                    'title': title,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': duration,
                    # 'year': year,
                    'plot': plot,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (_('Download'), 'XBMC.RunPlugin(' +
                              common.PLUGIN.get_url(action='download_video',
                                                    url_video=url_video) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                title,
                'thumb':
                img,
                'fanart':
                img,
                'url':
                common.PLUGIN.get_url(action='channel_entry',
                                      next='play_r',
                                      url_video=url_video),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

    # More videos...
    videos.append({
        'label':
        common.ADDON.get_localized_string(30100),
        'url':
        common.PLUGIN.get_url(action='channel_entry',
                              category_url=params.category_url,
                              category_name=params.category_name,
                              next='list_videos_1',
                              page=str(int(params.page) + 1),
                              update_listing=True,
                              previous_listing=str(videos))
    })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_PLAYCOUNT,
                      common.sp.xbmcplugin.SORT_METHOD_DATE,
                      common.sp.xbmcplugin.SORT_METHOD_DURATION,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title())
示例#45
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_1':
        list_videos_html = utils.get_webcontent(params.show_url)
        list_videos_soup = bs(list_videos_html, 'html.parser')

        videos_data = list_videos_soup.find_all('dl', class_='alist')

        for video in videos_data:

            title = video.find('img').get('alt')
            plot = ''
            duration = 0
            img = video.find('img').get('src')
            video_url = video.find('a').get('href')
            video_url = re.compile(r'\(\'(.*?)\'\)').findall(video_url)[0]

            info = {
                'video': {
                    'title': title,
                    'plot': plot,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': duration,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (_('Download'), 'XBMC.RunPlugin(' +
                              common.PLUGIN.get_url(action='download_video',
                                                    video_url=video_url) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                title,
                'thumb':
                img,
                'url':
                common.PLUGIN.get_url(
                    action='channel_entry',
                    next='play_r',
                    video_url=video_url,
                ),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        category=common.get_window_title())
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_1':
        list_videos_html = utils.get_webcontent(
            params.category_url)
        list_videos_soup = bs(list_videos_html, 'html.parser')

        videos_data = list_videos_soup.find_all(
            'div', class_='item')

        for video in videos_data:

            title = video.find('h4').get_text()
            plot = video.find('p').get_text()
            duration = 0
            img = video.find('img').get('src')
            video_id = video.get('data-mediaid')

            info = {
                'video': {
                    'title': title,
                    'plot': plot,
                    # 'aired': aired,
                    # 'date': date,
                    'duration': duration,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='download_video',
                    module_path=params.module_path,
                    module_name=params.module_name,
                    video_id=video_id) + ')'
            )
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label': title,
                'thumb': img,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='play_r',
                    video_id=video_id,
                ),
                'is_playable': True,
                'info': info,
                'context_menu': context_menu
            })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        content='tvshows',
        category=common.get_window_title(params)
    )
示例#47
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_emission':

        file_path = utils.download_catalog(
            URL_JSON_EMISSION_BY_ID % params.emission_id,
            'url_videos_emission_%s.html' % params.emission_id)
        videos_json = open(file_path).read()
        videos_jsonparser = json.loads(videos_json)

        for video in videos_jsonparser['data']:

            if video["subtitle"]:
                title = video["title"].encode('utf-8') + \
                    ' - ' + video["subtitle"].encode('utf-8')
            else:
                title = video["title"].encode('utf-8')
            img = URL_ROOT_IMAGE_RTBF + video["thumbnail"]["full_medium"]
            url_video = video["urlHls"]
            if 'drm' in url_video:
                # the following url is not drm protected
                url_video = video["urlHlsAes128"]
            plot = ''
            if video["description"]:
                plot = video["description"].encode('utf-8')
            duration = 0
            duration = video["durations"]

            value_date = time.strftime('%d %m %Y',
                                       time.localtime(video["liveFrom"]))
            date = str(value_date).split(' ')
            day = date[0]
            mounth = date[1]
            year = date[2]

            date = '.'.join((day, mounth, year))
            aired = '-'.join((year, mounth, day))

            info = {
                'video': {
                    'title': title,
                    'plot': plot,
                    # 'episode': episode_number,
                    # 'season': season_number,
                    # 'rating': note,
                    'aired': aired,
                    'date': date,
                    'duration': duration,
                    'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                common.PLUGIN.get_url(action='download_video',
                                      module_path=params.module_path,
                                      module_name=params.module_name,
                                      url_video=url_video) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                title,
                'thumb':
                img,
                'fanart':
                img,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='play_r',
                                      url_video=url_video),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu
            })

    elif params.next == 'list_videos_categorie':

        file_path = utils.get_webcontent(params.category_url)
        episodes_soup = bs(file_path, 'html.parser')
        list_categories = episodes_soup.find_all('section',
                                                 class_="js-item-container")

        for select_category_value in list_categories:
            if select_category_value.get('id') == params.sub_category_id:

                list_episodes = select_category_value.find_all('article')

                for episode in list_episodes:

                    if episode.get('data-type') == 'media':
                        if episode.find('h4'):
                            title = episode.find('h3').find(
                                'a').get('title') + ' - ' + \
                                episode.find('h4').get_text()
                        else:
                            title = episode.find('h3').find('a').get('title')
                        duration = 0
                        video_id = episode.get('data-id')
                        all_images = episode.find('img').get(
                            'data-srcset').split(',')
                        for image in all_images:
                            img = image.split(' ')[0]

                        info = {
                            'video': {
                                'title': title,
                                # 'plot': plot,
                                # 'episode': episode_number,
                                # 'season': season_number,
                                # 'rating': note,
                                # 'aired': aired,
                                # 'date': date,
                                'duration': duration,
                                # 'year': year,
                                'mediatype': 'tvshow'
                            }
                        }

                        download_video = (common.GETTEXT('Download'),
                                          'XBMC.RunPlugin(' +
                                          common.PLUGIN.get_url(
                                              action='download_video',
                                              module_path=params.module_path,
                                              module_name=params.module_name,
                                              video_id=video_id) + ')')
                        context_menu = []
                        context_menu.append(download_video)

                        videos.append({
                            'label':
                            title,
                            'thumb':
                            img,
                            'fanart':
                            img,
                            'url':
                            common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                next='play_r_categorie',
                                video_id=video_id),
                            'is_playable':
                            True,
                            'info':
                            info,
                            'context_menu':
                            context_menu
                        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_DATE),
        content='tvshows',
        category=common.get_window_title(params))
def list_shows(params):
    """Build categories listing"""
    shows = []
    if 'previous_listing' in params:
        shows = ast.literal_eval(params['previous_listing'])

    unique_item = dict()

    real_channel = params.channel_name
    if params.channel_name == 'la_1ere':
        real_channel = 'la_1ere_reunion%2C' \
                       'la_1ere_guyane%2C' \
                       'la_1ere_polynesie%2C' \
                       'la_1ere_martinique%2C' \
                       'la_1ere_mayotte%2C' \
                       'la_1ere_nouvellecaledonie%2C' \
                       'la_1ere_guadeloupe%2C' \
                       'la_1ere_wallisetfutuna%2C' \
                       'la_1ere_saintpierreetmiquelon'

    # Level 0
    if params.next == 'list_shows_root':

        json_filepath = utils.download_catalog(
            CHANNEL_CATALOG % (real_channel),
            '%s.json' % (params.channel_name))
        with open(json_filepath) as json_file:
            json_parser = json.load(json_file)

        emissions = json_parser['reponse']['emissions']
        for emission in emissions:
            rubrique = emission['rubrique'].encode('utf-8')
            if rubrique not in unique_item:
                unique_item[rubrique] = rubrique
                rubrique_title = change_to_nicer_name(rubrique)

                shows.append({
                    'label':
                    rubrique_title,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          rubrique=rubrique,
                                          next='list_shows_2_cat',
                                          window_title=rubrique_title)
                })

        # Last videos
        shows.append({
            'label':
            common.GETTEXT('Last videos'),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_shows_last',
                                  page='0',
                                  window_title=common.GETTEXT('Last videos'))
        })

        # Search videos
        shows.append({
            'label':
            common.GETTEXT('Search videos'),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='search',
                                  window_title=common.GETTEXT('Search videos'),
                                  is_folder=False)
        })

        # from A to Z
        shows.append({
            'label':
            common.GETTEXT('From A to Z'),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_shows_from_a_to_z',
                                  window_title=common.GETTEXT('From A to Z'))
        })

    # level 1
    elif 'list_shows_from_a_to_z' in params.next:
        shows.append({
            'label':
            common.GETTEXT('Ascending'),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_shows_2_from_a_to_z_CATEGORIES',
                                  page='0',
                                  url=URL_ALPHA % ('asc', '%s'),
                                  sens='asc',
                                  window_title=params.window_title)
        })
        shows.append({
            'label':
            common.GETTEXT('Descending'),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_shows_2_from_a_to_z_CATEGORIES',
                                  page='0',
                                  url=URL_ALPHA % ('desc', '%s'),
                                  sens='desc',
                                  window_title=params.window_title)
        })

    # level 1
    elif 'list_shows_last' in params.next:
        for title, url in CATEGORIES.iteritems():
            if 'Toutes catégories' in title:
                url = url % (params.channel_name, '%s')
            shows.append({
                'label':
                title,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='list_videos_last',
                                      page='0',
                                      url=url,
                                      title=title,
                                      window_title=title)
            })

    # level 1 or 2
    elif 'list_shows_2' in params.next:

        if 'list_shows_2_cat' in params.next:
            json_filepath = utils.download_catalog(
                CHANNEL_CATALOG % (real_channel),
                '%s.json' % (params.channel_name))

        elif 'list_shows_2_from_a_to_z_CATEGORIES' in params.next:
            json_filepath = utils.download_catalog(
                URL_ALPHA % (params.sens, params.page), '%s_%s_%s_alpha.json' %
                (params.channel_name, params.sens, params.page))

        with open(json_filepath) as json_file:
            json_parser = json.load(json_file)
        emissions = json_parser['reponse']['emissions']
        for emission in emissions:
            rubrique = emission['rubrique'].encode('utf-8')
            chaine_id = emission['chaine_id'].encode('utf-8')
            if ('from_a_to_z' in params.next and
                    chaine_id == params.channel_name) or \
                    rubrique == params.rubrique:
                titre_programme = emission['titre_programme'].encode('utf-8')
                if titre_programme != '':
                    id_programme = emission['id_programme'].encode('utf-8')
                    if id_programme == '':
                        id_programme = emission['id_emission'].encode('utf-8')
                    if id_programme not in unique_item:
                        unique_item[id_programme] = id_programme
                        icon = URL_IMG % (emission['image_large'])
                        genre = emission['genre']
                        accroche_programme = emission['accroche_programme']

                        info = {
                            'video': {
                                'title': titre_programme,
                                'plot': accroche_programme,
                                'genre': genre
                            }
                        }
                        shows.append({
                            'label':
                            titre_programme,
                            'thumb':
                            icon,
                            'fanart':
                            icon,
                            'url':
                            common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                next='list_videos_1',
                                id_programme=id_programme,
                                page='0',
                                window_title=titre_programme,
                                fanart=icon),
                            'info':
                            info
                        })
        if params.next == 'list_shows_2_from_a_to_z_CATEGORIES':
            # More videos...
            shows.append({
                'label':
                common.ADDON.get_localized_string(30700),
                'url':
                common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='list_shows_2_from_a_to_z_CATEGORIES',
                    sens=params.sens,
                    page=str(int(params.page) + 100),
                    window_title=params.window_title,
                    update_listing=True,
                    previous_listing=str(shows))
            })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
示例#49
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_1':

        videos_datas_xml = utils.get_webcontent(params.category_url)
        xml_elements = ET.XML(videos_datas_xml)

        for video in xml_elements.findall(".//event"):

            video_links = video.findall(".//link")
            video_url = ''
            for video_link in video_links:
                if 'Video' in video_link.text.encode('utf-8'):
                    video_url = video_link.get('href')

            if video_url != '':
                video_title = video.find("title").text.encode('utf-8')
                video_duration = 0
                video_plot = ''
                if video.find("abstract").text:
                    video_plot = video.find("abstract").text.encode('utf-8')

                info = {
                    'video': {
                        'title': video_title,
                        # 'aired': aired,
                        # 'date': date,
                        'duration': video_duration,
                        'plot': video_plot,
                        # 'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          video_url=video_url) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    video_title,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='website_entry',
                                          next='play_r',
                                          video_url=video_url),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if 'search' in params.next:
        url_search = URL_SEARCH_VIDEOS
        body = "{\"params\": \"filters=class:video&page=%s&query=%s\"}" % (
            params.page, params.query)

        result = utils.get_webcontent(url_search,
                                      request_type='post',
                                      specific_headers=HEADERS_YATTA,
                                      post_dic=body)

        json_d = json.loads(result)
        nb_pages = json_d['nbPages']
        for hit in json_d['hits']:
            label = hit['program']['label']
            title = hit['title']
            headline = hit['headline_title']
            desc = hit['description']
            duration = hit['duration']
            season = hit['season_number']
            episode = hit['episode_number']
            id_yatta = hit['id']
            director = hit['director']
            # producer = hit['producer']
            presenter = hit['presenter']
            casting = hit['casting']
            # characters = hit['characters']
            last_publication_date = hit['dates']['last_publication_date']
            image_400 = hit['image']['formats']['vignette_16x9']['urls'][
                'w:400']
            image_1024 = hit['image']['formats']['vignette_16x9']['urls'][
                'w:1024']

            url_root = 'http://api-front.yatta.francetv.fr'
            image_400 = url_root + image_400
            image_1024 = url_root + image_1024

            title = label + ' - ' + title
            if headline and headline != '':
                desc = headline + '\n' + desc

            if not director:
                director = presenter

            info = {
                'video': {
                    'title':
                    title,
                    'plot':
                    desc,
                    'aired':
                    time.strftime('%Y-%m-%d',
                                  time.localtime(last_publication_date)),
                    'date':
                    time.strftime('%d.%m.%Y',
                                  time.localtime(last_publication_date)),
                    'duration':
                    duration,
                    'year':
                    time.strftime('%Y', time.localtime(last_publication_date)),
                    'mediatype':
                    'tvshow',
                    'season':
                    season,
                    'episode':
                    episode,
                    'cast':
                    casting.split(', '),
                    'director':
                    director
                }
            }

            download_video = (
                common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                common.PLUGIN.get_url(action='download_video',
                                      module_path=params.module_path,
                                      module_name=params.module_name,
                                      id_yatta=id_yatta) + ')')
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label':
                title,
                'fanart':
                image_1024,
                'thumb':
                image_400,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='play_r',
                                      id_yatta=id_yatta),
                'is_playable':
                True,
                'info':
                info,
                'context_menu':
                context_menu,
                # 'subtitles': 'subtitles'
            })

        if int(params.page) != nb_pages - 1:
            # More videos...
            videos.append({
                'label':
                common.ADDON.get_localized_string(30700),
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next=params.next,
                                      query=params.query,
                                      page=str(int(params.page) + 1),
                                      window_title=params.window_title,
                                      update_listing=True,
                                      previous_listing=str(videos))
            })

        return common.PLUGIN.create_listing(
            videos,
            sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                          common.sp.xbmcplugin.SORT_METHOD_DATE,
                          common.sp.xbmcplugin.SORT_METHOD_DURATION,
                          common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                          common.sp.xbmcplugin.SORT_METHOD_EPISODE),
            content='tvshows',
            update_listing='update_listing' in params,
            category=common.get_window_title(params))

    elif 'last' in params.next:
        json_filepath = utils.download_catalog(
            params.url % params.page, '%s_%s_%s_last.json' %
            (params.channel_name, params.page, params.title))

    elif 'from_a_to_z' in params.next:
        json_filepath = utils.download_catalog(
            params.url % params.page, '%s_%s_%s_last.json' %
            (params.channel_name, params.page, params.sens))

    else:
        json_filepath = utils.download_catalog(
            CHANNEL_CATALOG % params.channel_name,
            '%s.json' % params.channel_name)
    with open(json_filepath) as json_file:
        json_parser = json.load(json_file)

    emissions = json_parser['reponse']['emissions']
    for emission in emissions:
        id_programme = emission['id_programme'].encode('utf-8')
        if id_programme == '':
            id_programme = emission['id_emission'].encode('utf-8')
        if 'search' in params.next \
                or 'last' in params.next \
                or 'from_a_to_z' in params.next \
                or id_programme == params.id_programme:
            title = ''
            plot = ''
            duration = 0
            date = ''
            genre = ''
            id_diffusion = emission['id_diffusion']
            chaine_id = emission['chaine_id'].encode('utf-8')

            # If we are in search or alpha or last videos cases,
            # only add channel's shows
            if 'search' in params.next or\
                    'from_a_to_z' in params.next or\
                    'last' in params.next:
                if chaine_id != params.channel_name:
                    continue

            file_prgm = utils.get_webcontent(SHOW_INFO %
                                             (emission['id_diffusion']))
            if (file_prgm != ''):
                json_parser_show = json.loads(file_prgm)
                if json_parser_show['synopsis']:
                    plot = json_parser_show['synopsis'].encode('utf-8')
                if json_parser_show['diffusion']['date_debut']:
                    date = json_parser_show['diffusion']['date_debut']
                    date = date.encode('utf-8')
                if json_parser_show['real_duration']:
                    duration = int(json_parser_show['real_duration'])
                if json_parser_show['titre']:
                    title = json_parser_show['titre'].encode('utf-8')
                if json_parser_show['sous_titre']:
                    title = ' '.join(
                        (title, '- [I]',
                         json_parser_show['sous_titre'].encode('utf-8'),
                         '[/I]'))

                if json_parser_show['genre'] != '':
                    genre = \
                        json_parser_show['genre'].encode('utf-8')

                subtitles = []
                if json_parser_show['subtitles']:
                    subtitles_list = json_parser_show['subtitles']
                    for subtitle in subtitles_list:
                        if subtitle['format'] == 'vtt':
                            subtitles.append(subtitle['url'].encode('utf-8'))

                episode = 0
                if 'episode' in json_parser_show:
                    episode = json_parser_show['episode']

                season = 0
                if 'saison' in json_parser_show:
                    season = json_parser_show['saison']

                cast = []
                director = ''
                personnes = json_parser_show['personnes']
                for personne in personnes:
                    fonctions = ' '.join(
                        x.encode('utf-8') for x in personne['fonctions'])
                    if 'Acteur' in fonctions:
                        cast.append(personne['nom'].encode('utf-8') + ' ' +
                                    personne['prenom'].encode('utf-8'))
                    elif 'Réalisateur' in fonctions:
                        director = personne['nom'].encode(
                            'utf-8') + ' ' + \
                            personne['prenom'].encode('utf-8')

                year = int(date[6:10])
                day = date[:2]
                month = date[3:5]
                date = '.'.join((day, month, str(year)))
                aired = '-'.join((str(year), month, day))
                # date: string (%d.%m.%Y / 01.01.2009)
                # aired: string (2008-12-07)

                # image = URL_IMG % (json_parserShow['image'])
                image = json_parser_show['image_secure']

                info = {
                    'video': {
                        'title': title,
                        'plot': plot,
                        'aired': aired,
                        'date': date,
                        'duration': duration,
                        'year': year,
                        'genre': genre,
                        'mediatype': 'tvshow',
                        'season': season,
                        'episode': episode,
                        'cast': cast,
                        'director': director
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          id_diffusion=id_diffusion) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    title,
                    'fanart':
                    image,
                    'thumb':
                    image,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='play_r',
                                          id_diffusion=id_diffusion),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu,
                    'subtitles':
                    subtitles
                })

    if 'last' in params.next:
        # More videos...
        videos.append({
            'label':
            common.ADDON.get_localized_string(30700),
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  url=params.url,
                                  next=params.next,
                                  page=str(int(params.page) + 20),
                                  title=params.title,
                                  window_title=params.window_title,
                                  update_listing=True,
                                  previous_listing=str(videos))
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_DATE,
                      common.sp.xbmcplugin.SORT_METHOD_DURATION,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      common.sp.xbmcplugin.SORT_METHOD_EPISODE),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
示例#51
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if 'meteo.tf1.fr/meteo-france' in params.program_url:
        program_html = utils.get_webcontent(params.program_url)
        program_soup = bs(program_html, 'html.parser')

        wat_info = program_soup.find('td', class_='textbase')

        title = wat_info.find('h3').get_text()

        program_id = re.compile('; src = \'(.*?)\?').findall(program_html)[0]

        info = {
            'video': {
                'title': title,
                # 'plot': stitle,
                # 'aired': aired,
                # 'date': date,
                # 'duration': duration,
                # 'year': int(aired[:4]),
                'mediatype': 'tvshow'
            }
        }

        download_video = (('Download'), 'XBMC.RunPlugin(' +
                          common.PLUGIN.get_url(action='download_video',
                                                module_path=params.module_path,
                                                module_name=params.module_name,
                                                program_id=program_id) + ')')
        context_menu = []
        context_menu.append(download_video)

        videos.append({
            'label':
            title,
            # 'thumb': img,
            'url':
            common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                next='play_r',
                program_id=program_id,
            ),
            'is_playable':
            True,
            'info':
            info,
            'context_menu':
            context_menu
        })
    else:
        if params.page == '1':
            url = ''.join((params.program_url, '/videos', '?filter=',
                           params.category_id))
        else:
            url = ''.join((params.program_url, '/videos/%s' % params.page,
                           '?filter=', params.category_id))
        program_html = utils.get_webcontent(url)
        program_soup = bs(program_html, 'html.parser')

        grid = program_soup.find('ul', class_='grid')

        if grid is not None:
            for li in grid.find_all('li'):
                video_type_string = li.find('div', class_='description').find(
                    'a')['data-xiti-libelle'].encode('utf-8')
                video_type_string = video_type_string.split('-')[0]

                if 'Playlist' not in video_type_string:
                    title = li.find('p',
                                    class_='title').get_text().encode('utf-8')

                    try:
                        stitle = li.find(
                            'p', class_='stitle').get_text().encode('utf-8')
                    except Exception:
                        stitle = ''

                    try:
                        duration_soup = li.find('p', class_='uptitle').find(
                            'span', class_='momentDate')
                        duration = int(
                            duration_soup.get_text().encode('utf-8'))
                    except Exception:
                        duration = 0

                    img = li.find('img')
                    try:
                        img = img['data-srcset'].encode('utf-8')
                    except Exception:
                        img = img['srcset'].encode('utf-8')

                    img = 'http:' + img.split(',')[-1].split(' ')[0]

                    try:
                        date_soup = li.find('div', class_='text').find(
                            'p', class_='uptitle').find('span')

                        aired = date_soup['data-date'].encode('utf-8').split(
                            'T')[0]
                        day = aired.split('-')[2]
                        mounth = aired.split('-')[1]
                        year = aired.split('-')[0]
                        date = '.'.join((day, mounth, year))
                        # date : string (%d.%m.%Y / 01.01.2009)
                        # aired : string (2008-12-07)

                    except Exception:
                        date = ''
                        aired = ''
                        year = 0

                    program_id = li.find('a')['href'].encode('utf-8')

                    info = {
                        'video': {
                            'title': title,
                            'plot': stitle,
                            'aired': aired,
                            'date': date,
                            'duration': duration,
                            'year': int(aired[:4]),
                            'mediatype': 'tvshow'
                        }
                    }

                    download_video = (
                        common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                        common.PLUGIN.get_url(action='download_video',
                                              module_path=params.module_path,
                                              module_name=params.module_name,
                                              program_id=program_id) + ')')
                    context_menu = []
                    context_menu.append(download_video)

                    videos.append({
                        'label':
                        title,
                        'thumb':
                        img,
                        'url':
                        common.PLUGIN.get_url(
                            module_path=params.module_path,
                            module_name=params.module_name,
                            action='replay_entry',
                            next='play_r',
                            program_id=program_id,
                        ),
                        'is_playable':
                        True,
                        'info':
                        info,
                        'context_menu':
                        context_menu
                    })

        if int(params.page) < int(params.last_page):
            # More videos...
            videos.append({
                'label':
                common.ADDON.get_localized_string(30700),
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      program_url=params.program_url,
                                      category_id=params.category_id,
                                      last_page=params.last_page,
                                      next='list_videos',
                                      page=str(int(params.page) + 1),
                                      update_listing=True,
                                      previous_listing=str(videos))
            })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_DATE,
                      common.sp.xbmcplugin.SORT_METHOD_DURATION,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title())
示例#52
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_videos_1':
        if params.channel_name == 'tv5mondeafrique':

            replay_videos_html = utils.get_webcontent(params.category_url)
            replay_videos_soup = bs(replay_videos_html, 'html.parser')
            if replay_videos_soup.find(
                    'div', class_='u-bg--concrete u-pad-t--xl u-pad-b--l') \
                    is None:

                data_video = replay_videos_soup.find('div',
                                                     class_='tv5-player')

                video_title = data_video.find('h1').get_text().strip().encode(
                    'utf-8')
                video_img = re.compile(r'image\" content=\"(.*?)\"').findall(
                    replay_videos_html)[0]
                video_plot = data_video.find(
                    'div',
                    class_='tv5-desc to-expand u-mg-t--m u-mg-b--s').get_text(
                    ).strip().encode('utf-8')

                info = {
                    'video': {
                        'title': video_title,
                        # 'aired': aired,
                        # 'date': date,
                        # 'duration': video_duration,
                        'plot': video_plot,
                        # 'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          video_url=params.category_url) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    video_title,
                    'thumb':
                    video_img,
                    'fanart':
                    video_img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='play_r',
                                          video_url=params.category_url),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })
            else:
                seasons = replay_videos_soup.find(
                    'div',
                    class_='tv5-pagerTop tv5-pagerTop--green').find_all('a')
                if len(seasons) > 1:

                    for season in seasons:

                        video_title = 'Saison ' + season.get_text()
                        video_url = URL_TV5MAF_ROOT + season.get(
                            'href').encode('utf-8')

                        info = {'video': {'title': video_title}}

                        videos.append({
                            'label':
                            video_title,
                            'url':
                            common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                next='list_videos_2',
                                category_url=video_url),
                            'is_playable':
                            False,
                            'info':
                            info
                        })
                else:
                    all_videos = replay_videos_soup.find(
                        'div', class_='u-bg--concrete u-pad-t--xl u-pad-b--l'
                    ).find_all('div', 'grid-col-12 grid-col-m-4')

                    for video in all_videos:

                        video_title = video.find(
                            'h2').get_text().strip().encode('utf-8')
                        video_img = video.find('img').get('src')
                        video_url = URL_TV5MAF_ROOT + video.find('a').get(
                            'href').encode('utf-8')

                        info = {
                            'video': {
                                'title': video_title,
                                # 'aired': aired,
                                # 'date': date,
                                # 'duration': video_duration,
                                # 'plot': video_plot,
                                # 'year': year,
                                'mediatype': 'tvshow'
                            }
                        }

                        download_video = (common.GETTEXT('Download'),
                                          'XBMC.RunPlugin(' +
                                          common.PLUGIN.get_url(
                                              action='download_video',
                                              module_path=params.module_path,
                                              module_name=params.module_name,
                                              video_url=video_url) + ')')
                        context_menu = []
                        context_menu.append(download_video)

                        videos.append({
                            'label':
                            video_title,
                            'thumb':
                            video_img,
                            'url':
                            common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                next='play_r',
                                video_url=video_url),
                            'is_playable':
                            True,
                            'info':
                            info,
                            'context_menu':
                            context_menu
                        })

        elif params.channel_name == 'tv5monde':

            replay_videos_html = utils.get_webcontent(params.category_url +
                                                      '?page=%s' % params.page)
            replay_videos_soup = bs(replay_videos_html, 'html.parser')

            all_videos = replay_videos_soup.find_all('article')

            for video in all_videos:

                if video.find('p', class_='video-item__subtitle'):
                    video_title = video.find('h3').get_text().strip(
                    ) + ' - ' + video.find(
                        'p', class_='video-item__subtitle').get_text().strip()
                else:
                    video_title = video.find('h3').get_text().strip()
                if 'http' in video.find('img').get('src'):
                    video_img = video.find('img').get('src')
                else:
                    video_img = URL_TV5MONDE_ROOT + video.find('img').get(
                        'src')
                video_url = URL_TV5MONDE_ROOT + video.find('a').get('href')

                info = {
                    'video': {
                        'title': video_title,
                        # 'aired': aired,
                        # 'date': date,
                        # 'duration': video_duration,
                        # 'plot': video_plot,
                        # 'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          video_url=video_url) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    video_title,
                    'thumb':
                    video_img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='play_r',
                                          video_url=video_url),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })

            # More videos...
            videos.append({
                'label':
                common.ADDON.get_localized_string(30700),
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      category_url=params.category_url,
                                      next=params.next,
                                      page=str(int(params.page) + 1),
                                      title=params.title,
                                      window_title=params.window_title,
                                      update_listing=True,
                                      previous_listing=str(videos))
            })

        elif params.channel_name == 'tivi5monde':

            replay_videos_html = utils.get_webcontent(params.category_url +
                                                      '?page=%s' % params.page)
            replay_videos_soup = bs(replay_videos_html, 'html.parser')

            all_videos = replay_videos_soup.find_all('div',
                                                     class_='row-vignette')

            for video in all_videos:

                video_title = video.find('img').get('alt')
                video_img = video.find('img').get('src')
                video_url = URL_TIVI5MONDE_ROOT + video.find('a').get('href')

                info = {
                    'video': {
                        'title': video_title,
                        # 'aired': aired,
                        # 'date': date,
                        # 'duration': video_duration,
                        # 'plot': video_plot,
                        # 'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          video_url=video_url) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    video_title,
                    'thumb':
                    video_img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='play_r_tivi5monde',
                                          video_url=video_url),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })

            # More videos...
            videos.append({
                'label':
                common.ADDON.get_localized_string(30700),
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      category_url=params.category_url,
                                      next=params.next,
                                      page=str(int(params.page) + 1),
                                      title=params.title,
                                      window_title=params.window_title,
                                      update_listing=True,
                                      previous_listing=str(videos))
            })

    elif params.next == 'list_videos_2':
        if params.channel_name == 'tv5mondeafrique':
            replay_videos_html = utils.get_webcontent(params.category_url)
            replay_videos_soup = bs(replay_videos_html, 'html.parser')

            all_videos = replay_videos_soup.find(
                'div',
                class_='u-bg--concrete u-pad-t--xl u-pad-b--l').find_all(
                    'div', 'grid-col-12 grid-col-m-4')

            for video in all_videos:

                video_title = video.find('h2').get_text().strip().encode(
                    'utf-8')
                video_img = video.find('img').get('src')
                video_url = URL_TV5MAF_ROOT + video.find('a').get(
                    'href').encode('utf-8')

                info = {
                    'video': {
                        'title': video_title,
                        # 'aired': aired,
                        # 'date': date,
                        # 'duration': video_duration,
                        # 'plot': video_plot,
                        # 'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                    common.PLUGIN.get_url(action='download_video',
                                          module_path=params.module_path,
                                          module_name=params.module_name,
                                          video_url=video_url) + ')')
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label':
                    video_title,
                    'thumb':
                    video_img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          next='play_r',
                                          video_url=video_url),
                    'is_playable':
                    True,
                    'info':
                    info,
                    'context_menu':
                    context_menu
                })

        elif params.channel_name == 'tv5monde':

            replay_videos_html = utils.get_webcontent(
                URL_TV5MONDE_ROOT +
                '/toutes-les-videos?order=1&type=%s&page=%s' %
                (params.category_type, params.page))
            replay_videos_soup = bs(replay_videos_html, 'html.parser')

            all_videos = replay_videos_soup.find_all('article')

            for video in all_videos:

                if video.find('a',
                              class_='video-item__link').get('href') != '':

                    if video.find('p', class_='video-item__subtitle'):
                        video_title = video.find('h3').get_text().strip(
                        ) + ' - ' + video.find(
                            'p',
                            class_='video-item__subtitle').get_text().strip()
                    else:
                        video_title = video.find('h3').get_text().strip()
                    if 'http' in video.find('img').get('src'):
                        video_img = video.find('img').get('src')
                    else:
                        video_img = URL_TV5MONDE_ROOT + video.find('img').get(
                            'src')
                    video_url = URL_TV5MONDE_ROOT + video.find('a').get('href')

                    info = {
                        'video': {
                            'title': video_title,
                            # 'aired': aired,
                            # 'date': date,
                            # 'duration': video_duration,
                            # 'plot': video_plot,
                            # 'year': year,
                            'mediatype': 'tvshow'
                        }
                    }

                    download_video = (
                        common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                        common.PLUGIN.get_url(action='download_video',
                                              module_path=params.module_path,
                                              module_name=params.module_name,
                                              video_url=video_url) + ')')
                    context_menu = []
                    context_menu.append(download_video)

                    videos.append({
                        'label':
                        video_title,
                        'thumb':
                        video_img,
                        'url':
                        common.PLUGIN.get_url(module_path=params.module_path,
                                              module_name=params.module_name,
                                              action='replay_entry',
                                              next='play_r',
                                              video_url=video_url),
                        'is_playable':
                        True,
                        'info':
                        info,
                        'context_menu':
                        context_menu
                    })

            # More videos...
            videos.append({
                'label':
                common.ADDON.get_localized_string(30700),
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next=params.next,
                                      page=str(int(params.page) + 1),
                                      category_type=params.category_type,
                                      title=params.title,
                                      window_title=params.window_title,
                                      update_listing=True,
                                      previous_listing=str(videos))
            })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params))
示例#53
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.next == 'list_videos_emission':

        file_path = utils.download_catalog(
            URL_JSON_EMISSION_BY_ID % params.emission_id,
            'url_videos_emission_%s.html' % params.emission_id)
        videos_json = open(file_path).read()
        videos_jsonparser = json.loads(videos_json)

        for video in videos_jsonparser['data']:

            if video["subtitle"]:
                title = video["title"].encode('utf-8') + \
                    ' - ' + video["subtitle"].encode('utf-8')
            else:
                title = video["title"].encode('utf-8')
            img = URL_ROOT_IMAGE_RTBF + video["thumbnail"]["full_medium"]
            url_video = video["urlHls"]
            plot = ''
            if video["description"]:
                plot = video["description"].encode('utf-8')
            duration = 0
            duration = video["durations"]

            value_date = time.strftime(
                '%d %m %Y', time.localtime(video["liveFrom"]))
            date = str(value_date).split(' ')
            day = date[0]
            mounth = date[1]
            year = date[2]

            date = '.'.join((day, mounth, year))
            aired = '-'.join((year, mounth, day))

            info = {
                'video': {
                    'title': title,
                    'plot': plot,
                    # 'episode': episode_number,
                    # 'season': season_number,
                    # 'rating': note,
                    'aired': aired,
                    'date': date,
                    'duration': duration,
                    'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='download_video',
                    module_path=params.module_path,
                    module_name=params.module_name,
                    url_video=url_video) + ')'
            )
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label': title,
                'thumb': img,
                'fanart': img,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='replay_entry',
                    next='play_r',
                    url_video=url_video
                ),
                'is_playable': True,
                'info': info,
                'context_menu': context_menu
            })

    elif params.next == 'list_videos_categorie':

        file_path = utils.get_webcontent(params.category_url)
        episodes_soup = bs(file_path, 'html.parser')
        list_episodes = episodes_soup.find_all('article')

        for episode in list_episodes:

            if episode.get('data-type') == 'media':
                if episode.find('h4'):
                    title = episode.find('h3').find(
                        'a').get('title') + ' - ' + \
                        episode.find('h4').get_text()
                else:
                    title = episode.find('h3').find('a').get('title')
                duration = 0
                video_id = episode.get('data-id')
                all_images = episode.find('img').get(
                    'data-srcset').split(',')
                for image in all_images:
                    img = image.split(' ')[0]

                info = {
                    'video': {
                        'title': title,
                        # 'plot': plot,
                        # 'episode': episode_number,
                        # 'season': season_number,
                        # 'rating': note,
                        # 'aired': aired,
                        # 'date': date,
                        'duration': duration,
                        # 'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'),
                    'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                        action='download_video',
                        module_path=params.module_path,
                        module_name=params.module_name,
                        video_id=video_id) + ')'
                )
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label': title,
                    'thumb': img,
                    'fanart': img,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        next='play_r_categorie',
                        video_id=video_id
                    ),
                    'is_playable': True,
                    'info': info,
                    'context_menu': context_menu
                })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_DATE
        ),
        content='tvshows',
        category=common.get_window_title()
    )
示例#54
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.channel_name == 'lci':

        file_path = utils.download_catalog(URL_LCI_REPLAY,
                                           params.channel_name + '.html')
        root_html = open(file_path).read()
        root_soup = bs(root_html, 'html.parser')

        if params.next == 'list_shows_1':
            programs_soup = root_soup.find(
                'ul', attrs={'class': 'topic-chronology-milestone-component'})
            for program in programs_soup.find_all('li'):
                program_url = URL_LCI_ROOT + program.find('a')['href'].encode(
                    'utf-8')
                program_name = program.find(
                    'h2', class_='text-block').get_text().encode('utf-8')
                img = program.find_all('source')[0]
                try:
                    img = img['data-srcset'].encode('utf-8')
                except Exception:
                    img = img['srcset'].encode('utf-8')

                img = img.split(',')[0].split(' ')[0]

                shows.append({
                    'label':
                    program_name,
                    'thumb':
                    img,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          program_url=program_url,
                                          next='list_videos_lci',
                                          window_title=program_name)
                })
    else:
        url = ''.join((URL_ROOT, params.channel_name, '/programmes-tv'))
        file_path = utils.download_catalog(url, params.channel_name + '.html')
        root_html = open(file_path).read()
        root_soup = bs(root_html, 'html.parser')

        if params.next == 'list_shows_1':
            categories_soup = root_soup.find(
                'ul', attrs={'class': 'filters_2 contentopen'})
            for category in categories_soup.find_all('a'):
                category_name = category.get_text().encode('utf-8')
                category_url = category['data-target'].encode('utf-8')

                shows.append({
                    'label':
                    category_name,
                    'url':
                    common.PLUGIN.get_url(module_path=params.module_path,
                                          module_name=params.module_name,
                                          action='replay_entry',
                                          category=category_url,
                                          next='list_shows_2',
                                          window_title=category_name)
                })

        elif params.next == 'list_shows_2':
            programs_soup = root_soup.find(
                'ul', attrs={'id': 'js_filter_el_container'})
            for program in programs_soup.find_all('li'):
                category = program['data-type'].encode('utf-8')
                if params.category == category or params.category == 'all':
                    program_url = program.find('div', class_='description')
                    program_url = program_url.find('a')['href'].encode('utf-8')
                    program_name = program.find(
                        'p', class_='program').get_text().encode('utf-8')
                    img = program.find('img')
                    try:
                        img = img['data-srcset'].encode('utf-8')
                    except Exception:
                        img = img['srcset'].encode('utf-8')

                    img = 'http:' + img.split(',')[-1].split(' ')[0]

                    if 'meteo.tf1.fr/meteo-france' in program_url:
                        shows.append({
                            'label':
                            program_name,
                            'thumb':
                            img,
                            'url':
                            common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                program_url=program_url,
                                next='list_videos',
                                window_title=program_name)
                        })
                    else:
                        shows.append({
                            'label':
                            program_name,
                            'thumb':
                            img,
                            'url':
                            common.PLUGIN.get_url(
                                module_path=params.module_path,
                                module_name=params.module_name,
                                action='replay_entry',
                                program_url=program_url,
                                next='list_videos_categories',
                                window_title=program_name)
                        })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        category=common.get_window_title())
示例#55
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.state_video == 'Toutes les videos (sans les categories)':

        file_path = utils.download_catalog(
            URL_ALL_VIDEO,
            '%s_all_video.xml' % params.channel_name,
        )
        replay_xml = open(file_path).read()

        xml_elements = ET.XML(replay_xml)

        programs = xml_elements.findall(
            "{http://www.sitemaps.org/schemas/sitemap/0.9}url")

        for program in programs:

            url_site = program.findtext(
                "{http://www.sitemaps.org/schemas/sitemap/0.9}loc"
            ).encode('utf-8')
            check_string = '%s/replay/' % params.channel_name
            if url_site.count(check_string) > 0:

                # Title
                title = url_site.rsplit('/', 1)[1].replace("-", " ").upper()

                video_node = program.findall(
                    "{http://www.google.com/schemas/sitemap-video/1.1}video")[0]

                # Duration
                duration = 0

                # Image
                img = ''
                img_node = video_node.find(
                    "{http://www.google.com/schemas/sitemap-video/1.1}thumbnail_loc")
                img = img_node.text.encode('utf-8')

                # Url Video
                url = ''
                url_node = video_node.find(
                    "{http://www.google.com/schemas/sitemap-video/1.1}content_loc")
                url = url_node.text.encode('utf-8')

                # Plot
                plot = ''
                plot_node = video_node.find(
                    "{http://www.google.com/schemas/sitemap-video/1.1}description")
                if plot_node.text:
                    plot = plot_node.text.encode('utf-8')

                # Date
                value_date = ''
                value_date_node = video_node.find(
                    "{http://www.google.com/schemas/sitemap-video/1.1}publication_date")
                value_date = value_date_node.text.encode('utf-8')
                date = value_date.split('T')[0].split('-')
                day = date[2]
                mounth = date[1]
                year = date[0]
                date = '.'.join((day, mounth, year))
                aired = '-'.join((year, mounth, day))

                info = {
                    'video': {
                        'title': title,
                        'plot': plot,
                        'duration': duration,
                        'aired': aired,
                        'date': date,
                        'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'),
                    'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                        action='download_video',
                        module_path=params.module_path,
                        module_name=params.module_name,
                        url_video=url_site) + ')'
                )
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label': title,
                    'fanart': img,
                    'thumb': img,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        next='play_r',
                        url_video=url
                    ),
                    'is_playable': True,
                    'info': info,
                    'context_menu': context_menu
                })

    else:
        file_path = utils.download_catalog(
            URL_REPLAY_API % params.channel_name,
            '%s_replay.xml' % params.channel_name,
        )
        replay_xml = open(file_path).read()

        xml_elements = ET.XML(replay_xml)

        programs = xml_elements.findall("program")

        for program in programs:
            if params.state_video == 'Toutes les videos':

                # Title
                title = program.findtext("title").encode('utf-8') + " - " + \
                    program.findtext("subtitle").encode('utf-8')

                # Duration
                duration = 0
                if program.findtext("duration"):
                    try:
                        duration = int(program.findtext("duration")) * 60
                    except ValueError:
                        pass      # or whatever

                # Image
                img = program.find("photos").findtext("photo")

                # Url Video
                url = ''
                # program.find("offres").find("offre").find("videos").findtext("video)
                for i in program.find("offres").findall("offre"):

                    date_value = i.get("startdate")
                    date_value_list = date_value.split(' ')[0].split('-')
                    day = date_value_list[2]
                    mounth = date_value_list[1]
                    year = date_value_list[0]

                    date = '.'.join((day, mounth, year))
                    aired = '-'.join((year, mounth, day))

                    for j in i.find("videos").findall("video"):
                        url = j.text.encode('utf-8')

                # Plot
                plot = ''
                for i in program.find("stories").findall("story"):
                    if int(i.get("maxlength")) == 680:
                        plot = i.text.encode('utf-8')

                info = {
                    'video': {
                        'title': title,
                        'plot': plot,
                        'duration': duration,
                        'aired': aired,
                        'date': date,
                        'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'),
                    'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                        action='download_video',
                        module_path=params.module_path,
                        module_name=params.module_name,
                        url_video=url) + ')'
                )
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label': title,
                    'fanart': img,
                    'thumb': img,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        next='play_r',
                        url_video=url
                    ),
                    'is_playable': True,
                    'info': info,
                    'context_menu': context_menu
                })

            elif params.id_program == program.get("IDSERIE"):

                # Title
                title = program.findtext("title").encode('utf-8') + " - " + \
                    program.findtext("subtitle").encode('utf-8')

                # Duration
                duration = 0
                if program.findtext("duration"):
                    try:
                        duration = int(program.findtext("duration")) * 60
                    except ValueError:
                        pass      # or whatever

                # Image
                img = program.find("photos").findtext("photo")

                # Url Video
                url = ''
                # program.find("offres").find("offre").find("videos").findtext("video)
                for i in program.find("offres").findall("offre"):

                    date_value = i.get("startdate")
                    date_value_list = date_value.split(' ')[0].split('-')
                    day = date_value_list[2]
                    mounth = date_value_list[1]
                    year = date_value_list[0]

                    date = '.'.join((day, mounth, year))
                    aired = '-'.join((year, mounth, day))

                    for j in i.find("videos").findall("video"):
                        url = j.text.encode('utf-8')

                # Plot
                plot = ''
                for i in program.find("stories").findall("story"):
                    if int(i.get("maxlength")) == 680:
                        plot = i.text.encode('utf-8')

                info = {
                    'video': {
                        'title': title,
                        'plot': plot,
                        'duration': duration,
                        'aired': aired,
                        'date': date,
                        'year': year,
                        'mediatype': 'tvshow'
                    }
                }

                download_video = (
                    common.GETTEXT('Download'),
                    'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                        action='download_video',
                        module_path=params.module_path,
                        module_name=params.module_name,
                        url_video=url) + ')'
                )
                context_menu = []
                context_menu.append(download_video)

                videos.append({
                    'label': title,
                    'fanart': img,
                    'thumb': img,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        next='play_r',
                        url_video=url
                    ),
                    'is_playable': True,
                    'info': info,
                    'context_menu': context_menu
                })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_DATE,
            common.sp.xbmcplugin.SORT_METHOD_DURATION,
            common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
            common.sp.xbmcplugin.SORT_METHOD_GENRE,
            common.sp.xbmcplugin.SORT_METHOD_PLAYCOUNT,
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        content='tvshows',
        category=common.get_window_title()
    )
示例#56
0
def list_videos(params):
    """Build videos listing"""
    videos = []

    if params.sub_category_id == 'null':
        url = URL_VIDEOS2 % params.program_id
    else:
        url = URL_VIDEOS % (params.program_id, params.sub_category_id)
    program_json = utils.get_webcontent(url, random_ua=True)
    json_parser = json.loads(program_json)

    # TO DO Playlist More one 'clips'

    for video in json_parser:
        video_id = str(video['id'])

        title = video['title'].encode('utf-8')
        duration = video['clips'][0]['duration']
        description = video['description'].encode('utf-8')
        try:
            aired = video['clips'][0]['product']['last_diffusion']
            aired = aired.encode('utf-8')
            aired = aired[:10]
            year = aired[:4]
            # date : string (%d.%m.%Y / 01.01.2009)
            # aired : string (2008-12-07)
            day = aired.split('-')[2]
            mounth = aired.split('-')[1]
            year = aired.split('-')[0]
            date = '.'.join((day, mounth, year))

        except Exception:
            aired = ''
            year = ''
            date = ''
        img = ''

        program_imgs = video['clips'][0]['images']
        program_img = ''
        for img in program_imgs:
            if img['role'].encode('utf-8') == 'vignette':
                external_key = img['external_key'].encode('utf-8')
                program_img = URL_IMG % (external_key)

        info = {
            'video': {
                'title': title,
                'plot': description,
                'aired': aired,
                'date': date,
                'duration': duration,
                'year': year,
                'mediatype': 'tvshow'
            }
        }

        download_video = (common.GETTEXT('Download'), 'XBMC.RunPlugin(' +
                          common.PLUGIN.get_url(action='download_video',
                                                module_path=params.module_path,
                                                module_name=params.module_name,
                                                video_id=video_id) + ')')
        context_menu = []
        context_menu.append(download_video)

        videos.append({
            'label':
            title,
            'thumb':
            program_img,
            'url':
            common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='replay_entry',
                next='play',
                video_id=video_id,
            ),
            'is_playable':
            True,
            'info':
            info,
            'context_menu':
            context_menu
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_DATE,
                      common.sp.xbmcplugin.SORT_METHOD_DURATION,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      common.sp.xbmcplugin.SORT_METHOD_UNSORTED),
        content='tvshows',
        category=common.get_window_title(params))
示例#57
0
def list_shows(params):
    """Create categories list"""
    shows = []

    if params.next == 'list_shows_1':

        file_path = utils.download_catalog(
            URL_VIDEOS_CNEWS,
            '%s_categories.html' % (
                params.channel_name))
        root_html = open(file_path).read()
        root_soup = bs(root_html, 'html.parser')

        menu_soup = root_soup.find('div', class_="nav-tabs-inner")

        categories_soup = menu_soup.find_all('a')

        for category in categories_soup:

            category_name = category.get_text().encode('utf-8')
            category_url = URL_ROOT_SITE + category.get('href')

            if category_name != 'Les tops':
                shows.append({
                    'label': category_name,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        category_url=category_url,
                        category_name=category_name,
                        next='list_shows_2',
                        window_title=category_name
                    )
                })

    elif params.next == 'list_shows_2':

        if params.category_name == 'Les sujets':

            file_path = utils.download_catalog(
                params.category_url,
                '%s_%s.html' % (
                    params.channel_name, params.category_name))
            root_html = open(file_path).read()
            root_soup = bs(root_html, 'html.parser')
            categories_soup = root_soup.find_all('a', class_="checkbox")

            for category in categories_soup:

                category_name = category.get_text().encode('utf-8')
                category_url = URL_ROOT_SITE + category.get('href')

                shows.append({
                    'label': category_name,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        category_url=category_url,
                        page="1",
                        category_name=category_name,
                        next='list_videos',
                        window_title=category_name
                    )
                })
        else:
            # Find all emissions
            file_path = utils.download_catalog(
                URL_EMISSIONS_CNEWS,
                '%s_ALL_EMISSION.html' % (
                    params.channel_name))
            root_html = open(file_path).read()
            root_soup = bs(root_html, 'html.parser')

            categories_soup = root_soup.find_all('article', class_="item")

            for category in categories_soup:

                category_name = category.find('h3').get_text().encode('utf-8')
                category_url = URL_VIDEOS_CNEWS + \
                    '/emissions' + \
                    category.find('a').get('href').split('.fr')[1]
                category_img = category.find('img').get('src').encode('utf-8')

                shows.append({
                    'label': category_name,
                    'thumb': category_img,
                    'fanart': category_img,
                    'url': common.PLUGIN.get_url(
                        module_path=params.module_path,
                        module_name=params.module_name,
                        action='replay_entry',
                        category_url=category_url,
                        page="1",
                        category_name=category_name,
                        next='list_videos',
                        window_title=category_name
                    )
                })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
            common.sp.xbmcplugin.SORT_METHOD_LABEL
        ),
        category=common.get_window_title()
    )
示例#58
0
def list_shows(params):
    """Build categories listing"""
    shows = []

    if params.next == 'list_shows_1':

        url_root_site = ''
        if params.channel_name == 'stories' or \
                params.channel_name == 'bruce' or \
                params.channel_name == 'crazy_kitchen' or \
                params.channel_name == 'home' or \
                params.channel_name == 'styles' or \
                params.channel_name == 'comedy' or \
                params.channel_name == 'fun_radio':
            url_root_site = URL_ROOT % params.channel_name
        else:
            url_root_site = URL_ROOT % (params.channel_name + 'replay')

        file_path = utils.download_catalog(url_root_site,
                                           '%s.json' % (params.channel_name),
                                           random_ua=True)
        file_prgm = open(file_path).read()
        json_parser = json.loads(file_prgm)

        # do not cache failed catalog fetch
        # the error format is:
        #   {"error":{"code":403,"message":"Forbidden"}}
        if isinstance(json_parser, dict) and \
                'error' in json_parser.keys():
            utils.os.remove(file_path)
            raise Exception('Failed to fetch the 6play catalog')

        for array in json_parser:
            category_id = str(array['id'])
            category_name = array['name'].encode('utf-8')

            shows.append({
                'label':
                category_name,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      category_id=category_id,
                                      next='list_shows_2',
                                      title=category_name,
                                      window_title=category_name)
            })

    elif params.next == 'list_shows_2':
        file_prgm = utils.get_webcontent(URL_CATEGORY % (params.category_id),
                                         random_ua=True)
        json_parser = json.loads(file_prgm)

        for array in json_parser:
            program_title = array['title'].encode('utf-8')
            program_id = str(array['id'])
            program_desc = array['description'].encode('utf-8')
            program_imgs = array['images']
            program_img = ''
            program_fanart = ''
            for img in program_imgs:
                if img['role'].encode('utf-8') == 'vignette':
                    external_key = img['external_key'].encode('utf-8')
                    program_img = URL_IMG % (external_key)
                elif img['role'].encode('utf-8') == 'carousel':
                    external_key = img['external_key'].encode('utf-8')
                    program_fanart = URL_IMG % (external_key)

            info = {'video': {'title': program_title, 'plot': program_desc}}

            shows.append({
                'label':
                program_title,
                'thumb':
                program_img,
                'fanart':
                program_fanart,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='list_shows_3',
                                      program_id=program_id,
                                      program_img=program_img,
                                      program_fanart=program_fanart,
                                      program_desc=program_desc,
                                      title=program_title,
                                      window_title=program_title),
                'info':
                info
            })

    elif params.next == 'list_shows_3':
        program_json = utils.get_webcontent(URL_SUBCATEGORY %
                                            (params.program_id),
                                            random_ua=True)

        json_parser = json.loads(program_json)

        try:
            program_fanart = params.program_fanart
        except Exception:
            program_fanart = ''

        for sub_category in json_parser['program_subcats']:
            sub_category_id = str(sub_category['id'])
            sub_category_title = sub_category['title'].encode('utf-8')

            info = {
                'video': {
                    'title': sub_category_title,
                    'plot': params.program_desc
                }
            }

            shows.append({
                'label':
                sub_category_title,
                'thumb':
                params.program_img,
                'fanart':
                program_fanart,
                'url':
                common.PLUGIN.get_url(module_path=params.module_path,
                                      module_name=params.module_name,
                                      action='replay_entry',
                                      next='list_videos',
                                      program_id=params.program_id,
                                      sub_category_id=sub_category_id,
                                      window_title=sub_category_title),
                'info':
                info
            })

        info = {
            'video': {
                'title': common.ADDON.get_localized_string(30701),
                'plot': params.program_desc
            }
        }

        shows.append({
            'label':
            common.ADDON.get_localized_string(30701),
            'thumb':
            params.program_img,
            'fanart':
            program_fanart,
            'url':
            common.PLUGIN.get_url(module_path=params.module_path,
                                  module_name=params.module_name,
                                  action='replay_entry',
                                  next='list_videos',
                                  program_id=params.program_id,
                                  sub_category_id='null',
                                  window_title=params.window_title),
            'info':
            info
        })

    return common.PLUGIN.create_listing(
        shows,
        sort_methods=(common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
                      common.sp.xbmcplugin.SORT_METHOD_LABEL),
        category=common.get_window_title(params))
示例#59
0
def generic_menu(params):
    """
    Build a generic addon menu
    with all not hidden items
    """
    current_skeleton = skeleton.SKELETON[('root', 'generic_menu')]
    current_path = ['root']

    if 'item_skeleton' in params:
        current_skeleton = eval(params.item_skeleton)
        current_path = eval(params.item_path)

    # First we sort the current menu
    menu = []
    for value in current_skeleton:
        item_id = value[0]
        item_next = value[1]
        # If menu item isn't disable
        if common.PLUGIN.get_setting(item_id):
            # Get order value in settings file
            item_order = common.PLUGIN.get_setting(item_id + '.order')

            # Get english item title in LABELS dict in skeleton file
            # and check if this title has any translated version in strings.po
            item_title = ''
            try:
                item_title = common.GETTEXT(skeleton.LABELS[item_id])
            except Exception:
                item_title = skeleton.LABELS[item_id]

            # Build step by step the module pathfile
            item_path = list(current_path)
            if item_id in skeleton.FOLDERS:
                item_path.append(skeleton.FOLDERS[item_id])
            else:
                item_path.append(item_id)

            item_skeleton = {}
            try:
                item_skeleton = current_skeleton[value]
            except TypeError:
                item_skeleton = {}

            item = (item_order, item_id, item_title, item_path, item_next,
                    item_skeleton)
            menu.append(item)

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

    # If only one item is present, directly open this item
    only_one_item = False
    if len(menu) == 1:
        only_one_item = True
        item = menu[0]
        item_id = item[1]
        item_title = item[2]
        item_path = item[3]
        item_next = item[4]
        item_skeleton = item[5]

        params['item_id'] = item_id
        params['item_path'] = str(item_path)
        params['item_skeleton'] = str(item_skeleton)
        params['window_title'] = item_title

        if item_next == 'root':
            return root(params)
        elif item_next == 'replay_entry':
            return replay_entry(params)
        elif item_next == 'build_live_tv_menu':
            return build_live_tv_menu(params)
        else:
            only_one_item = False

    if not only_one_item:
        listing = []
        for index, (item_order, item_id, item_title, item_path, item_next,
                    item_skeleton) in enumerate(menu):

            # 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=item_id + '.order',
                    displayed_items=menu) + ')'
            )
            item_up = (
                common.GETTEXT('Move up'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='move',
                    direction='up',
                    item_id_order=item_id + '.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=item_id) + ')'
            )
            context_menu.append(hide)

            item_path_media = list(current_path)
            item_path_media.append(item_id)
            media_item_path = common.sp.xbmc.translatePath(
                common.sp.os.path.join(
                    common.MEDIA_PATH,
                    *(item_path_media)
                )
            )

            media_item_path = media_item_path.decode(
                "utf-8").encode(common.FILESYSTEM_CODING)

            icon = media_item_path + '.png'
            fanart = media_item_path + '_fanart.jpg'

            listing.append({
                'icon': icon,
                'fanart': fanart,
                'label': item_title,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action=item_next,
                    item_id=item_id,
                    item_path=str(item_path),
                    item_skeleton=str(item_skeleton),
                    window_title=item_title
                ),
                'context_menu': context_menu
            })

        return common.PLUGIN.create_listing(
            listing,
            sort_methods=(
                common.sp.xbmcplugin.SORT_METHOD_UNSORTED,),
            category=common.get_window_title()
        )
示例#60
0
def list_videos(params):
    """Build videos listing"""
    videos = []
    if 'previous_listing' in params:
        videos = ast.literal_eval(params['previous_listing'])

    if params.next == 'list_videos_1':

        replay_videos_html = utils.get_webcontent(
            params.category_url + '?paged=%s' % params.page)
        replay_videos_soup = bs(replay_videos_html, 'html.parser')
        all_videos = replay_videos_soup.find_all('article')

        for video in all_videos:

            video_title = video.find('h2').find(
                'a').get('title').encode('utf-8')
            if video.find('img').get('data-src'):
                video_img = video.find('img').get('data-src')
            else:
                video_img = video.find('img').get('src')
            video_url = URL_ROOT + video.find('h2').find(
                'a').get('href').encode('utf-8')

            # TO DO Playlist

            info = {
                'video': {
                    'title': video_title,
                    # 'aired': aired,
                    # 'date': date,
                    # 'duration': video_duration,
                    # 'plot': video_plot,
                    # 'year': year,
                    'mediatype': 'tvshow'
                }
            }

            download_video = (
                common.GETTEXT('Download'),
                'XBMC.RunPlugin(' + common.PLUGIN.get_url(
                    action='download_video',
                    module_path=params.module_path,
                    module_name=params.module_name,
                    video_url=video_url) + ')'
            )
            context_menu = []
            context_menu.append(download_video)

            videos.append({
                'label': video_title,
                'thumb': video_img,
                'url': common.PLUGIN.get_url(
                    module_path=params.module_path,
                    module_name=params.module_name,
                    action='website_entry',
                    next='play_r',
                    video_url=video_url
                ),
                'is_playable': True,
                'info': info,
                'context_menu': context_menu
            })

        # More videos...
        videos.append({
            'label': common.ADDON.get_localized_string(30700),
            'url': common.PLUGIN.get_url(
                module_path=params.module_path,
                module_name=params.module_name,
                action='website_entry',
                category_url=params.category_url,
                next=params.next,
                page=str(int(params.page) + 1),
                title=params.title,
                window_title=params.window_title,
                update_listing=True,
                previous_listing=str(videos)
            )
        })

    return common.PLUGIN.create_listing(
        videos,
        sort_methods=(
            common.sp.xbmcplugin.SORT_METHOD_UNSORTED
        ),
        content='tvshows',
        update_listing='update_listing' in params,
        category=common.get_window_title(params)
    )