天天看點

用you-get批量下載下傳bilibili的視訊清單

源代碼不能用了,就稍微改了一哈,可以了。https://lolicon.link/2016/08/07/yet-another-method-to-download-video-from-bilibili/

用的是you-get下載下傳的,方法是

python download.py [視訊連結] [分p數]
           
#!/usr/bin/env python
#coding:utf-8

import sys
from subprocess import call

def check_and_go(args):
    try:
        if not (args[0] and args[1]):
            usage_tip(0)
        if "index" in args[0]:
            usage_tip(2)
        else:
            if args[1] == 0:
                usage_tip(2)
            else:
                bilibili_down_them_all(args[0],int(args[1]))
    except IndexError:
        usage_tip(0)
    except ValueError:
        usage_tip(1)

def bilibili_down_them_all(link,p_count):
    for i in range(1,p_count+1):
        print("Start downloading...\n%s\n" % link)
        call("you-get -d " + link + "?p_" + str(i) + ".html", shell=True)

def usage_tip(exit_flag):
    if exit_flag == 0:
        print("Missing parameters !\n")
    else:
        print("Please check you parameters !\n")
    print("Usage: python bilibili_download_them_all.py [PageLink] [VideoCount]")
    print("Example: python bilibili_download_them_all.py http://www.bilibili.com/video/av4432868/ 9")
    sys.exit(exit_flag)

if __name__ == "__main__":
    check_and_go(sys.argv[1:])
           

我檢查了一下b站的視訊播放頁面,發現和Youtube類似,其實是可以直接擷取分段視訊的連結的,這樣用requests下載下傳後直接用ffmpeg拼接起來就可以了,連youget其實都用不上。

繼續閱讀