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

merge local branch with pyamf fix.

This commit is contained in:
Johan Andersson 2011-11-02 09:54:00 +01:00
commit 8ef02ef21f

View File

@ -70,6 +70,62 @@ class Common(object):
file_d.close()
class Kanal5(Common):
def __init__(self, output, quality, live, other):
self.output = output
self.quality = quality
self.live = live
self.other = other
def get(self, url):
try:
from pyamf import remoting
except ImportError:
print "You need to install pyamf to download content from kanal5 and kanal9"
print "In debian the package is called python-pyamf"
sys.exit(2)
player_id = 811317479001
publisher_id = 22710239001
const = "9f79dd85c3703b8674de883265d8c9e606360c2e"
env = remoting.Envelope(amfVersion=3)
env.bodies.append(("/1", remoting.Request(target="com.brightcove.player.runtime.PlayerMediaFacade.findMediaById", body=[const, player_id, self.other, publisher_id], envelope=env)))
env = str(remoting.encode(env).read())
url = "http://" + url + "/services/messagebroker/amf?playerKey=AQ~~,AAAABUmivxk~,SnCsFJuhbr0vfwrPJJSL03znlhz-e9bk"
header = "application/x-amf"
data = self.getdata(url, "POST", header, env)
streams = {}
for i in remoting.decode(data).bodies[0][1].body['renditions']:
stream = {}
stream["uri"] = i["defaultURL"]
streams[i["encodingRate"]] = stream
sort = []
for key in sorted(streams.iterkeys()):
sort.append(int(key))
sort = sorted(sort)
if not self.quality:
self.quality = sort.pop()
try:
test = streams[int(self.quality)]
except:
print "Err: cant find that quality. try: "
for i in sort:
print i
sys.exit(2)
if not self.output:
self.output = os.path.basename(streams[int(self.quality)]["uri"])
print "Outfile: ", self.output
filename = streams[int(self.quality)]["uri"]
match = re.search("(rtmp[e]{0,1}://.*)\&(.*)$", filename)
other = "-y %s -W %s" % (match.group(2), "http://admin.brightcove.com/viewer/us1.25.04.01.2011-05-24182704/connection/ExternalConnection_2.swf")
self.getrtmp(match.group(1), self.output, self.live, other)
class Expressen(Common):
def __init__(self, output, quality, live):
self.output = output