1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

Adding suport for vid.me

This commit is contained in:
dalgr 2017-09-26 23:05:57 +02:00 committed by Johan Andersson
parent 908b4ec313
commit 510e8424fc
2 changed files with 54 additions and 0 deletions

View File

@ -54,6 +54,7 @@ from svtplay_dl.service.urplay import Urplay
from svtplay_dl.service.vg import Vg from svtplay_dl.service.vg import Vg
from svtplay_dl.service.viaplay import Viaplay from svtplay_dl.service.viaplay import Viaplay
from svtplay_dl.service.viasatsport import Viasatsport from svtplay_dl.service.viasatsport import Viasatsport
from svtplay_dl.service.vidme import Vidme
from svtplay_dl.service.vimeo import Vimeo from svtplay_dl.service.vimeo import Vimeo
from svtplay_dl.service.youplay import Youplay from svtplay_dl.service.youplay import Youplay
@ -95,6 +96,7 @@ sites = [
Urplay, Urplay,
Viaplay, Viaplay,
Viasatsport, Viasatsport,
Vidme,
Vimeo, Vimeo,
Vg, Vg,
Youplay, Youplay,

View File

@ -0,0 +1,52 @@
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
from __future__ import absolute_import
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.fetcher.dash import dashparse
from svtplay_dl.error import ServiceError
class Vidme(Service, OpenGraphThumbMixin):
supported_domains = ['vid.me']
def get(self):
parse = urlparse(self.url)
if parse.netloc is not "vid.me":
print parse
yield ServiceError("Need the url with the video")
vid = parse.path[1:]
res = self.http.get("https://api.vid.me/videoByUrl/{0}".format(vid))
try:
janson = res.json()
except ValueError:
yield ServiceError("Can't decode api request: {0}".format(res.request.url))
return
videos = self._get_video(janson)
for i in videos:
yield i
def _get_video(self, janson):
if "video" in janson and "formats" in janson["video"]:
janson_v = janson["video"]
if len(janson_v["formats"]) == 0:
yield ServiceError("Media doesn't have any associated videos.")
return
print janson_v["formats"]
for i in janson_v["formats"]:
streams = None
if i["type"] == "hls":
streams = hlsparse(self.options, self.http.request("get", i["uri"]), i["uri"])
elif i["type"] == "dash":
streams = dashparse(self.options, self.http.request("get", i["uri"]), i["uri"])
if streams:
for n in list(streams.keys()):
yield streams[n]