2013-03-02 21:26:28 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2013-03-01 23:39:42 +01:00
|
|
|
from __future__ import absolute_import
|
2013-02-12 19:43:37 +01:00
|
|
|
import re
|
2013-03-03 10:58:37 +01:00
|
|
|
import json
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2013-04-21 12:44:31 +02:00
|
|
|
from svtplay_dl.service import Service
|
2013-03-24 20:28:14 +01:00
|
|
|
from svtplay_dl.utils import get_http_data, subtitle_tt
|
2013-03-17 19:55:19 +01:00
|
|
|
from svtplay_dl.fetcher.rtmp import download_rtmp
|
|
|
|
from svtplay_dl.fetcher.hls import download_hls
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2013-04-21 12:44:31 +02:00
|
|
|
class Urplay(Service):
|
2013-01-17 00:21:47 +01:00
|
|
|
def handle(self, url):
|
2013-03-03 10:59:52 +01:00
|
|
|
return ("urplay.se" in url) or ("ur.se" in url)
|
2013-01-17 00:21:47 +01:00
|
|
|
|
|
|
|
def get(self, options, url):
|
|
|
|
data = get_http_data(url)
|
2013-03-03 10:58:37 +01:00
|
|
|
data = re.search("urPlayer.init\((.*)\);", data)
|
2013-03-24 20:27:35 +01:00
|
|
|
data = re.sub("(\w+): ", r'"\1":', data.group(1))
|
2013-03-03 10:58:37 +01:00
|
|
|
data = data.replace("\'", "\"").replace("\",}","\"}").replace("(m = location.hash.match(/[#&]start=(\d+)/)) ? m[1] : 0,","0")
|
|
|
|
jsondata = json.loads(data)
|
2013-03-10 13:51:10 +01:00
|
|
|
subtitle = jsondata["subtitles"].split(",")[0]
|
2013-03-03 10:58:37 +01:00
|
|
|
basedomain = jsondata["streaming_config"]["streamer"]["redirect"]
|
|
|
|
http = "http://%s/%s" % (basedomain, jsondata["file_html5"])
|
2013-04-21 12:33:35 +02:00
|
|
|
#hds = "%s%s" % (http, jsondata["streaming_config"]["http_streaming"]["hds_file"])
|
2013-03-03 10:58:37 +01:00
|
|
|
hls = "%s%s" % (http, jsondata["streaming_config"]["http_streaming"]["hls_file"])
|
|
|
|
rtmp = "rtmp://%s/%s" % (basedomain, jsondata["streaming_config"]["rtmp"]["application"])
|
|
|
|
path = "mp%s:%s" % (jsondata["file_flash"][-1], jsondata["file_flash"])
|
|
|
|
options.other = "-v -a %s -y %s" % (jsondata["streaming_config"]["rtmp"]["application"], path)
|
|
|
|
if options.hls:
|
|
|
|
download_hls(options, hls, http)
|
2013-03-10 13:35:08 +01:00
|
|
|
else:
|
2013-03-03 10:58:37 +01:00
|
|
|
download_rtmp(options, rtmp)
|
2013-03-10 13:51:10 +01:00
|
|
|
if options.subtitle:
|
|
|
|
if options.output != "-":
|
|
|
|
data = get_http_data(subtitle)
|
|
|
|
subtitle_tt(options, data)
|