1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-30 23:24:16 +01:00

Add support for service mtv.se

This commit is contained in:
dalgr 2018-01-27 00:03:42 +01:00 committed by Johan Andersson
parent 81c0eea37b
commit f6e46178a2
2 changed files with 47 additions and 0 deletions

View File

@ -34,6 +34,7 @@ from svtplay_dl.service.flowonline import Flowonline
from svtplay_dl.service.hbo import Hbo from svtplay_dl.service.hbo import Hbo
from svtplay_dl.service.twitch import Twitch from svtplay_dl.service.twitch import Twitch
from svtplay_dl.service.lemonwhale import Lemonwhale from svtplay_dl.service.lemonwhale import Lemonwhale
from svtplay_dl.service.mtvnn import MtvMusic
from svtplay_dl.service.mtvnn import Mtvnn from svtplay_dl.service.mtvnn import Mtvnn
from svtplay_dl.service.mtvservices import Mtvservices from svtplay_dl.service.mtvservices import Mtvservices
from svtplay_dl.service.nhl import NHL from svtplay_dl.service.nhl import NHL
@ -83,6 +84,7 @@ sites = [
Twitch, Twitch,
Lemonwhale, Lemonwhale,
Mtvservices, Mtvservices,
MtvMusic,
Mtvnn, Mtvnn,
NHL, NHL,
Nrk, Nrk,

View File

@ -10,6 +10,7 @@ from svtplay_dl.error import ServiceError
from svtplay_dl.log import log from svtplay_dl.log import log
from svtplay_dl.fetcher.rtmp import RTMP from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.hls import hlsparse from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.utils.urllib import urlparse
# This is _very_ similar to mtvservices.. # This is _very_ similar to mtvservices..
@ -92,3 +93,47 @@ class Mtvnn(Service, OpenGraphThumbMixin):
episodes.append("http://www.nickelodeon.se/serier/{0}-something/videos/{1}-something".format(programid, i)) episodes.append("http://www.nickelodeon.se/serier/{0}-something/videos/{1}-something".format(programid, i))
n += 1 n += 1
return episodes return episodes
class MtvMusic(Service, OpenGraphThumbMixin):
supported_domains = ['mtv.se']
def get(self):
data = self.get_urldata()
if self.exclude():
yield ServiceError("Excluding video")
return
match = re.search('window.pagePlaylist = (.*);', data)
if not match:
yield ServiceError("Can't find video info")
return
try:
janson = json.loads(match.group(1))
except:
yield ServiceError("Can't decode api request: {0}".format(match.group(1)))
return
parse = urlparse(self.url)
wanted_id = parse.path.split("/")[-1].split("-")[0]
for n in janson:
if wanted_id == str(n["id"]):
mrssxmlurl = "http://media-utils.mtvnservices.com/services/MediaGenerator/mgid:arc:video:mtv.se:{0}?acceptMethods=hls".format(n["video_token"])
hls_asset = self.http.request("get", mrssxmlurl)
xml = ET.XML(hls_asset.text)
if xml.find("./video") is not None and xml.find("./video").find("item") is not None and \
xml.find("./video").find("item").find("rendition") is not None and \
xml.find("./video").find("item").find("rendition").find("src") is not None:
hls_url = xml.find("./video").find("item").find("rendition").find("src").text
stream = hlsparse(self.options, self.http.request("get", hls_url), hls_url)
if stream:
for key in list(stream.keys()):
yield stream[key]