diff options
author | enkore <public@enkore.de> | 2013-03-25 19:25:13 +0100 |
---|---|---|
committer | enkore <public@enkore.de> | 2013-03-25 19:25:13 +0100 |
commit | f4ce5647c93b450e9052390655cb4e7456b8e777 (patch) | |
tree | c5e6fdc07c09d61199db53da44bede5318d96363 /module/plugins/hoster/ZDF.py | |
parent | NetloadIn: Fixed bug #49 (diff) | |
download | pyload-f4ce5647c93b450e9052390655cb4e7456b8e777.tar.xz |
Add plugin for ZDF mediathek
Diffstat (limited to 'module/plugins/hoster/ZDF.py')
-rw-r--r-- | module/plugins/hoster/ZDF.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/module/plugins/hoster/ZDF.py b/module/plugins/hoster/ZDF.py new file mode 100644 index 000000000..f72bde1ed --- /dev/null +++ b/module/plugins/hoster/ZDF.py @@ -0,0 +1,46 @@ + +import re +from xml.etree.ElementTree import fromstring + +from module.plugins.Hoster import Hoster + +XML_API = "http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?id=%i" + +class ZDF(Hoster): + # Based on zdfm + # http://github.com/enkore/zdfm/ + __name__ = "ZDF Mediathek" + __version__ = "0.7" + __pattern__ = r"http://www\.zdf\.de/ZDFmediathek/[^0-9]*([0-9]+)[^0-9]*" + __config__ = [] + + @staticmethod + def video_key(video): + return ( + int(video.findtext("videoBitrate", "0")), + any(f.text == "progressive" for f in video.iter("facet")), + ) + + @staticmethod + def video_valid(video): + return (video.findtext("url").startswith("http") and video.findtext("url").endswith(".mp4")) + + @staticmethod + def get_id(url): + return int(re.search(r"[^0-9]*([0-9]+)[^0-9]*", url).group(1)) + + def process(self, pyfile): + xml = fromstring(self.load(XML_API % self.get_id(pyfile.url))) + + status = xml.findtext("./status/statuscode") + if status != "ok": + self.fail("Error retrieving manifest.") + + video = xml.find("video") + title = video.findtext("information/title") + + pyfile.name = title + + target_url = sorted((v for v in video.iter("formitaet") if self.video_valid(v)), key=self.video_key)[-1].findtext("url") + + self.download(target_url) |