You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals
  3. import io
  4. import optparse
  5. import os
  6. import sys
  7. # Import youtube_dl
  8. ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
  9. sys.path.insert(0, ROOT_DIR)
  10. import youtube_dl
  11. def main():
  12. parser = optparse.OptionParser(usage='%prog OUTFILE.md')
  13. options, args = parser.parse_args()
  14. if len(args) != 1:
  15. parser.error('Expected an output filename')
  16. outfile, = args
  17. def gen_ies_md(ies):
  18. for ie in ies:
  19. ie_md = '**{0}**'.format(ie.IE_NAME)
  20. ie_desc = getattr(ie, 'IE_DESC', None)
  21. if ie_desc is False:
  22. continue
  23. if ie_desc is not None:
  24. ie_md += ': {0}'.format(ie.IE_DESC)
  25. if not ie.working():
  26. ie_md += ' (Currently broken)'
  27. yield ie_md
  28. ies = sorted(youtube_dl.gen_extractors(), key=lambda i: i.IE_NAME.lower())
  29. out = '# Supported sites\n' + ''.join(
  30. ' - ' + md + '\n'
  31. for md in gen_ies_md(ies))
  32. with io.open(outfile, 'w', encoding='utf-8') as outf:
  33. outf.write(out)
  34. if __name__ == '__main__':
  35. main()