Python youtube-dl recompile

大城市里の小女人 提交于 2019-12-11 03:55:30

问题


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 contains main.py, init.py, FileDownloader.py, InfoExtractors.py, PostProcessor.py, utils.py

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

Thanks for your help!


回答1:


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

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)

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)


来源:https://stackoverflow.com/questions/12683518/python-youtube-dl-recompile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!