2013-03-10 14:18:39 +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 json
|
2013-11-14 22:56:32 +01:00
|
|
|
import re
|
2014-06-07 20:43:40 +02:00
|
|
|
import copy
|
2013-11-12 20:46:08 +01:00
|
|
|
|
2014-01-26 01:52:11 +01:00
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
2014-04-21 17:09:03 +02:00
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2013-03-10 14:18:39 +01:00
|
|
|
|
2018-03-19 20:51:38 +01:00
|
|
|
from svtplay_dl.fetcher.hls import hlsparse
|
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-01-26 01:52:11 +01:00
|
|
|
class Vimeo(Service, OpenGraphThumbMixin):
|
2014-01-01 14:57:17 +01:00
|
|
|
supported_domains = ['vimeo.com']
|
2013-03-10 14:18:39 +01:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2015-08-30 11:27:31 +02:00
|
|
|
data = self.get_urldata()
|
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
|
|
|
|
|
2018-03-19 19:19:37 +01:00
|
|
|
match_cfg_url = re.search('data-config-url="([^"]+)" data-fallback-url', data)
|
|
|
|
match_clip_page_cfg = re.search( r'vimeo\.clip_page_config\s*=\s*({.+?});', data)
|
|
|
|
|
|
|
|
if match_cfg_url:
|
|
|
|
player_url = match_cfg_url.group(1).replace("&", "&")
|
|
|
|
|
|
|
|
elif match_clip_page_cfg:
|
|
|
|
page_config = json.loads(match_clip_page_cfg.group(1))
|
|
|
|
player_url = page_config["player"]["config_url"]
|
|
|
|
|
|
|
|
else:
|
2017-10-09 22:35:13 +02:00
|
|
|
yield ServiceError("Can't find video file for: {0}".format(self.url))
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2018-03-19 19:19:37 +01:00
|
|
|
|
2015-09-07 19:02:43 +02:00
|
|
|
player_data = self.http.request("get", player_url).text
|
2013-03-10 14:18:39 +01:00
|
|
|
|
2013-11-12 20:46:08 +01:00
|
|
|
if player_data:
|
2018-03-19 20:51:38 +01:00
|
|
|
|
2013-11-12 20:46:08 +01:00
|
|
|
jsondata = json.loads(player_data)
|
2018-03-19 20:51:38 +01:00
|
|
|
|
|
|
|
if ("hls" in jsondata["request"]["files"]) and ("fastly_skyfire" in jsondata["request"]["files"]["hls"]["cdns"]):
|
|
|
|
hls_elem = jsondata["request"]["files"]["hls"]["cdns"]["fastly_skyfire"]
|
|
|
|
stream = hlsparse(self.options, self.http.request("get", hls_elem["url"]), hls_elem["url"])
|
|
|
|
|
|
|
|
if stream:
|
|
|
|
for n in list(stream.keys()):
|
|
|
|
yield stream[n]
|
|
|
|
|
2015-11-15 11:19:12 +01:00
|
|
|
avail_quality = jsondata["request"]["files"]["progressive"]
|
|
|
|
for i in avail_quality:
|
2015-12-26 11:46:14 +01:00
|
|
|
yield HTTP(copy.copy(self.options), i["url"], i["height"])
|
2018-03-19 20:51:38 +01:00
|
|
|
|
2013-03-10 14:18:39 +01:00
|
|
|
else:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find any streams.")
|
2015-04-28 23:19:35 +02:00
|
|
|
return
|