Exemplo n.º 1
0
def list_videos(plugin, item_id, category_url, **kwargs):
    """Build videos listing"""
    videos_datas_xml = urlquick.get(category_url).text
    videos_datas_xml = utils.ensure_native_str(videos_datas_xml)
    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:
                video_url = video_link.get('href')

        if video_url != '':
            item = Listitem()
            item.label = video.find("title").text

            if video.find("abstract").text:
                item.info['plot'] = utils.strip_tags(
                    video.find("abstract").text)

            item.set_callback(get_video_url,
                              item_id=item_id,
                              video_url=video_url)
            item_post_treatment(item, is_playable=True, is_downloadable=True)
            yield item
def list_videos(plugin, item_id, category_url):
    """Build videos listing"""
    videos_datas_xml = urlquick.get(category_url).text
    videos_datas_xml = utils.ensure_native_str(videos_datas_xml)
    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:
                video_url = video_link.get('href')

        if video_url != '':
            item = Listitem()
            item.label = video.find("title").text

            if video.find("abstract").text:
                item.info['plot'] = utils.strip_tags(
                    video.find("abstract").text)

            item.context.script(get_video_url,
                                plugin.localize(LABELS['Download']),
                                item_id=item_id,
                                video_url=video_url,
                                video_label=LABELS[item_id] + ' - ' +
                                item.label,
                                download_mode=True)

            item.set_callback(get_video_url,
                              item_id=item_id,
                              video_url=video_url)
            yield item
def list_videos(plugin, item_id, category_slug, page, **kwargs):

    resp = urlquick.get(URL_VIDEOS % (category_slug, page))
    json_parser = json.loads(resp.text)

    for video_datas in json_parser["category"]["news"]:
        if video_datas["video"]:
            video_title = video_datas["title"]
            video_image = video_datas["media"][0]["image"]
            video_plot = utils.strip_tags(video_datas["text"])
            video_url = None
            video_id = None
            if 'url' in video_datas["media"][0]:
                video_url = video_datas["media"][0]["url"]
            elif 'youtube.com/embed' in video_datas["text"]:
                video_id = re.compile(r'youtube\.com\/embed\/(.*?)\"').findall(
                    video_datas["text"])[0]

            if video_url is not None:
                item = Listitem()
                item.label = video_title
                item.art['thumb'] = video_image
                item.info['plot'] = video_plot

                item.set_callback(get_video_url,
                                  item_id=item_id,
                                  video_label=LABELS[item_id] + ' - ' +
                                  item.label,
                                  video_url=video_url)
                item_post_treatment(item,
                                    is_playable=True,
                                    is_downloadable=True)
                yield item

            if video_id is not None:
                item = Listitem()
                item.label = video_title
                item.art['thumb'] = video_image
                item.info['plot'] = video_plot

                item.set_callback(get_video_yt_url,
                                  item_id=item_id,
                                  video_label=LABELS[item_id] + ' - ' +
                                  item.label,
                                  video_id=video_id)
                item_post_treatment(item,
                                    is_playable=True,
                                    is_downloadable=True)
                yield item

    # More videos...
    yield Listitem.next_page(item_id=item_id,
                             category_slug=category_slug,
                             page=str(int(page) + 1))
Exemplo n.º 4
0
def list_videos(plugin, item_id, program_url):

    resp = urlquick.get(program_url)
    root_soup = bs(resp.text, 'html.parser')
    if root_soup.find('ul', class_='episodes-container'):
        list_videos_datas = root_soup.find(
            'ul', class_='episodes-container').find_all('li')

        for video_datas in list_videos_datas:

            # Check the IF maybe keep just icon-play?
            if 'icon-play' in video_datas.find('a').get('class') or \
                video_datas.find('div', class_='play medium'):
                video_title = utils.strip_tags(
                    video_datas.find('a').get('title'))
                video_image = ''
                if video_datas.find('img'):
                    if 'http' in video_datas.find('img').get('src'):
                        video_image = video_datas.find('img').get('src')
                    else:
                        video_image = URL_ROOT + video_datas.find('img').get(
                            'src')
                video_url = URL_ROOT + video_datas.find('a').get('href')

                item = Listitem()
                item.label = video_title
                item.art['thumb'] = video_image

                item.context.script(get_video_url,
                                    plugin.localize(LABELS['Download']),
                                    item_id=item_id,
                                    video_url=video_url,
                                    video_label=LABELS[item_id] + ' - ' +
                                    item.label,
                                    download_mode=True)

                item.set_callback(get_video_url,
                                  item_id=item_id,
                                  video_url=video_url)
                yield item
