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.

56 lines
1.7 KiB

  1. #!/usr/bin/env python3
  2. import datetime
  3. import textwrap
  4. import json
  5. atom_template=textwrap.dedent("""\
  6. <?xml version='1.0' encoding='utf-8'?>
  7. <atom:feed xmlns:atom="http://www.w3.org/2005/Atom">
  8. <atom:title>youtube-dl releases</atom:title>
  9. <atom:id>youtube-dl-updates-feed</atom:id>
  10. <atom:updated>@TIMESTAMP@</atom:updated>
  11. @ENTRIES@
  12. </atom:feed>""")
  13. entry_template=textwrap.dedent("""
  14. <atom:entry>
  15. <atom:id>youtube-dl-@VERSION@</atom:id>
  16. <atom:title>New version @VERSION@</atom:title>
  17. <atom:link href="http://rg3.github.io/youtube-dl" />
  18. <atom:content type="xhtml">
  19. <div xmlns="http://www.w3.org/1999/xhtml">
  20. Downloads available at <a href="https://yt-dl.org/downloads/@VERSION@/">https://yt-dl.org/downloads/@VERSION@/</a>
  21. </div>
  22. </atom:content>
  23. <atom:author>
  24. <atom:name>The youtube-dl maintainers</atom:name>
  25. </atom:author>
  26. <atom:updated>@TIMESTAMP@</atom:updated>
  27. </atom:entry>
  28. """)
  29. now = datetime.datetime.now()
  30. now_iso = now.isoformat()
  31. atom_template = atom_template.replace('@TIMESTAMP@',now_iso)
  32. entries=[]
  33. versions_info = json.load(open('update/versions.json'))
  34. versions = list(versions_info['versions'].keys())
  35. versions.sort()
  36. for v in versions:
  37. entry = entry_template.replace('@TIMESTAMP@',v.replace('.','-'))
  38. entry = entry.replace('@VERSION@',v)
  39. entries.append(entry)
  40. entries_str = textwrap.indent(''.join(entries), '\t')
  41. atom_template = atom_template.replace('@ENTRIES@', entries_str)
  42. with open('update/releases.atom','w',encoding='utf-8') as atom_file:
  43. atom_file.write(atom_template)