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-01-17 00:21:47 +01:00
|
|
|
import sys
|
|
|
|
import re
|
2014-02-05 23:15:19 +01:00
|
|
|
import json
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2013-04-21 12:44:31 +02:00
|
|
|
from svtplay_dl.service import Service
|
2013-03-17 19:55:19 +01:00
|
|
|
from svtplay_dl.utils import get_http_data
|
|
|
|
from svtplay_dl.log import log
|
2014-02-05 23:15:19 +01:00
|
|
|
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 Aftonbladet(Service):
|
2014-02-05 23:15:19 +01:00
|
|
|
supported_domains = ['tv.aftonbladet.se']
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2014-01-06 23:14:06 +01:00
|
|
|
def get(self, options):
|
2014-02-18 16:48:53 +01:00
|
|
|
data = self.get_urldata()
|
2014-02-08 17:31:02 +01:00
|
|
|
match = re.search('data-aptomaId="([-0-9a-z]+)"', data)
|
2013-01-17 00:21:47 +01:00
|
|
|
if not match:
|
2014-02-05 23:15:19 +01:00
|
|
|
log.error("Can't find video info")
|
2013-01-17 00:21:47 +01:00
|
|
|
sys.exit(2)
|
2014-02-05 23:15:19 +01:00
|
|
|
videoId = match.group(1)
|
2014-02-08 17:31:02 +01:00
|
|
|
match = re.search(r'data-isLive="(\w+)"', data)
|
2014-02-05 23:15:19 +01:00
|
|
|
if not match:
|
|
|
|
log.error("Can't find live info")
|
|
|
|
sys.exit(2)
|
|
|
|
if match.group(1) == "true":
|
2013-03-02 21:28:58 +01:00
|
|
|
options.live = True
|
2014-02-05 23:15:19 +01:00
|
|
|
if not options.live:
|
|
|
|
dataurl = "http://aftonbladet-play-metadata.cdn.drvideo.aptoma.no/video/%s.json" % videoId
|
|
|
|
data = get_http_data(dataurl)
|
|
|
|
data = json.loads(data)
|
|
|
|
videoId = data["videoId"]
|
|
|
|
|
|
|
|
streamsurl = "http://aftonbladet-play-static-ext.cdn.drvideo.aptoma.no/actions/video/?id=%s&formats&callback=" % videoId
|
|
|
|
streams = json.loads(get_http_data(streamsurl))
|
|
|
|
hls = streams["formats"]["hls"]["level3"]["m3u8"][0]
|
|
|
|
playlist = "http://%s/%s/%s" % (hls["address"], hls["path"], hls["filename"])
|
2014-02-08 16:08:39 +01:00
|
|
|
download_hls(options, playlist)
|