Python youtube-dl重新编译 [英] Python youtube-dl recompile

查看:214
本文介绍了Python youtube-dl重新编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

旧的youtube-dl过去只是一个文件,因此我很容易进行编辑.新版本中包含多个文件.为了使其在我的服务器上正常工作,我需要提取文件并更改python路径.现在如何将其放回原处? youtube-dl网站说要进行编译.

The old youtube-dl use to be just one file so it was easy for me to edit. The new version has multiple files inside of it. To get it to work on my server I needed to extract the files and change the python path. Now how do I put it back together? The youtube-dl site says make compile.

youtube-dl包含 main .py, init .py,FileDownloader.py,InfoExtractors.py,PostProcessor.py,utils.py

youtube-dl contains main.py, init.py, FileDownloader.py, InfoExtractors.py, PostProcessor.py, utils.py

我需要将这些脚本放回单个youtube-dl文件中.我正在运行CentOS.

I need to put those scripts back into a single youtube-dl file. I'm running CentOS.

感谢您的帮助!

推荐答案

如果只想更改解释器行(即hashbang),则应编辑该文件.

If all you want is to change the interpreter line (the hashbang), you should edit the file.

因为它是一个二进制文件,所以不能使用常规的文本编辑器.我建议只使用Python脚本对其进行

Since it's a binary file, you can't use a normal text editor. I'd recommend just editing it with a Python script:

with open('youtube-dl', 'rb') as f:
    header = f.readline()
    zipfile = f.read()

with open('youtube-dl-new', 'wb') as f:
    print >> f, '#!/your/new/hashbang/line'
    f.write(zipfile)

在Python 3中:

In Python 3:

with open('youtube-dl', 'rb') as f:
    header = f.readline()
    zipfile = f.read()

with open('youtube-dl-new', 'wb') as f:
    print('#!/your/new/hashbang/line', file=f)
    f.write(zipfile)

这篇关于Python youtube-dl重新编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