Exemplo n.º 5
0
def list_videos(plugin, item_id, program_title, **kwargs):

    resp = urlquick.get(URL_VIDEOS % program_title)

    videos_datas_xml = utils.ensure_native_str(resp.text)
    xml_elements = ET.XML(videos_datas_xml)

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

        item = Listitem()
        item.label = video.find(".//show").text

        if video.find(".//description").text:
            item.info['plot'] = utils.strip_tags(
                video.find(".//description").text)
        item.art['thumb'] = item.art['landscape'] = video.find(
            ".//screenshot").text
        video_id = video.find(".//pageurl").text

        item.set_callback(get_video_url, item_id=item_id, video_id=video_id)
        item_post_treatment(item, is_playable=True, is_downloadable=True)
        yield item
def list_videos(plugin, item_id, program_url):

    resp = urlquick.get(program_url)
    root = resp.parse()
    if root.find(".//ul[@class='episodes-container']") is not None:

        for video_datas in root.find(
                ".//ul[@class='episodes-container']").iterfind('.//li'):

            # Check the IF maybe keep just icon-play?
            if 'icon-play' in video_datas.find('.//a').get('class') or \
                video_datas.find(".//div[@class='play medium]'") is not None:
                video_title = utils.strip_tags(
                    video_datas.find('.//a').get('title'))
                video_image = ''
                if video_datas.find('.//img') is not None:
                    if 'http' in video_datas.find('.//img').get('src'):
                        video_image = video_datas.find('.//img').get('src')
                    else:
                        video_image = URL_ROOT + video_datas.find(
                            './/img').get('src')
                video_url = URL_ROOT + video_datas.find('.//a').get('href')

                item = Listitem()
                item.label = video_title
                item.art['thumb'] = video_image

                item.context.script(get_video_url,
                                    plugin.localize(LABELS['Download']),
                                    item_id=item_id,
                                    video_url=video_url,
                                    video_label=LABELS[item_id] + ' - ' +
                                    item.label,
                                    download_mode=True)

                item.set_callback(get_video_url,
                                  item_id=item_id,
                                  video_url=video_url)
                yield item
Exemplo n.º 7
0
def open_site(plugin, url, search_query=None):
    if search_query:
        url = url = url + "?search=" + search_query
    url = url_constructor(url)

    site_body_raw = urlquick.get(url)
    site_body_decoded = json.loads(site_body_raw.text)

    if 'channels' in site_body_decoded:
        for channel in site_body_decoded['channels']:
            link = Listitem()
            if 'title' in channel:
                link.label = utils.strip_tags(channel['title'])
            if 'logo_30x30' in channel:
                link.art['thumb'] = channel['logo_30x30']
            if 'playlist_url' in channel:
                if 'search_on' in channel:
                    link.set_callback(user_input, url=channel['playlist_url'])
                else:
                    link.set_callback(open_site, url=channel['playlist_url'])
            elif 'stream_url' in channel:
                link.set_callback(play_media, url=channel['stream_url'])

            yield link
