Skip to main content
 首页 » 编程设计

python之如何从源代码重建 python youtube-dl

2024年11月24日11rubylouvre

起初我想承认我是 python 编程的菜鸟。但不知何故,我还是设法弄清楚了如何修改一些 python 正则表达式,因为提取器可以为我获取一些额外的数据。不幸的是,我不知道如何从更改后的源代码构建可执行文件。因为我正在使用 PHP 包装器来使用 youtube-dl ubuntu 可执行文件来抓取一些数据。

我注意到有一个 6 年以上的帖子在

Python youtube-dl recompile

但不幸的是,解决方案没有提供重新编译或重建的方法。我什至还没有在开发人员的官方文档中找到如何重建

https://github.com/ytdl-org/youtube-dl#developer-instructions

Most users do not need to build youtube-dl and can download the builds or get them from their distribution.

To run youtube-dl as a developer, you don't need to build anything either.

最后使用 git 进行开源贡献

  1. Finally, create a pull request. We'll then review and merge it.

但找不到任何可在本地构建以在本地使用的内容。

请您参考如下方法:

如 development instructions 中所述,您可以交互式地运行 youtube-dl

python -m youtube_dl 

当 youtube-dl 存储库在您的 PYTHONPATH 中时,例如因为您的 cwd是 youtube-dl 存储库的根目录。

对于开发,运行测试通常更容易。同样,as documented , 任何这些工作:

python -m unittest discover 
python test/test_download.py 
nosetests 

如果你正在开发一个提取器,你可以运行

python test/test_download.py TestDownload.test_YourExtractor 

只是测试你的提取器。

如果您真的想要一个 youtube-dl 二进制文件,请输入

make 

在 youtube-dl 存储库的根目录中。您将获得一个名为 youtube-dl 的二进制文件。

请注意 make与任何维护良好的软件项目一起工作,尽管一些新千年的时髦语言更愿意重新发明他们自己的不兼容版本。