1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-28 14:14:15 +01:00
svtplay-dl/lib/svtplay_dl/service/urplay.py

38 lines
1.7 KiB
Python
Raw Normal View History

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 -*-
from __future__ import absolute_import
import re
import json
from svtplay_dl.service import Service
2013-03-24 20:28:14 +01:00
from svtplay_dl.utils import get_http_data, subtitle_tt
from svtplay_dl.fetcher.rtmp import download_rtmp
from svtplay_dl.fetcher.hls import download_hls
class Urplay(Service):
def handle(self, url):
2013-03-03 10:59:52 +01:00
return ("urplay.se" in url) or ("ur.se" in url)
def get(self, options, url):
data = get_http_data(url)
data = re.search(r"urPlayer.init\((.*)\);", data)
data = re.sub(r"(\w+): ", r'"\1":', data.group(1))
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]
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"])
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:
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)