you-get:一行命令下载视频和Python简单使用you-get

you-get:一行命令下载视频和Python简单使用you-get

  • 1、安装you-get库
  • 2、you-get库的使用
    • 2.1、下载命令:you-get+URL
    • 2.2、下载命令:-l
  • 3、通过python 使用you-get

1、安装you-get库

安装you-get库如下所示

(spider) E:\Document\Video\you-get_Video\BLACKPINK>pip install you-get
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting you-get
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a3/90/29332796e5248a37caae04e50564dcfad183b77f5143339dffa14791b425/you_get-0.4.1620-py3-none-any.whl (230 kB)
Installing collected packages: you-get
Successfully installed you-get-0.4.1620

2、you-get库的使用

2.1、下载命令:you-get+URL

一般的you-get 下载命令如下所示

you-get  URL

例如:you-get https://www.bilibili.com/video/BV13V41117xc?spm_id_from=333.337.search-card.all.click

  • 效果如下:
(spider) E:\Document\Video\you-get_Video\BLACKPINK>you-get  https://www.bilibili.com/video/BV13V41117xc?spm_id_from=333.337.search-card.all.click
you-get: This is a multipart video. (use --playlist to download all parts.)
site:                Bilibili
title:               【计算机导论】计算机科学导论(大神之路-起始篇) (P1. 0.起始篇)
stream:
    - format:        flv
      container:     flv
      quality:       高清 1080P
      size:          18.3 MiB (19184674 bytes)
    # download-with: you-get --format=flv [URL]

Downloading 【计算机导论】计算机科学导论(大神之路-起始篇) (P1. 0.起始篇).flv ...
 6.8% (  1.2/ 18.3MB) ├███─────────────────────────────────────┤[1/1]  122 kB/s

you-get:一行命令下载视频和Python简单使用you-get_第1张图片

2.2、下载命令:-l

下载命令:-l使用如下所示。
例如

you-get -i https://www.bilibili.com/video/BV1vx411p7yn?spm_id_from=333.337.search-card.all.click&vd_source=e3ed038abbffc416fc9c30fc99037706
  • 效果如下所示。
    you-get:一行命令下载视频和Python简单使用you-get_第2张图片
  • 运行的代码如下所示。
(spider) C:\WINDOWS\system32>you-get -i https://www.bilibili.com/video/BV1vx411p7yn?spm_id_from=333.337.search-card.all.click&vd_source=e3ed038abbffc416fc9c30fc99037706
you-get: This is a multipart video. (use --playlist to download all parts.)
site:                Bilibili
title:               【BLACKPINK】BLACKPINK综艺合集(更新至181221《美里秋》) (P1. 181221【美里秋】EP.6)
streams:             # Available quality and codecs
    [ DASH ] ____________________________________
    - format:        dash-flv720
      container:     mp4
      quality:       高清 720P
      size:          1083.5 MiB (1136105582 bytes)
    # download-with: you-get --format=dash-flv720 [URL]

    - format:        dash-flv480
      container:     mp4
      quality:       清晰 480P
      size:          608.6 MiB (638169151 bytes)
    # download-with: you-get --format=dash-flv480 [URL]

    - format:        dash-flv360
      container:     mp4
      quality:       流畅 360P
      size:          222.2 MiB (233020094 bytes)
    # download-with: you-get --format=dash-flv360 [URL]

    [ DEFAULT ] _________________________________
    - format:        flv720
      container:     flv
      quality:       高清 720P
      size:          1108.4 MiB (1162269877 bytes)
    # download-with: you-get --format=flv720 [URL]

    - format:        flv480
      container:     flv
      quality:       清晰 480P
      size:          492.3 MiB (516196104 bytes)
    # download-with: you-get --format=flv480 [URL]

    - format:        flv360
      container:     flv
      quality:       流畅 360P
      size:          302.0 MiB (316714843 bytes)
    # download-with: you-get --format=flv360 [URL]

  • 可以看到视频的下载信息。
  • 视频具有下载信息的格式。

3、通过python 使用you-get


import sys
import you_get


def VideoDownloads(url, path):
    sys.argv = ['you-get', '-o', path, url]
    you_get.main()


if __name__ == '__main__':
    # 视频网站的地址
    url = 'https://www.bilibili.com/video/BV13V41117xc?spm_id_from=333.337.search-card.all.click'
    # 视频输出的位置
    path = 'E:\\Document\\Video\\you-get_Video'
    VideoDownloads(url, path)
    

运行结果如下:
you-get:一行命令下载视频和Python简单使用you-get_第3张图片

你可能感兴趣的:(#,Python爬虫,#,Python爬虫高级教程,Python,python,音视频,开发语言,you-get,Python爬虫)