相关疑难解决方法(0)

无法下载youtube视频

我无法自动检索Youtube视频.这是代码.问题是最后一部分.download = urllib.request.urlopen(download_url).read()

    # Youtube video download script
    # 10n1z3d[at]w[dot]cn

    import urllib.request
    import sys

    print("\n--------------------------")
    print (" Youtube Video Downloader")
    print ("--------------------------\n")

    try:
            video_url = sys.argv[1]
    except:
            video_url = input('[+] Enter video URL: ')

    print("[+] Connecting...")
    try:
            if(video_url.endswith('&feature=related')):
                    video_id = video_url.split('www.youtube.com/watch?v=')[1].split('&feature=related')[0]
            elif(video_url.endswith('&feature=dir')):
                    video_id = video_url.split('www.youtube.com/watch?v=')[1].split('&feature=dir')[0]
            elif(video_url.endswith('&feature=fvst')):
                    video_id = video_url.split('www.youtube.com/watch?v=')[1].split('&feature=fvst')[0]
            elif(video_url.endswith('&feature=channel_page')):
                    video_id = video_url.split('www.youtube.com/watch?v=')[1].split('&feature=channel_page')[0]
            else:
                    video_id = video_url.split('www.youtube.com/watch?v=')[1]
    except:
            print("[-] Invalid URL.")
            exit(1)       
    print("[+] Parsing token...")
    try:
            url = str(urllib.request.urlopen('http://www.youtube.com/get_video_info?&video_id=' + video_id).read())
            token_value = url.split('video_id='+video_id+'&token=')[1].split('&thumbnail_url')[0]

            download_url = "http://www.youtube.com/get_video?video_id=" + video_id …
Run Code Online (Sandbox Code Playgroud)

python file urllib python-3.x

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

file ×1

python ×1

python-3.x ×1

urllib ×1