Created
April 27, 2009 10:42
-
-
Save bradwright/102435 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
import random | |
sys.path.insert( 0, os.path.join( os.path.dirname( __file__ ) ) ) | |
from jinja2 import Template, Environment, FileSystemLoader | |
env = Environment( loader=FileSystemLoader( '.', encoding='utf-8' ) ) | |
video_template = env.get_template( 'video-template.xml' ) | |
class Video( object ): | |
COUNT = 0 | |
def __init__( self, id, title, summary ): | |
# Set date to reflect the ID for easy testing. | |
Video.COUNT += 1 | |
self._data = { | |
'date': u'2009-0%d-0%d 0%d:0%d' % ( Video.COUNT, Video.COUNT, Video.COUNT, Video.COUNT ), | |
'published': u'2009-0%d-0%d 0%d:0%d' % ( Video.COUNT, Video.COUNT, Video.COUNT, Video.COUNT ), | |
# What types can we have? No idea. | |
'type': u'Reportage', | |
# Do we store author names anywhere? | |
'author': u'Author Name', | |
# Right now all the videos are 4:3. We need some 16:9 videos for testing | |
'format': 1, | |
'title': title, | |
'summary': summary, | |
'source': u'Reuters', | |
'permalink': u'http://www.sueddeutsche.de/app/multimedia/video/%d' % Video.COUNT, | |
'artikel': u'http://www.sueddeutsche.de/artikel/%d' % Video.COUNT, | |
'low': { | |
'video': u'http://pix.sueddeutsche.de/video/redaktion/180x134-low-%s.flv' % id, | |
'thumb': u'http://pix.sueddeutsche.de/video/redaktion/180x134-low-%s.jpg' % id | |
}, | |
'mid': { | |
'video': u'http://pix.sueddeutsche.de/video/redaktion/180x134-%s.flv' % id, | |
'thumb': u'http://pix.sueddeutsche.de/video/redaktion/180x134-%s.jpg' % id | |
}, | |
'high': { | |
'video': u'http://pix.sueddeutsche.de/video/redaktion/456x342-%s.flv' % id, | |
'thumb': u'http://pix.sueddeutsche.de/video/redaktion/456x342-%s.jpg' % id | |
} | |
} | |
def render( self ): | |
return video_template.render( self._data ) | |
def main(): | |
videos = [ | |
Video( | |
u'2um2_0424_sde', | |
u'Ein Geheimtipp für die Bayern', | |
u'', | |
).render(), | |
Video( | |
u'270409grippedeutschland', | |
u'RKI sieht Deutschland gerüstet', | |
u'Der Präsident des Robert-Koch-Instituts, Jörg Hacker, sieht die Bundesrepublik mit den bestehenden Pandemie-Plänen auf einen möglichen Ausbruch der Schweinegrippe gut vorbereitet.' | |
).render(), | |
Video( | |
u'270409schweinegrippe', | |
u'Schweinegrippe breitet sich aus', | |
u'In Mexiko ist die Zahl der durch das Virus getöteten Menschen auf 103 gestiegen. Kanada meldete die ersten Fälle. Die USA riefen den Gesundheitsnotstand aus, um schnell Hilfen bereitstellen zu können.' | |
).render(), | |
Video( | |
u'260409ethikreli', | |
u'Ethik oder Reli', | |
u'Berlin stimmt in Volksentscheid über Ethik- und Religionsunterricht ab.' | |
).render(), | |
Video( | |
u'260409grippe', | |
u'Schweinegrippe weitet sich aus', | |
u'An einer New Yorker Schule gibt es acht Verdachtsfälle auf Schweinegrippe. In Mexiko starben bislang 81 Menschen an der neuartigen Virus-Erkrankung' | |
).render(), | |
Video( | |
u'250409schweinegrippe', | |
u'Angst vor Schweinegrippe-Virus', | |
u'In Mexiko sind dutzende Menschen an einem von Schweinen auf Menschen übertragenen Grippevirus gestorben' | |
).render(), | |
Video( | |
u'250409filmpreis', | |
u'Goldene Lolas für "John Rabe"', | |
u'Beim Deutschen Filmpreis hat das Historiendrama "John Rabe" abgeräumt - unter anderem als Bester Film und für den Besten Hauptdarsteller - Ulrich Tukur.' | |
).render() | |
] | |
COUNT = 0 | |
for video in videos: | |
COUNT += 1 | |
f = open( os.path.join( os.path.dirname( __file__ ), '%d.xml' % COUNT ), 'w' ) | |
f.write( video.encode('utf-8') ) | |
f.close() | |
if __name__ == '__main__': | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<video> | |
<!-- Date formats: YYYY-MM-DD HH:MM --> | |
<date>{{ date }}</date> | |
<publish>{{ published }}</publish> | |
<!-- Not sure what this is --> | |
<type>{{ type }}</type> | |
<!-- Do our videos have authors? --> | |
<author>{{ author }}</author> | |
<!-- I don't like magic numbers: 1 == 4:3, 2 == 16:9 --> | |
<format>{{ format }}</format> | |
<title>{{ title }}</title> | |
<summary>{{ summary }}</summary> | |
<source>{{ source }}</source> | |
<permalink>{{ permalink }}</permalink> | |
<articlelink>{{ artikel }}</articlelink> | |
<!-- Moegliche weitere Links auf aehnliche Artikel / Themen --> | |
<topics> | |
<!-- We don't have this yet. | |
<topic> | |
<link>URL des Artikels</link> | |
<text>Headline des Artikels</text> | |
</topic> | |
... | |
--> | |
</topics> | |
<videos> | |
<video quality="high">{{ high.video }}</video> | |
<video quality="mid">{{ mid.video }}</video> | |
<video quality="low">{{ low.video }}</video> | |
</videos> | |
<previewimages> | |
<image quality="high">{{ high.thumb }}</image> | |
<image quality="mid">{{ mid.thumb }}</image> | |
<image quality="low">{{ low.thumb }}</image> | |
</previewimages> | |
<!-- Weitere aehnliche Videos (wahrscheinlich erst spaeter, Videoseite 2.0 ?!?) --> | |
<relatedVideos> | |
<!-- We don't have this yet either. | |
<video> | |
<xmlurl>URL</xmlurl> | |
<title>Titel</title> | |
<type>Schlagwoerter</type> | |
<previewimage>URL</previewimage> | |
</video> | |
--> | |
</relatedVideos> | |
</video> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment