Improve Atom feed creation (Fixes #2081)

master
Philipp Hagemeister 11 years ago
parent 9b12003c35
commit 317d4edfa8

@ -7,45 +7,44 @@ import textwrap
atom_template = textwrap.dedent("""\ atom_template = textwrap.dedent("""\
<?xml version='1.0' encoding='utf-8'?> <?xml version="1.0" encoding="utf-8"?>
<atom:feed xmlns:atom="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<atom:title>youtube-dl releases</atom:title> <title>youtube-dl releases</title>
<atom:id>https://yt-dl.org/feed/youtube-dl-updates-feed</atom:id> <id>https://yt-dl.org/feed/youtube-dl-updates-feed</id>
<atom:updated>@TIMESTAMP@</atom:updated> <updated>@TIMESTAMP@</updated>
@ENTRIES@ @ENTRIES@
</atom:feed>""") </feed>""")
entry_template = textwrap.dedent(""" entry_template = textwrap.dedent("""
<atom:entry> <entry>
<atom:id>https://yt-dl.org/feed/youtube-dl-updates-feed/youtube-dl-@VERSION@</atom:id> <id>https://yt-dl.org/feed/youtube-dl-updates-feed/youtube-dl-@VERSION@</id>
<atom:title>New version @VERSION@</atom:title> <title>New version @VERSION@</title>
<atom:link href="http://rg3.github.io/youtube-dl" /> <link href="http://rg3.github.io/youtube-dl" />
<atom:content type="xhtml"> <content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml"> <div xmlns="http://www.w3.org/1999/xhtml">
Downloads available at <a href="https://yt-dl.org/downloads/@VERSION@/">https://yt-dl.org/downloads/@VERSION@/</a> Downloads available at <a href="https://yt-dl.org/downloads/@VERSION@/">https://yt-dl.org/downloads/@VERSION@/</a>
</div> </div>
</atom:content> </content>
<atom:author> <author>
<atom:name>The youtube-dl maintainers</atom:name> <name>The youtube-dl maintainers</name>
</atom:author> </author>
<atom:updated>@TIMESTAMP@</atom:updated> <updated>@TIMESTAMP@</updated>
</atom:entry> </entry>
""") """)
now = datetime.datetime.now() now = datetime.datetime.now()
now_iso = now.isoformat() now_iso = now.isoformat() + 'Z'
atom_template = atom_template.replace('@TIMESTAMP@', now_iso) atom_template = atom_template.replace('@TIMESTAMP@', now_iso)
entries=[]
versions_info = json.load(open('update/versions.json')) versions_info = json.load(open('update/versions.json'))
versions = list(versions_info['versions'].keys()) versions = list(versions_info['versions'].keys())
versions.sort() versions.sort()
entries = []
for v in versions: for v in versions:
entry = entry_template.replace('@TIMESTAMP@',v.replace('.','-')) entry = entry_template.replace('@TIMESTAMP@', v.replace('.', '-') + 'T00:00:00Z')
entry = entry.replace('@VERSION@',v) entry = entry.replace('@VERSION@', v)
entries.append(entry) entries.append(entry)
entries_str = textwrap.indent(''.join(entries), '\t') entries_str = textwrap.indent(''.join(entries), '\t')

Loading…
Cancel
Save