From 7b0ff9437ec604f1cc28120d80a4f52c2a4b58ad Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sun, 18 Jan 2015 18:03:38 +0100 Subject: [PATCH] service: support for HDS and HLS stream playlists. this fixes #201 --- lib/svtplay_dl/service/__init__.py | 5 +++++ lib/svtplay_dl/service/raw.py | 34 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 lib/svtplay_dl/service/raw.py diff --git a/lib/svtplay_dl/service/__init__.py b/lib/svtplay_dl/service/__init__.py index eebc2f9..84712bd 100644 --- a/lib/svtplay_dl/service/__init__.py +++ b/lib/svtplay_dl/service/__init__.py @@ -113,6 +113,7 @@ from svtplay_dl.service.picsearch import Picsearch from svtplay_dl.service.qbrick import Qbrick from svtplay_dl.service.radioplay import Radioplay from svtplay_dl.service.ruv import Ruv +from svtplay_dl.service.raw import Raw from svtplay_dl.service.sr import Sr from svtplay_dl.service.svtplay import Svtplay from svtplay_dl.service.tv4play import Tv4play @@ -204,6 +205,10 @@ class Generic(object): if i.handles(url): return url, i(url) + if url.find(".f4m") > 0: + return url, Raw(url) + if url.find(".m3u8") > 0: + return url, Raw(url) return url, stream def service_handler(url): diff --git a/lib/svtplay_dl/service/raw.py b/lib/svtplay_dl/service/raw.py new file mode 100644 index 0000000..1c40338 --- /dev/null +++ b/lib/svtplay_dl/service/raw.py @@ -0,0 +1,34 @@ +from __future__ import absolute_import +import copy +import os + +from svtplay_dl.service import Service +from svtplay_dl.fetcher.hds import hdsparse +from svtplay_dl.fetcher.hls import hlsparse, HLS +from svtplay_dl.log import log + +class Raw(Service): + def get(self, options): + error, data = self.get_urldata() + if error: + log.error("Can't get the page") + return + + if self.exclude(options): + return + + if self.url.find(".f4m") > 0: + if options.output is None: + filename = os.path.basename(self.url[:self.url.rfind("/")-1]) + options.output = "%s.flv" % filename + streams = hdsparse(copy.copy(options), self.url) + if streams: + for n in list(streams.keys()): + yield streams[n] + if self.url.find(".m3u8") > 0: + streams = hlsparse(self.url) + if options.output is None: + filename = os.path.basename(self.url[:self.url.rfind("/")-1]) + options.output = "%s.ts" % filename + for n in list(streams.keys()): + yield HLS(copy.copy(options), streams[n], n)