logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

make_readme.py (783B)


  1. from __future__ import unicode_literals
  2. import os.path
  3. import re
  4. import sys
  5. dirn = os.path.dirname
  6. sys.path.insert(0, dirn(dirn(os.path.abspath(__file__))))
  7. from utils import read_file
  8. from youtube_dl.compat import compat_open as open
  9. README_FILE = 'README.md'
  10. helptext = sys.stdin.read()
  11. if isinstance(helptext, bytes):
  12. helptext = helptext.decode('utf-8')
  13. oldreadme = read_file(README_FILE)
  14. header = oldreadme[:oldreadme.index('# OPTIONS')]
  15. footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
  16. options = helptext[helptext.index(' General Options:') + 19:]
  17. options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options)
  18. options = '# OPTIONS\n' + options + '\n'
  19. with open(README_FILE, 'w', encoding='utf-8') as f:
  20. f.write(header)
  21. f.write(options)
  22. f.write(footer)