1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

Support for aftonbladet

This commit is contained in:
Johan Andersson 2011-09-20 21:05:19 +02:00
parent c5d6ae2c94
commit f646492d69

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python
import re
import urllib
import urllib2
import sys
import os
@ -65,6 +66,31 @@ class Common(object):
file_d.close()
class Aftonbladet(Common):
def __init__(self, output, quality, live):
self.output = output
self.quality = quality
self.live = live
def get(self, url, start):
data = self.getdata(url)
xml = ET.XML(data)
url = xml.find("articleElement").find("mediaElement").find("baseUrl").text
path = xml.find("articleElement").find("mediaElement").find("media").attrib["url"]
other = "-y %s" % path
if start > 0:
other = other + " -A %s" % str(start)
if not self.output:
self.output = os.path.basename(path)
print "Outfile: ", self.output
if url[0:4] == "rtmp":
self.getrtmp(url, self.output, self.live, other)
else:
filename = url + path
self.gethttp(filename, self.output)
class Viaplay(Common):
def __init__(self, output, quality, live):
self.output = output
@ -222,6 +248,20 @@ def main():
viaplay = Viaplay(output, quality, live)
viaplay.get(url)
elif re.findall("aftonbladet", url):
parse = urlparse.urlparse(url)
match = re.search(".*/article([0-9]+)\.ab", parse.path)
if not match:
print "Something wrong with that url"
sys.exit(2)
try:
start = urlparse.parse_qs(parse[4])["start"][0]
except KeyError:
start = 0
url = "http://www.aftonbladet.se/resource/webbtv/article/%s/player" % match.group(1)
aftonbladet = Aftonbladet(output, quality, live)
aftonbladet.get(url, start)
else:
svtplay = Svtplay(output, quality, live)
svtplay.get(url)