Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

77 rindas
2.3KB

  1. #!/usr/bin/env python3
  2. from __future__ import unicode_literals
  3. import datetime
  4. import io
  5. import json
  6. import textwrap
  7. atom_template = textwrap.dedent("""\
  8. <?xml version="1.0" encoding="utf-8"?>
  9. <feed xmlns="http://www.w3.org/2005/Atom">
  10. <link rel="self" href="http://ytdl-org.github.io/youtube-dl/update/releases.atom" />
  11. <title>youtube-dl releases</title>
  12. <id>https://yt-dl.org/feed/youtube-dl-updates-feed</id>
  13. <updated>@TIMESTAMP@</updated>
  14. @ENTRIES@
  15. </feed>""")
  16. entry_template = textwrap.dedent("""
  17. <entry>
  18. <id>https://yt-dl.org/feed/youtube-dl-updates-feed/youtube-dl-@VERSION@</id>
  19. <title>New version @VERSION@</title>
  20. <link href="http://ytdl-org.github.io/youtube-dl" />
  21. <content type="xhtml">
  22. <div xmlns="http://www.w3.org/1999/xhtml">
  23. Downloads available at <a href="https://yt-dl.org/downloads/@VERSION@/">https://yt-dl.org/downloads/@VERSION@/</a>
  24. </div>
  25. </content>
  26. <author>
  27. <name>The youtube-dl maintainers</name>
  28. </author>
  29. <updated>@TIMESTAMP@</updated>
  30. </entry>
  31. """)
  32. now = datetime.datetime.now()
  33. now_iso = now.isoformat() + 'Z'
  34. atom_template = atom_template.replace('@TIMESTAMP@', now_iso)
  35. versions_info = json.load(open('update/versions.json'))
  36. versions = list(versions_info['versions'].keys())
  37. versions.sort()
  38. entries = []
  39. for v in versions:
  40. fields = v.split('.')
  41. year, month, day = map(int, fields[:3])
  42. faked = 0
  43. patchlevel = 0
  44. while True:
  45. try:
  46. datetime.date(year, month, day)
  47. except ValueError:
  48. day -= 1
  49. faked += 1
  50. assert day > 0
  51. continue
  52. break
  53. if len(fields) >= 4:
  54. try:
  55. patchlevel = int(fields[3])
  56. except ValueError:
  57. patchlevel = 1
  58. timestamp = '%04d-%02d-%02dT00:%02d:%02dZ' % (year, month, day, faked, patchlevel)
  59. entry = entry_template.replace('@TIMESTAMP@', timestamp)
  60. entry = entry.replace('@VERSION@', v)
  61. entries.append(entry)
  62. entries_str = textwrap.indent(''.join(entries), '\t')
  63. atom_template = atom_template.replace('@ENTRIES@', entries_str)
  64. with io.open('update/releases.atom', 'w', encoding='utf-8') as atom_file:
  65. atom_file.write(atom_template)