目錄 [显示]
命令行下載視頻
You-Get
You-Get 乃一小小噠命令行程序,提供便利的方式來下載網絡上的媒體信息。
為什麼那麼多人熱衷於命令行下載呢,因為它可以下載網上絕大部分的主流媒體信息,包括Youtube,B站,微博,優酷,網易音樂等等的媒體信息,而你只需要輸入一句簡單的命令行,這對比網上的一些視頻下載方法可以說是很省事的。
You-Get支持的網站列表
項目源地址:https://you-get.org/
其實利用命令行下載並沒有看上去那麼難,你只需要按部就班跟着做就可以了;
譬如,想要用命令行下載某個視頻,那你需要先安裝You-Get;
安裝
這裡只提供Windows系統常規安裝方法介紹,其他系統請自行查找安裝方法;
需要用到的工具:Python 3
以下是視頻格式轉換工具,根據自己需求安裝:
安裝Python的最新版本(目前最新是3.8.2版),安裝方法是打開上面的官網下載下來安裝即可,安裝目錄隨意(不建議C盤);
安裝過程記得勾選幾個選項
安裝成功之後,就可以輸入命令行下載媒體信息了
Win+R
調出運行命令框→輸入cmd
然後確定(Enter)打開命令框;
開始
下載視頻
以這視頻為例:https://www.bilibili.com/video/BV1TK411L71m
您可以使用 --info
/-i
以查看所有可用畫質與格式;
即輸入命令行:
- you-get -i https://www.bilibili.com/video/BV1TK411L71m #在命令框中鼠標右鍵即為粘貼
- you-get -i https://www.bilibili.com/video/BV1TK411L71m
- site: Bilibili
- title: 【咻咻滿】芒種 美美噠版本(Cover 音闕詩聽/趙方婧)【主播真
- 會玩Show藝篇】13芒種 完整版
- streams: # Available quality and codecs
- [ DASH ] ____________________________________
- - format: dash-flv480
- container: mp4
- quality: 清晰 480P
- size: 11.8 MiB (12373774 bytes)
- # download-with: you-get --format=dash-flv480 [URL]
- - format: dash-flv720
- container: mp4
- quality: 高清 720P
- size: 11.8 MiB (12322266 bytes)
- # download-with: you-get --format=dash-flv720 [URL]
- - format: dash-flv360
- container: mp4
- quality: 流暢 360P
- size: 11.7 MiB (12293960 bytes)
- # download-with: you-get --format=dash-flv360 [URL]
- [ DEFAULT ] _________________________________
- - format: flv720
- container: flv
- quality: 高清 720P
- size: 17.4 MiB (18233240 bytes)
- # download-with: you-get --format=flv720 [URL]
- - format: flv480
- container: flv
- quality: 清晰 480P
- size: 17.4 MiB (18248035 bytes)
- # download-with: you-get --format=flv480 [URL]
- - format: flv360
- container: flv
- quality: 流暢 360P
- size: 11.8 MiB (12382231 bytes)
- # download-with: you-get --format=flv360 [URL]
標有DEFAULT
為默認畫質。如認同,可下載:
- you-get https://www.bilibili.com/video/BV1TK411L71m
或者選擇畫質下載:
- you-get --format=flv480 https://www.bilibili.com/video/BV1TK411L71m
- you-get --format=flv480 https://www.bilibili.com/video/BV1TK411L71m
- site: Bilibili
- title: 【咻咻滿】芒種 美美噠版本(Cover 音闕詩聽/趙方婧)【主播真
- 會玩Show藝篇】13芒種 完整版
- stream:
- - format: flv480
- container: flv
- quality: 清晰 480P
- size: 17.4 MiB (18248035 bytes)
- # download-with: you-get --format=flv480 [URL]
- Downloading 【咻咻滿】芒種 美美噠版本(Cover 音闕詩聽/趙方婧)【主播真
- 會玩Show藝篇】13芒種 完整版.flv ...
- 100% ( 17.4/ 17.4MB) ├████████████████████████████████████████┤[1/1] 606 kB/s
- Downloading 【咻咻滿】芒種 美美噠版本(Cover 音闕詩聽/趙方婧)【主播真
- 會玩Show藝篇】13芒種 完整版.cmt.xml ...
等待命令行執行完成之後,你會發現視頻也已經下載好了,默認下載路徑為C盤>用戶USR(當前用戶文件夾中);
如視頻中帶有字幕,You-Get也會一併下載下來,如示例中字幕以XML格式保存。
注意事項
升級
考慮到 you-get
安裝方法之差異, 請使用:
- pip3 install --upgrade you-get
或下載最新更新:
- you-get https://github.com/soimort/you-get/archive/master.zip
查看所有命令
- you-get -h
下面會介紹幾個常用命令介紹
- you-get -h
- you-get: version 0.4.1432, a tiny downloader that scrapes the web.
- usage: you-get [OPTION]... URL...
- A tiny downloader that scrapes the web
- optional arguments:
- -V, --version Print version and exit
- -h, --help Print this help message and exit
- Dry-run options:
- (no actual downloading)
- -i, --info Print extracted information
- -u, --url Print extracted information with URLs
- --json Print extracted URLs in JSON format
- Download options:
- -n, --no-merge Do not merge video parts
- --no-caption Do not download captions (subtitles, lyrics, danmaku,
- ...)
- -f, --force Force overwriting existing files
- --skip-existing-file-size-check
- Skip existing file without checking file size
- -F STREAM_ID, --format STREAM_ID
- Set video format to STREAM_ID
- -O FILE, --output-filename FILE
- Set output filename
- -o DIR, --output-dir DIR
- Set output directory
- -p PLAYER, --player PLAYER
- Stream extracted URL to a PLAYER
- -c COOKIES_FILE, --cookies COOKIES_FILE
- Load cookies.txt or cookies.sqlite
- -t SECONDS, --timeout SECONDS
- Set socket timeout
- -d, --debug Show traceback and other debug info
- -I FILE, --input-file FILE
- Read non-playlist URLs from FILE
- -P PASSWORD, --password PASSWORD
- Set video visit password to PASSWORD
- -l, --playlist Prefer to download a playlist
- -a, --auto-rename Auto rename same name different files
- -k, --insecure ignore ssl errors
- Proxy options:
- -x HOST:PORT, --http-proxy HOST:PORT
- Use an HTTP proxy for downloading
- -y HOST:PORT, --extractor-proxy HOST:PORT
- Use an HTTP proxy for extracting only
- --no-proxy Never use a proxy
- -s HOST:PORT, --socks-proxy HOST:PORT
- Use an SOCKS5 proxy for downloading
格式
想要選擇格式或畫質下載,在you-get
後面添加相關標籤即可,例如--format=flv480
,如不希望you-get合併視頻,使用--no-merge/-n
下載其他內容
如你有URL,可以直接使用:
- you-get https://stallman.org/rms.jpg
- Site: stallman.org
- Title: rms
- Type: JPEG Image (image/jpeg)
- Size: 0.06 MiB (66482 Bytes)
- Downloading rms.jpg ...
- 100.0% ( 0.1/0.1 MB) ├████████████████████████████████████████┤[1/1] 127 kB/s
或者, you-get
將自動檢查網頁,下載一切有可能感興趣的內容:
- you-get http://kopasas.tumblr.com/post/69361932517
- Site: Tumblr.com
- Title: kopasas
- Type: Unknown type (None)
- Size: 0.51 MiB (536583 Bytes)
- Site: Tumblr.com
- Title: tumblr_mxhg13jx4n1sftq6do1_1280
- Type: Portable Network Graphics (image/png)
- Size: 0.51 MiB (536583 Bytes)
- Downloading tumblr_mxhg13jx4n1sftq6do1_1280.png ...
- 100.0% ( 0.5/0.5 MB) ├████████████████████████████████████████┤[1/1] 22 MB/s
在Google Videos搜索並下載
you-get
可以下載任何東西. 如果不是合法的URL, you-get
將在Google查找並下載最相關視頻.(可能不是最心儀的)。
- you-get "Richard Stallman eats"
暫停與恢復下載
可以使用Ctrl+C 暫停下載.
臨時的.download
文件將保存於輸出目錄。下次使用you-get
傳入相同參數時,下載將從上次繼續開始。如果下載已經完成 (臨時的.download
擴展名消失),you-get
將忽略下載.
用--force
/-f
強行重下載. (注意: 將覆蓋同名文件或臨時文件!)
設置輸出文件名或路徑
使用--output-dir
/-o
設定路徑, --output-filename
/-O
設定輸出文件名:
- you-get -o ~/Videos -O zoo.webm https://www.youtube.com/watch?v=jNQXAC9IVRw
提示:
- 如果原視頻標題含有與系統不兼容字符,這將十分有效.
- 也可以幫助使用腳本批量下載於指定目錄和文件名.
代理設置
使用 --http-proxy
/-x
為you-get
設置HTTP代理:
- you-get -x 127.0.0.1:8087 https://www.youtube.com/watch?v=jNQXAC9IVRw
使用--no-proxy
可強行關閉。
提示:
- 如果經常使用代理 (網絡封鎖了部分網站), 考慮將
you-get
和 proxychains 一同使用,並設置alias you-get="proxychains -q you-get"
(於命令行)。 - 對於某些網站(例如Youku), 如果你需要下載僅供中國大陸觀看的視頻, 可以使用
--extractor-proxy
/-y
單獨為解析器設置代理. 可以使用-y proxy.uku.im:8888
(鳴謝: Unblock Youku 項目)。
觀看視頻
使用 --player
/-p
將視頻投放到播放器播放, 例如 mplayer
或者 vlc
,而不是下載:
- you-get -p vlc https://www.youtube.com/watch?v=jNQXAC9IVRw
或者你想在瀏覽器中觀看而不希望看廣告或評論區:
- $ you-get -p chromium https://www.youtube.com/watch?v=jNQXAC9IVRw
提示:
- 可以使用
-p
開啟下載工具,例如you-get -p uget-gtk https://www.youtube.com/watch?v=jNQXAC9IVRw
, 有時候有可能不靈。
加載cookie
並非所有視頻可供任何人觀看。如果需要登錄以觀看 (例如, 私密視頻), 可能必須將瀏覽器cookie通過--cookies
/-c
加載入 you-get
注意:
- 目前我們支持兩種cookie格式:Mozilla
cookies.sqlite
和 Netscapecookies.txt
.
復用解析數據
使用 --url
/-u
獲得頁面所有可下載URL列表. 使用 --json
以獲得JSON格式.
警告:
- 目前此功能未定型,JSON格式未來有可能變化。
已知問題
如果 you-get
出現問題,不要驚慌. (是的,問題一直存在!)
看看是不是在 https://github.com/soimort/you-get/wiki/Known-Bugs裡面, 搜索 開放Issue. 如果沒人報告,開個新issue, 加上詳細的命令行輸出。
Annie
類似You-Get的命令行下載工具,只是支持視頻地址比You-Get少很多,可以作為備用之選。
Site | URL | ![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
抖音 | https://www.douyin.com | ✓ | |||
嗶哩嗶哩 | https://www.bilibili.com | ✓ | ✓ | ✓ | |
半次元 | https://bcy.net | ✓ | |||
pixivision | https://www.pixivision.net | ✓ | |||
優酷 | https://www.youku.com | ✓ | ✓ | ||
YouTube | https://www.youtube.com | ✓ | ✓ | ||
愛奇藝 | https://www.iqiyi.com | ✓ | |||
芒果TV | https://www.mgtv.com | ✓ | |||
糖豆廣場舞 | http://www.tangdou.com | ✓ | ✓ | ||
Tumblr | https://www.tumblr.com | ✓ | ✓ | ||
Vimeo | https://vimeo.com | ✓ | |||
https://facebook.com | ✓ | ||||
鬥魚視頻 | https://v.douyu.com | ✓ | |||
秒拍 | https://www.miaopai.com | ✓ | |||
微博 | https://weibo.com | ✓ | |||
https://www.instagram.com | ✓ | ✓ | |||
https://twitter.com | ✓ | ||||
騰訊視頻 | https://v.qq.com | ✓ | |||
網易雲音樂 | https://music.163.com | ✓ | |||
音悅台 | https://yinyuetai.com | ✓ | |||
極客時間 | https://time.geekbang.org | ✓ | |||
Pornhub | https://pornhub.com | ✓ | |||
XVIDEOS | https://xvideos.com | ✓ | |||
聯合新聞網 | https://udn.com | ✓ | |||
TikTok | https://www.tiktok.com | ✓ |
和You-Get不同的是,由於Annie是Go語言所寫,需要在Go環境變量中使用,具體操作請看→下載神器annie的安裝及使用;
關於用法基本和You-Get差不多,都是一句簡單的命令行,而且上文也有提及,這裡就不贅述了。
相關事項
項目源地址:https://github.com/iawia002/annie
查看所有命令
- annie -h
——未完待續——