BackBox
V2EX  ›  问与答

如何用脚本下载Youtube视频?

  •  
  •   BackBox · Jan 30, 2013 · 6335 views
    This topic created in 4878 days ago, the information mentioned may be changed or developed.
    我知道有youtube-dl这个项目。但是源代码太多了。不知道哪个是主文件?

    我想实现的功能很简单的。就是传入一个youtube视频的地址。可以得到这个视频的含有的不同清晰度和下载。


    谢谢
    26 replies    1970-01-01 08:00:00 +08:00
    BackBox
        1
    BackBox  
    OP
       Jan 30, 2013
    就是拦截请求然后分析地址中各部分的组成而已.

    论坛的朋友这么说的。

    但是没有明白,如何实现。
    alexrezit
        2
    alexrezit  
       Jan 30, 2013   ❤️ 1
    如果只是使用而不研究原理, 用包管理安装就行了 (Mac OS X w/ Homebrew):
    $ brew install youtube-dl
    研究原理也很无聊的, 无非就是从源码里爬个链接算算 id 什么的.
    BackBox
        3
    BackBox  
    OP
       Jan 30, 2013
    @alexrezit 其实1楼的建议就是提取你的建议。

    知道youtube-dl。

    但是想自己实现。从源码中爬个链接。没有太明白。返回的html页面中的没有可以下载的地址吧。
    BackBox
        4
    BackBox  
    OP
       Jan 30, 2013
    @alexrezit 你ios版本的youtube-download就是用了youtube-dl的代码吗?
    alexrezit
        5
    alexrezit  
       Jan 30, 2013
    @BackBox
    没做过 iOS 的啊...
    我之前倒是写过一个 Mac 上的爬链接的工具, 不过自从 YouTube 改了算法... 已经弃了很久了.
    BackBox
        6
    BackBox  
    OP
       Jan 30, 2013
    @alexrezit 就是那个mac版本的。
    alexrezit
        7
    alexrezit  
       Jan 30, 2013
    @BackBox
    没用, 就自己写的, 后来改了算法, 加了一些参数, 懒得研究, 就没更新过.
    leofml
        8
    leofml  
       Jan 30, 2013   ❤️ 1
    难道不应该是这个? [Youtube Video and Mp3 Downloader]( http://userscripts.org/scripts/show/153688 )
    BackBox
        9
    BackBox  
    OP
       Jan 30, 2013
    @leofml js学的很烂。囧。
    BackBox
        10
    BackBox  
    OP
       Jan 30, 2013
    @leofml 是否有python或者ruby简易版本。
    BackBox
        12
    BackBox  
    OP
       Jan 30, 2013
    @nazor 这个也是调用别人的服务。
    TONYHEAD
        13
    TONYHEAD  
       Jan 31, 2013   ❤️ 1
    就是那个没有后缀的 youtube-dl ,一个文件搞定。
    BackBox
        14
    BackBox  
    OP
       Jan 31, 2013
    BackBox
        15
    BackBox  
    OP
       Jan 31, 2013
    @TONYHEAD 表示好复杂啊.

    请教.
    shiyulei
        16
    shiyulei  
       Jan 31, 2013
    http://userscripts.org/scripts/show/25105 我在用这个脚本,很好用。
    TONYHEAD
        17
    TONYHEAD  
       Jan 31, 2013
    @BackBox 是的,是那个文件,单独一个文件,在命令行里执行。

    例如:

    ./youtube-dl -t

    要求Python 2.7或以上。
    TONYHEAD
        18
    TONYHEAD  
       Jan 31, 2013
    呃。。视频自动解析了。。。

    ./youtube-dl -t h T T p://www.youtube.com/watch?v=0aydlo05fIA
    BackBox
        19
    BackBox  
    OP
       Jan 31, 2013
    @TONYHEAD 我想知道实现原理.

    那个源码看不懂.
    run2
        20
    run2  
       Jan 31, 2013   ❤️ 1
    BackBox
        21
    BackBox  
    OP
       Jan 31, 2013
    @sobigfish 不懂....
    TONYHEAD
        22
    TONYHEAD  
       Jan 31, 2013
    @BackBox 我也不懂,普通电脑用户。 o(︶︿︶)o
    BackBox
        23
    BackBox  
    OP
       Feb 1, 2013
    @zythum 朱一帮帮忙
    userscripts.org/scripts/show/62634 js
    说说啥原理
    zythum
        24
    zythum  
       Feb 1, 2013   ❤️ 1
    过程类似于朱一的妈妈再也不怕我的macbook发热计划。
    就是用页面上的一些参数去拼video的播放地址。
    他是找flashvar的参数去拼的。
    alexrezit
        25
    alexrezit  
       Feb 1, 2013 via iPhone
    @zythum
    正解.
    BackBox
        26
    BackBox  
    OP
       Feb 7, 2013
    @zythum 感谢。

    但是不知道有什么方法找到这些参数?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   943 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 21:44 · PVG 05:44 · LAX 14:44 · JFK 17:44
    ♥ Do have faith in what you're doing.