update-sites.py 976 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python3
  2. from __future__ import unicode_literals
  3. import sys
  4. import os
  5. import textwrap
  6. dirn = os.path.dirname
  7. # We must be able to import youtube_dl
  8. sys.path.insert(0, dirn(dirn(dirn(os.path.abspath(__file__)))))
  9. import youtube_dl
  10. from devscripts.utils import read_file, write_file
  11. def main():
  12. template = read_file('supportedsites.html.in')
  13. ie_htmls = []
  14. for ie in youtube_dl.list_extractors(age_limit=None):
  15. ie_html = '<b>{}</b>'.format(ie.IE_NAME)
  16. ie_desc = getattr(ie, 'IE_DESC', None)
  17. if ie_desc is False:
  18. continue
  19. elif ie_desc is not None:
  20. ie_html += ': {}'.format(ie.IE_DESC)
  21. if not ie.working():
  22. ie_html += ' (Currently broken)'
  23. ie_htmls.append('<li>{}</li>'.format(ie_html))
  24. template = template.replace('@SITES@', textwrap.indent('\n'.join(ie_htmls), '\t'))
  25. write_file('supportedsites.html', template)
  26. if __name__ == '__main__':
  27. main()