예제 #1
0
def get_video_url(params):
    """Get video URL and start video player"""
    if params.next == 'play_l':
        return params.url_live
    elif params.next == 'play_r' or params.next == 'download_video':
        # Case Youtube
        if 'youtube' in params.video_url:
            video_id = re.compile(
                'www.youtube.com/embed/(.*?)[\?\"\&]').findall(
                params.video_url)[0]
            if params.next == 'download_video':
                return resolver.get_stream_youtube(
                    video_id, True)
            else:
                return resolver.get_stream_youtube(
                    video_id, False)
        # Case Vimeo
        elif 'vimeo' in params.video_url:
            video_id = re.compile('player.vimeo.com/video/(.*?)[\?\"\&]').findall(
                params.video_url)[0]
            if params.next == 'download_video':
                return resolver.get_stream_vimeo(
                    video_id, True)
            else:
                return resolver.get_stream_vimeo(
                    video_id, False)
예제 #2
0
def get_video_url(params):
    """Get video URL and start video player"""
    if params.next == 'play_r' or params.next == 'download_video':
        file_path = utils.get_webcontent(params.video_url)
        video_soup = bs(file_path, 'html.parser')
        video_iframe = video_soup.find('iframe')

        url_video_resolver = video_iframe.get('src')

        # Case Youtube
        if 'youtube' in url_video_resolver:
            video_id = re.compile('www.youtube.com/embed/(.*?)[\?\"\&]'
                                  ).findall(url_video_resolver)[0]
            if params.next == 'download_video':
                return resolver.get_stream_youtube(video_id, True)
            else:
                return resolver.get_stream_youtube(video_id, False)
        # Case Vimeo
        elif 'vimeo' in url_video_resolver:
            video_id = re.compile('player.vimeo.com/video/(.*?)[\?\"]'
                                  ).findall(url_video_resolver)[0]
            if params.next == 'download_video':
                return resolver.get_stream_vimeo(video_id, True)
            else:
                return resolver.get_stream_vimeo(video_id, False)
        else:
            # TODO
            return ''
예제 #3
0
def get_video_url(params):
    """Get video URL and start video player"""
    if params.next == 'play_r' or params.next == 'download_video':
        if params.isyoutube == 'True':
            if params.next == 'download_video':
                return resolver.get_stream_youtube(params.video_id, True)
            else:
                return resolver.get_stream_youtube(params.video_id, False)
        else:
            if params.next == 'download_video':
                return resolver.get_stream_vimeo(params.video_id, True)
            else:
                return resolver.get_stream_vimeo(params.video_id, False)
def get_video_url(params):
    """Get video URL and start video player"""
    if params.next == 'play_l':
        return params.url_live
    elif params.next == 'play_r' or params.next == 'download_video':
        # Case Youtube
        if 'youtube' in params.video_url:
            video_id = re.compile(
                'www.youtube.com/embed/(.*?)[\?\"\&]').findall(
                    params.video_url)[0]
            if params.next == 'download_video':
                return resolver.get_stream_youtube(video_id, True)
            else:
                return resolver.get_stream_youtube(video_id, False)
        # Case Vimeo
        elif 'vimeo' in params.video_url:
            video_id = re.compile(
                'player.vimeo.com/video/(.*?)[\?\"\&]').findall(
                    params.video_url)[0]
            if params.next == 'download_video':
                return resolver.get_stream_vimeo(video_id, True)
            else:
                return resolver.get_stream_vimeo(video_id, False)
