本文记录一些我使用过的开源项目的操作过程,以防因为时间久远而忘记过去的我是如何成功使用的。

you-get:视频下载

github万star的经典项目,可用于下载很多视频网站的视频。

Github链接:https://github.com/soimort/you-get

使用

C:\Users\kljxn>you-get https://www.youtube.com/watch?v=6E-jLv1oHCE
site:                YouTube
title:               我 的 泳 装
stream:
    - itag:          22
      container:     mp4
      quality:       hd720
      size:          21.1 MiB (22083826 bytes)
    # download-with: you-get --itag=22 [URL]

Downloading 我 的 泳 装.mp4 ...
 100% ( 21.1/ 21.1MB) ├████████████████████████████████████████┤[1/1]   61 MB/s

1572013450693

下载到cmd当前工作目录。上图中下载到C:\Users\kljxn

踩坑

网上很多教程上使用you-get -i 'https://www.youtube.com/watch?v=6E-jLv1oHCE'

C:\Users\kljxn>you-get -i 'https://www.youtube.com/watch?v=6E-jLv1oHCE'
you-get: [error] oops, something went wrong.
you-get: don't panic, c'est la vie. please try the following steps:
you-get:   (1) Rule out any network problem.
you-get:   (2) Make sure you-get is up-to-date.
you-get:   (3) Check if the issue is already known, on
you-get:         https://github.com/soimort/you-get/wiki/Known-Bugs
you-get:         https://github.com/soimort/you-get/issues
you-get:   (4) Run the command with '--debug' option,
you-get:       and report this issue with the full output.

1572013708632

后面带上--debug,可以查看报错信息。

C:\Users\kljxn>you-get -i 'https://www.youtube.com/watch?v=6E-jLv1oHCE' --debug
[DEBUG] get_location: http://'https://www.youtube.com/watch?v=6E-jLv1oHCE'
[DEBUG] HTTP Error with code400
[DEBUG] HTTP Error with code400
[DEBUG] HTTP Error with code400
[DEBUG] get_location: http://'https://www.youtube.com/watch?v=6E-jLv1oHCE'
[DEBUG] HTTP Error with code400
[DEBUG] HTTP Error with code400
[DEBUG] HTTP Error with code400
you-get: version 0.4.1355, a tiny downloader that scrapes the web.
you-get: Namespace(URL=["'https://www.youtube.com/watch?v=6E-jLv1oHCE'"], auto_rename=False, cookies=None, debug=True, extractor_proxy=None, force=False, format=None, help=False, http_proxy=None, info=True, input_file=None, insecure=False, itag=None, json=False, no_caption=False, no_merge=False, no_proxy=False, output_dir='.', output_filename=None, password=None, player=None, playlist=False, skip_existing_file_size_check=False, socks_proxy=None, stream=None, timeout=600, url=False, version=False)
Traceback (most recent call last):
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 1737, in url_to_module
    location = get_location(url) # t.co isn't happy with fake_headers
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 388, in get_location
    res = urlopen_with_retry(req)
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 412, in urlopen_with_retry
    raise http_error
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 403, in urlopen_with_retry
    return request.urlopen(*args, **kwargs)
  File "c:\cs\python37\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "c:\cs\python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "c:\cs\python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\cs\python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "c:\cs\python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "c:\cs\python37\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Invalid header received from client

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\cs\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\cs\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\CS\Python37\Scripts\you-get.exe\__main__.py", line 7, in <module>
  File "c:\cs\python37\lib\site-packages\you_get\__main__.py", line 92, in main
    main(**kwargs)
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 1758, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 1646, in script_main
    **extra
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 1302, in download_main
    download(url, **kwargs)
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 1748, in any_download
    m, url = url_to_module(url)
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 1739, in url_to_module
    location = get_location(url, headers=fake_headers)
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 388, in get_location
    res = urlopen_with_retry(req)
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 412, in urlopen_with_retry
    raise http_error
  File "c:\cs\python37\lib\site-packages\you_get\common.py", line 403, in urlopen_with_retry
    return request.urlopen(*args, **kwargs)
  File "c:\cs\python37\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "c:\cs\python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "c:\cs\python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\cs\python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "c:\cs\python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "c:\cs\python37\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Invalid header received from client

400状态码是bad requests的意思。

dhbooker:欢乐书客小说下载

左转我之前写的博文:零基础运行golang项目

Last modification:September 9th, 2020 at 03:22 pm