Exemplo n.º 8
0
def list_videos(plugin, item_id, category_url, page):

    replay_paged_url = category_url + '&paged=' + page
    resp = urlquick.get(replay_paged_url)
    root_soup = bs(resp.text, 'html.parser')
    list_videos_datas = root_soup.find_all('div',
                                           class_='program sticky video')

    for video_datas in list_videos_datas:
        info_video = video_datas.find_all('p')

        video_title = utils.ensure_unicode(
            video_datas.find('p', class_="red").text)
        video_img = video_datas.find('img')['src']
        video_id = video_datas.find('div', class_="player")['data-id-video']
        video_duration = 0
        video_duration_list = utils.strip_tags(str(info_video[3])).split(':')
        if len(video_duration_list) > 2:
            video_duration = int(video_duration_list[0]) * 3600 + \
                int(video_duration_list[1]) * 60 + \
                int(video_duration_list[2])
        else:
            video_duration = int(video_duration_list[0]) * 60 + \
                int(video_duration_list[1])

        # get month and day on the page
        try:
            date_list = utils.strip_tags(str(info_video[2])).split(' ')
        except:
            pass
        day = '00'
        month = '00'
        year = '2018'
        if len(date_list) > 3:
            day = date_list[2]
            try:
                month = CORRECT_MONTH[date_list[3]]
            except Exception:
                month = '00'
            # get year ?

        date_value = '-'.join((year, month, day))

        item = Listitem()
        item.label = video_title
        item.art['thumb'] = video_img
        item.info['duration'] = video_duration
        item.info.date(date_value, '%Y-%m-%d')

        item.context.script(get_video_url,
                            plugin.localize(LABELS['Download']),
                            item_id=item_id,
                            video_id=video_id,
                            video_label=LABELS[item_id] + ' - ' + item.label,
                            download_mode=True)

        item.set_callback(get_video_url, item_id=item_id, video_id=video_id)
        yield item

    yield Listitem.next_page(item_id=item_id,
                             category_url=category_url,
                             page=str(int(page) + 1))
    def _parse_program_dict(self, program):
        program_dict = {}

        # Channel ID
        program_dict['id_chaine'] = program['id_chaine']

        # Horaire
        try:
            local_tz = get_localzone()
        except Exception:
            # Hotfix issue #102
            local_tz = pytz.timezone('Europe/Paris')

        start_s = program['horaire']['debut']
        try:
            start = datetime.datetime.strptime(start_s,
                                               self._TELERAMA_TIME_FORMAT)
        except TypeError:
            start = datetime.datetime(
                *(time.strptime(start_s, self._TELERAMA_TIME_FORMAT)[0:6]))

        start = self._TELERAMA_TIMEZONE.localize(start)
        start = start.astimezone(local_tz)
        final_start_s = start.strftime("%Hh%M")
        program_dict['start_time'] = final_start_s

        stop_s = program['horaire']['fin']
        try:
            stop = datetime.datetime.strptime(stop_s,
                                              self._TELERAMA_TIME_FORMAT)
        except TypeError:
            stop = datetime.datetime(
                *(time.strptime(stop_s, self._TELERAMA_TIME_FORMAT)[0:6]))

        stop = self._TELERAMA_TIMEZONE.localize(stop)
        stop = stop.astimezone(local_tz)
        final_stop_s = stop.strftime("%Hh%M")
        program_dict['stop_time'] = final_stop_s

        # Title
        program_dict['title'] = program['titre']

        if program['titre_original']:
            program_dict['originaltitle'] = program['titre_original']

        # Sub-title
        if program['soustitre']:
            program_dict['subtitle'] = program['soustitre']

        # Desc
        if program['resume']:
            program_dict['plot'] = utils.strip_tags(
                self._fix_xml_unicode_string(program['resume']))

        # Categories
        if program['id_genre']:
            program_dict['genre'] = self._TELERAMA_CATEGORIES.get(
                program['id_genre'], 'Inconnue')

        # Add specific category
        if program['genre_specifique']:
            program_dict['specific_genre'] = program['genre_specifique']

        # Icon
        if 'vignettes' in program:
            program_dict['thumb'] = program['vignettes']['grande']
            program_dict['fanart'] = program['vignettes']['grande169']

        # Episode/season
        if program['serie'] and program['serie']['numero_episode']:
            program_dict['season'] = (program['serie'].get('saison', 1)
                                      or 1) - 1
            program_dict['episode'] = program['serie']['numero_episode'] - 1

        # Video format
        aspect = None
        if program['flags']['est_ar16x9']:
            aspect = '16:9'
        elif program['flags']['est_ar4x3']:
            aspect = '4:3'
        if aspect is not None:
            program_dict['aspect'] = aspect
        if program['flags']['est_hd']:
            program_dict['quality'] = 'HDTV'

        # Audio format
        stereo = None
        if program['flags']['est_dolby']:
            stereo = 'dolby'
        elif program['flags']['est_stereoar16x9'] or program['flags'][
                'est_stereo']:
            stereo = 'stereo'
        elif program['flags']['est_vm']:
            stereo = 'bilingual'
        if stereo is not None:
            program_dict['audio'] = stereo

        # Check whether the program was previously shown
        if program['flags']['est_premdif'] or program['flags']['est_inedit']:
            # program_xml.append(Element('premiere'))
            program_dict['diffusion'] = 'Inédit'
        elif program['flags']['est_redif']:
            # program_xml.append(Element('previously-shown'))
            program_dict['diffusion'] = 'Redifusion'
        elif program['flags']['est_derdif']:
            # program_xml.append(Element('last-chance'))
            program_dict['diffusion'] = 'Dernière chance'

        # Subtitles
        if program['flags']['est_stm']:
            # program_xml.append(Element('subtitles', type='deaf-signed'))
            program_dict['subtitles'] = 'deaf-signed'
        elif program['flags']['est_vost']:
            # program_xml.append(Element('subtitles', type='onscreen'))
            program_dict['subtitles'] = 'onscreen'

        # Star rating
        if program['note_telerama'] > 0:
            program_dict['rating'] = float(program['note_telerama'] *
                                           2)  # Pour avoir sur 10 pour Kodi

        return program_dict