예제 #5
0
def get_video_url(params):
    """Get video URL and start video player"""
    if params.next == 'play_l':
        live_html = utils.get_webcontent(URL_LIVE)
        return re.compile('source src=\"(.*?)\"').findall(live_html)[0]
    elif params.next == 'play_r' or params.next == 'download_video':
        # Case Youtube
        if 'youtube' in params.video_url:
            video_id = re.compile(
                'www.youtube.com/embed/(.*?)[\?\"\&]').findall(
                    params.video_url)[0]
            if params.next == 'download_video':
                return resolver.get_stream_youtube(video_id, True)
            else:
                return resolver.get_stream_youtube(video_id, False)
        # Case Vimeo
        elif 'vimeo' in params.video_url:
            video_id = re.compile(
                'player.vimeo.com/video/(.*?)[\?\"\&]').findall(
                    params.video_url)[0]
            if params.next == 'download_video':
                return resolver.get_stream_vimeo(video_id, True)
            else:
                return resolver.get_stream_vimeo(video_id, False)
def get_video_url(params):
    """Get video URL and start video player"""
    video_json = utils.get_webcontent(URL_API_MEDIA %
                                      (params.video_id, PARTNER))
    video_json_parser = json.loads(video_json)

    desired_quality = common.PLUGIN.get_setting('quality')

    url = ''
    if 'rendition' in video_json_parser["media"]:
        # (Video Hosted By Allocine)
        if desired_quality == "DIALOG":
            all_datas_videos_quality = []
            all_datas_videos_path = []
            for media in video_json_parser["media"]["rendition"]:
                all_datas_videos_quality.append(media["bandwidth"]["$"])
                all_datas_videos_path.append(media["href"])
            seleted_item = common.sp.xbmcgui.Dialog().select(
                _('Choose video quality'), all_datas_videos_quality)
            if seleted_item == -1:
                return None
            url = all_datas_videos_path[seleted_item]
        elif desired_quality == "BEST":
            for media in video_json_parser["media"]["rendition"]:
                url = media["href"]
        else:
            for media in video_json_parser["media"]["rendition"][0]:
                url = media["href"]
        if requests.get(url, stream=True).status_code == 404:
            utils.send_notification(common.ADDON.get_localized_string(30111))
            return ''
        return url
    else:
        # (Video Not Hosted By Allocine)
        url_video_embeded = re.compile('src=\'(.*?)\'').findall(
            video_json_parser["media"]["trailerEmbed"])[0]
        if 'allocine' in url_video_embeded:
            url_video_embeded_html = utils.get_webcontent(url_video_embeded)
            url_video_resolver = re.compile('data-model="(.*?)"').findall(
                url_video_embeded_html)[0]
            url_video_resolver = url_video_resolver.replace('"', '"')
            url_video_resolver = url_video_resolver.replace('\\', '')
            url_video_resolver = url_video_resolver.replace('&', '&')
            url_video_resolver = url_video_resolver.replace('%2F', '/')
            # Case Youtube
            if 'youtube' in url_video_resolver:
                video_id = re.compile('www.youtube.com/embed/(.*?)[\?\"\&]'
                                      ).findall(url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_youtube(video_id, True)
                else:
                    return resolver.get_stream_youtube(video_id, False)
            # Case DailyMotion
            elif 'dailymotion' in url_video_resolver:
                video_id = re.compile(r'embed/video/(.*?)[\"\?]').findall(
                    url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_dailymotion(video_id, True)
                else:
                    return resolver.get_stream_dailymotion(video_id, False)
            # Case Facebook
            elif 'facebook' in url_video_resolver:
                video_id = re.compile('www.facebook.com/allocine/videos/(.*?)/'
                                      ).findall(url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_facebook(video_id, True)
                else:
                    return resolver.get_stream_facebook(video_id, False)
            # Case Vimeo
            elif 'vimeo' in url_video_resolver:
                video_id = re.compile('player.vimeo.com/video/(.*?)"').findall(
                    url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_vimeo(video_id, True)
                else:
                    return resolver.get_stream_vimeo(video_id, False)
            # TO DO ? (return an error)
            else:
                return ''
        else:
            # Case Youtube
            if 'youtube' in url_video_embeded:
                video_id = re.compile('www.youtube.com/embed/(.*?)[\?\"\&]'
                                      ).findall(url_video_embeded)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_youtube(video_id, True)
                else:
                    return resolver.get_stream_youtube(video_id, False)
            # TO DO ? (return an error)
            else:
                return ''
예제 #7
0
def get_video_url(params):
    """Get video URL and start video player"""
    video_json = utils.get_webcontent(
        URL_API_MEDIA % (params.video_id, PARTNER))
    video_json_parser = json.loads(video_json)

    desired_quality = common.PLUGIN.get_setting('quality')

    url = ''
    if 'rendition' in video_json_parser["media"]:
        # (Video Hosted By Allocine)
        if desired_quality == "DIALOG":
            all_datas_videos_quality = []
            all_datas_videos_path = []
            for media in video_json_parser["media"]["rendition"]:
                all_datas_videos_quality.append(
                    media["bandwidth"]["$"])
                all_datas_videos_path.append(media["href"])
            seleted_item = common.sp.xbmcgui.Dialog().select(
                common.GETTEXT('Choose video quality'),
                all_datas_videos_quality)
            if seleted_item == -1:
                return None
            url = all_datas_videos_path[seleted_item]
        elif desired_quality == "BEST":
            for media in video_json_parser["media"]["rendition"]:
                url = media["href"]
        else:
            for media in video_json_parser["media"]["rendition"][0]:
                url = media["href"]
        if requests.get(url, stream=True).status_code == 404:
            utils.send_notification(
                common.ADDON.get_localized_string(30710))
            return ''
        return url
    else:
        # (Video Not Hosted By Allocine)
        url_video_embeded = re.compile(
            'src=\'(.*?)\''
            ).findall(video_json_parser["media"]["trailerEmbed"])[0]
        if 'allocine' in url_video_embeded:
            url_video_embeded_html = utils.get_webcontent(url_video_embeded)
            url_video_resolver = re.compile(
                'data-model="(.*?)"'
            ).findall(url_video_embeded_html)[0]
            url_video_resolver = url_video_resolver.replace('"', '"')
            url_video_resolver = url_video_resolver.replace('\\','')
            url_video_resolver = url_video_resolver.replace('&','&')
            url_video_resolver = url_video_resolver.replace('%2F','/')
            # Case Youtube
            if 'youtube' in url_video_resolver:
                video_id = re.compile(
                    'www.youtube.com/embed/(.*?)[\?\"\&]').findall(
                    url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_youtube(
                        video_id, True)
                else:
                    return resolver.get_stream_youtube(
                        video_id, False)
            # Case DailyMotion
            elif 'dailymotion' in url_video_resolver:
                video_id = re.compile(
                    r'embed/video/(.*?)[\"\?]').findall(
                    url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_dailymotion(
                        video_id, True)
                else:
                    return resolver.get_stream_dailymotion(
                        video_id, False)
            # Case Facebook
            elif 'facebook' in url_video_resolver:
                video_id = re.compile(
                    'www.facebook.com/allocine/videos/(.*?)/').findall(
                    url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_facebook(
                        video_id, True)
                else:
                    return resolver.get_stream_facebook(
                        video_id, False)
            # Case Vimeo
            elif 'vimeo' in url_video_resolver:
                video_id = re.compile('player.vimeo.com/video/(.*?)"').findall(
                    url_video_resolver)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_vimeo(
                        video_id, True)
                else:
                    return resolver.get_stream_vimeo(
                        video_id, False)
            else:
                return ''
        else:
            # Case Youtube
            if 'youtube' in url_video_embeded:
                video_id = re.compile(
                    'www.youtube.com/embed/(.*?)[\?\"\&]').findall(
                    url_video_embeded)[0]
                if params.next == 'download_video':
                    return resolver.get_stream_youtube(
                        video_id, True)
                else:
                    return resolver.get_stream_youtube(
                        video_id, False)
            else:
                return ''