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.

23 lines
959 B

  1. #!/usr/bin/env python
  2. import hashlib
  3. import subprocess
  4. import os.path
  5. youtubeDlDir = os.path.join(os.path.dirname(__file__), '..', 'youtube-dl')
  6. # Read template page
  7. template = file('download.html.in', 'r').read()
  8. # Build replacement strings
  9. version = subprocess.check_output([os.path.join(youtubeDlDir, 'youtube-dl'), '--version']).strip()
  10. data = subprocess.check_output(['git', 'show', '%s:youtube-dl' % version], cwd=youtubeDlDir)
  11. url = 'https://github.com/rg3/youtube-dl/raw/%s/youtube-dl' % version
  12. md5sum = hashlib.md5(data).hexdigest()
  13. sha1sum = hashlib.sha1(data).hexdigest()
  14. sha256sum = hashlib.sha256(data).hexdigest()
  15. template = template.replace('@PROGRAM_VERSION@', version)
  16. template = template.replace('@PROGRAM_URL@', url)
  17. template = template.replace('@PROGRAM_MD5SUM@', md5sum)
  18. template = template.replace('@PROGRAM_SHA1SUM@', sha1sum)
  19. template = template.replace('@PROGRAM_SHA256SUM@', sha256sum)
  20. file('download.html', 'w').write(template)