Exemplo n.º 10
0
 def test_strip_tags(self):
     ret = utils.strip_tags(
         '<a href="http://example.com/">I linked to <i>example.com</i></a>')
     self.assertEqual(ret, "I linked to example.com")
Exemplo n.º 11
0
def list_videos(plugin, item_id, category_url, page):

    replay_paged_url = category_url + '&paged=' + page
    resp = urlquick.get(replay_paged_url)
    root = resp.parse()

    for video_datas in root.iterfind(".//div[@class='program sticky video']"):

        video_title = utils.ensure_unicode(
            video_datas.find(".//p[@class='red']").text)
        video_img = video_datas.find(".//img").get('src')
        video_id = video_datas.find(".//div[@class='player']").get(
            'data-id-video')

        video_duration = 0
        video_duration_list = video_datas.find(".//strong").text.split(':')
        if len(video_duration_list) > 2:
            video_duration = int(video_duration_list[0]) * 3600 + \
                int(video_duration_list[1]) * 60 + \
                int(video_duration_list[2])
        else:
            video_duration = int(video_duration_list[0]) * 60 + \
                int(video_duration_list[1])

        info_video = video_datas.findall(".//p")
        # get month and day on the page
        date_list = ''
        try:
            date_list = utils.strip_tags(str(info_video[2].text)).split(' ')
        except:
            pass
        day = '00'
        month = '00'
        year = '2019'
        if len(date_list) > 3:
            day = date_list[2]
            try:
                month = CORRECT_MONTH[date_list[3]]
            except Exception:
                month = '00'
            # get year ?

        date_value = '-'.join((year, month, day))

        item = Listitem()
        item.label = video_title
        item.art['thumb'] = video_img
        item.info['duration'] = video_duration
        try:
            item.info.date(date_value, '%Y-%m-%d')
        except:
            pass

        item.context.script(get_video_url,
                            plugin.localize(LABELS['Download']),
                            item_id=item_id,
                            video_id=video_id,
                            video_label=LABELS[item_id] + ' - ' + item.label,
                            download_mode=True)

        item.set_callback(get_video_url, item_id=item_id, video_id=video_id)
        yield item

    yield Listitem.next_page(item_id=item_id,
                             category_url=category_url,
                             page=str(int(page) + 1))
Exemplo n.º 12
0
    resp = urlquick.get(URL_VIDEOS % program_title)

    videos_datas_xml = utils.ensure_native_str(resp.text)
    xml_elements = ET.XML(videos_datas_xml)

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

        item = Listitem()
<<<<<<< HEAD:plugin.video.catchuptvandmore/resources/lib/channels/us/nycmedia.py
        item.label = video_title
        item.art['thumb'] = item.art['landscape'] = video_image
=======
        item.label = video.find(".//show").text

        if video.find(".//description").text:
            item.info['plot'] = utils.strip_tags(
                video.find(".//description").text)
        item.art['thumb'] = item.art['landscape'] = video.find(".//screenshot").text
        video_id = video.find(".//pageurl").text
>>>>>>> cf69920d1ba10a4558544c5d79d7c35f56d3e2c3:resources/lib/channels/us/nycmedia.py

        item.set_callback(get_video_url,
                          item_id=item_id,
                          video_id=video_id)
        item_post_treatment(item, is_playable=True, is_downloadable=True)
        yield item


@Resolver.register
def get_video_url(plugin,
                  item_id,
                  video_id,