2014-02-05 20:37:50 +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
|
2014-06-07 20:43:40 +02:00
|
|
|
import copy
|
2014-02-05 20:37:50 +01:00
|
|
|
|
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2014-04-21 18:26:26 +02:00
|
|
|
from svtplay_dl.fetcher.rtmp import RTMP
|
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
2014-02-05 20:37:50 +01:00
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-02-05 20:37:50 +01:00
|
|
|
class Bambuser(Service, OpenGraphThumbMixin):
|
|
|
|
supported_domains = ["bambuser.com"]
|
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2014-02-05 20:37:50 +01:00
|
|
|
match = re.search(r"v/(\d+)", self.url)
|
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video id in url")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-12-22 17:41:40 +01:00
|
|
|
|
2016-05-14 22:54:30 +02:00
|
|
|
if self.exclude():
|
2015-09-06 23:04:48 +02:00
|
|
|
yield ServiceError("Excluding video")
|
2014-12-22 17:41:40 +01:00
|
|
|
return
|
|
|
|
|
2017-10-09 22:35:13 +02:00
|
|
|
json_url = "http://player-c.api.bambuser.com/getVideo.json?api_key=005f64509e19a868399060af746a00aa&vid={0}".format(match.group(1))
|
2015-11-15 11:18:40 +01:00
|
|
|
data = self.http.request("get", json_url).text
|
2014-11-25 23:20:14 +01:00
|
|
|
|
2014-02-05 20:37:50 +01:00
|
|
|
info = json.loads(data)["result"]
|
|
|
|
video = info["url"]
|
|
|
|
if video[:4] == "rtmp":
|
|
|
|
playpath = info["id"][len(info["id"])-36:]
|
2017-10-09 22:35:13 +02:00
|
|
|
self.options.other = "-y {0}".format(playpath)
|
2014-02-05 20:37:50 +01:00
|
|
|
if info["type"] == "live":
|
2015-12-26 11:46:14 +01:00
|
|
|
self.options.live = True
|
|
|
|
yield RTMP(copy.copy(self.options), video, "0")
|
2014-02-05 20:37:50 +01:00
|
|
|
else:
|
2015-12-26 11:46:14 +01:00
|
|
|
yield HTTP(copy.copy(self.options), video, "0")
|
2014-02-05 20:37:50 +01:00
|
|
|
|