Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # coding: utf-8
- import io, os, sys
- import xml.etree.ElementTree as ElementTree
- for filename in sys.argv[1:]:
- if os.path.exists(filename):
- doc = ElementTree.parse(filename)
- title = doc.find('title').text or "Kein Titel"
- year = doc.find('year').text or "Jahr ?"
- plot = doc.find('plot').text or "Keine Inhaltsangabe"
- votes = doc.find('ratings/rating/votes').text or "-"
- director = doc.find('director').text or "?"
- runtime = doc.find('runtime').text or "X"
- if runtime == "0": runtime = "X"
- rating = doc.find('ratings/rating/value').text
- if rating is None: votes = "-"
- if rating is None: rating = "-.-"
- country = doc.find('country').text or "Land ?"
- if country == "United Kingdom": country = "GB"
- if country == "France": country = "Frankreich"
- if country == "Australia": country = "Australien"
- if country == "Belgium": country = "Belgien"
- if country == "Germany": country = "Deutschland"
- if country == "United States of America": country = "USA"
- if country == "Netherlands": country = "Niederlande"
- if country == "Sweden": country = "Schweden"
- if country == "Canada": country = "Kanada"
- if country == "Colombia": country = "Kolumbien"
- if country == "Spain": country = "Spanien"
- if country == "Argentina": country = "Argentinien"
- if country == "Italy": country = "Italien"
- if country == "Cuba": country = "Kuba"
- if country == "Denmark": country = "D nemark"
- if country == "Czech Republic": country = "Tscheschien"
- if country == "New Zealand": country = "Neuseeland"
- if country == "Russia": country = "Russland"
- if country == "Iceland": country = "Island"
- names = [n.text or "?" for n in doc.findall('actor/name')]
- genre = [g.text or "Genre ?" for g in doc.findall('genre')]
- items = [ title, country + ' ' + year + ' (R/V: ' + rating[:3] + '/ ' + votes + ')', runtime + ' min, ' + ', '.join(genre), plot, 'Regie: ' + director, 'Darsteller: ' + ', '.join(names)]
- basename = os.path.splitext(filename)[0]
- with io.open(basename + '.txt', 'w', encoding='utf-8') as fh:
- fh.write(u'\n\n'.join(items))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement