Commit 16a0b6c0 authored by Lysander Trischler's avatar Lysander Trischler

Add subtitle and ttl in feed

parent e134dc07
......@@ -27,8 +27,8 @@ __copyright__ = "Copyright 2012, Lysander Trischler"
__license__ = "WTFPL"
__maintainer__ = "Lysander Trischler"
__email__ = "software@lyse.isobeef.org"
__version__ = "0.1"
__version_info__ = (0, 1)
__version__ = "0.2"
__version_info__ = (0, 2)
import os.path
import os
......@@ -88,6 +88,8 @@ class Video(object):
raise ValueError("No video ID given!")
if not self.updated:
# It's a pitty the YouTube API does not return video's uplaod timestamps,
# so use current date and time.
self.updated = now()
if not self.title or not self.author:
......@@ -129,7 +131,7 @@ def add_fav(video_id):
if not os.path.exists(index_dirname):
os.makedirs(index_dirname)
else:
# check duplicates
# filter duplicates
with open(INDEX_FILE, "r") as index:
for line in index.readlines():
video = Video(line=line)
......@@ -148,10 +150,13 @@ def gen_atom(max=None):
os.makedirs(atom_dirname)
with open(INDEX_FILE, "r") as index, open(ATOM_FILE, "w") as atom:
atom.write('<?xml version="1.0" encoding="utf-8"?>'
'<feed xmlns="http://www.w3.org/2005/Atom">'
'<feed xmlns="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">'
'<link rel="self" type="application/atom+xml" href="' + CONFIG.get("atom", "url", "https://lyse.isobeef.org/yfav.atom") + '" />'
'<id>' + CONFIG.get("atom", "id", "https://lyse.isobeef.org/yfav.atom") + '</id>'
'<title>' + CONFIG.get("atom", "title", "Lyse's favorite YouTube videos") + '</title>'
'<id>' + CONFIG.get("atom", "id", CONFIG.get("atom", "url", "https://lyse.isobeef.org/yfav.atom")) + '</id>'
'<title>' + CONFIG.get("atom", "title", "Lyse's YouTube videos catapult") + '</title>'
'<subtitle>' + CONFIG.get("atom", "subtitle", "Some awesome videos on YouTube which Lyse thinks are worth to spread. It's mainly a filtered best-of-youtube.com view. Normally updates every 1-2 days.") + '</subtitle>'
'<sy:updatePeriod>' + CONFIG.get("atom", "updatePeriod", "daily") + '</sy:updatePeriod>'
'<sy:updateFrequency>' + CONFIG.get("atom", "updateFrequency", "1") + '</sy:updateFrequency>'
'<updated>' + now() + '</updated>'
'<generator>yfav/' + __version__ + '</generator>\n')
lines = reversed(index.readlines())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment