mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-30 15:14:14 +01:00
fetcher.rtmp: RIP. Who use flash in 2018 anyway.
Removing old RTMP and related code. qbrick is not used anyway.
This commit is contained in:
parent
f910e66efb
commit
74f68a535b
@ -1,46 +0,0 @@
|
|||||||
# 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 subprocess
|
|
||||||
import shlex
|
|
||||||
|
|
||||||
from svtplay_dl.log import log
|
|
||||||
from svtplay_dl.fetcher import VideoRetriever
|
|
||||||
from svtplay_dl.utils.output import output, formatname
|
|
||||||
|
|
||||||
|
|
||||||
class RTMP(VideoRetriever):
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
return "rtmp"
|
|
||||||
|
|
||||||
def download(self):
|
|
||||||
""" Get the stream from RTMP """
|
|
||||||
self.output_extention = "flv"
|
|
||||||
args = []
|
|
||||||
if self.config.get("live"):
|
|
||||||
args.append("-v")
|
|
||||||
|
|
||||||
if self.config.get("resume"):
|
|
||||||
args.append("-e")
|
|
||||||
|
|
||||||
file_d = output(self.output, self.config, "flv", False)
|
|
||||||
if file_d is None:
|
|
||||||
return
|
|
||||||
args += ["-o", formatname(self.output, self.config, "flv")]
|
|
||||||
if self.config.get("silent"):
|
|
||||||
args.append("-q")
|
|
||||||
if self.kwargs.get("other"):
|
|
||||||
args += shlex.split(self.kwargs.pop("other"))
|
|
||||||
|
|
||||||
if self.config.get("verbose"):
|
|
||||||
args.append("-V")
|
|
||||||
|
|
||||||
command = ["rtmpdump", "-r", self.url] + args
|
|
||||||
log.debug("Running: {0}".format(" ".join(command)))
|
|
||||||
try:
|
|
||||||
subprocess.call(command)
|
|
||||||
except OSError as e:
|
|
||||||
log.error("Could not execute rtmpdump: {0}".format(e.strerror))
|
|
||||||
return
|
|
||||||
self.finished = True
|
|
@ -8,7 +8,6 @@ import copy
|
|||||||
from urllib.parse import urljoin, urlparse
|
from urllib.parse import urljoin, urlparse
|
||||||
|
|
||||||
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
||||||
from svtplay_dl.fetcher.rtmp import RTMP
|
|
||||||
from svtplay_dl.fetcher.hls import hlsparse
|
from svtplay_dl.fetcher.hls import hlsparse
|
||||||
from svtplay_dl.fetcher.hds import hdsparse
|
from svtplay_dl.fetcher.hds import hdsparse
|
||||||
from svtplay_dl.subtitle import subtitle
|
from svtplay_dl.subtitle import subtitle
|
||||||
@ -64,10 +63,6 @@ class Dr(Service, OpenGraphThumbMixin):
|
|||||||
streams = hlsparse(self.config, self.http.request("get", stream["Uri"]), stream["Uri"], output=self.output)
|
streams = hlsparse(self.config, self.http.request("get", stream["Uri"]), stream["Uri"], output=self.output)
|
||||||
for n in list(streams.keys()):
|
for n in list(streams.keys()):
|
||||||
yield streams[n]
|
yield streams[n]
|
||||||
if stream["Target"] == "Streaming":
|
|
||||||
self.config.set("other", "-v -y '{0}'".format(stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "")))
|
|
||||||
rtmp = "rtmp://vod.dr.dk/cms/"
|
|
||||||
yield RTMP(copy.copy(self.config), rtmp, stream['Bitrate'], output=self.output)
|
|
||||||
|
|
||||||
def find_all_episodes(self, config):
|
def find_all_episodes(self, config):
|
||||||
episodes = []
|
episodes = []
|
||||||
@ -126,8 +121,3 @@ class Dr(Service, OpenGraphThumbMixin):
|
|||||||
streams = hlsparse(config, self.http.request("get", i["Uri"]), i["Uri"], output=self.output)
|
streams = hlsparse(config, self.http.request("get", i["Uri"]), i["Uri"], output=self.output)
|
||||||
for n in list(streams.keys()):
|
for n in list(streams.keys()):
|
||||||
yield streams[n]
|
yield streams[n]
|
||||||
else:
|
|
||||||
if i["Target"] == "Streaming":
|
|
||||||
config.set("other", "-y '{0}'".format(i["Uri"].replace("rtmp://vod.dr.dk/cms/", "")))
|
|
||||||
rtmp = "rtmp://vod.dr.dk/cms/"
|
|
||||||
yield RTMP(copy.copy(config), rtmp, i["Bitrate"], output=self.output)
|
|
||||||
|
@ -7,7 +7,6 @@ from urllib.parse import urlparse
|
|||||||
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
||||||
from svtplay_dl.error import ServiceError
|
from svtplay_dl.error import ServiceError
|
||||||
from svtplay_dl.log import log
|
from svtplay_dl.log import log
|
||||||
from svtplay_dl.fetcher.rtmp import RTMP
|
|
||||||
from svtplay_dl.fetcher.hls import hlsparse
|
from svtplay_dl.fetcher.hls import hlsparse
|
||||||
|
|
||||||
|
|
||||||
@ -65,22 +64,9 @@ class Mtvnn(Service, OpenGraphThumbMixin):
|
|||||||
mrssxmlurl = match.group(1)
|
mrssxmlurl = match.group(1)
|
||||||
data = self.http.request("get", mrssxmlurl).content
|
data = self.http.request("get", mrssxmlurl).content
|
||||||
xml = ET.XML(data)
|
xml = ET.XML(data)
|
||||||
mediagen = xml.find("channel").find("item").find("{http://search.yahoo.com/mrss/}group")
|
|
||||||
title = xml.find("channel").find("item").find("title").text
|
title = xml.find("channel").find("item").find("title").text
|
||||||
self.output["title"] = title
|
self.output["title"] = title
|
||||||
|
|
||||||
swfurl = mediagen.find("{http://search.yahoo.com/mrss/}player").attrib["url"]
|
|
||||||
other = "-W {0}".format(self.http.check_redirect(swfurl))
|
|
||||||
|
|
||||||
contenturl = mediagen.find("{http://search.yahoo.com/mrss/}content").attrib["url"]
|
|
||||||
content = self.http.request("get", contenturl).content
|
|
||||||
xml = ET.XML(content)
|
|
||||||
ss = xml.find("video").find("item")
|
|
||||||
sa = list(ss.iter("rendition"))
|
|
||||||
|
|
||||||
for i in sa:
|
|
||||||
yield RTMP(self.config, i.find("src").text, i.attrib["bitrate"], other=other, output=self.output)
|
|
||||||
|
|
||||||
match = re.search("gon.viacom_config=([^;]+);", self.get_urldata())
|
match = re.search("gon.viacom_config=([^;]+);", self.get_urldata())
|
||||||
if match:
|
if match:
|
||||||
countrycode = json.loads(match.group(1))["country_code"].replace("_", "/")
|
countrycode = json.loads(match.group(1))["country_code"].replace("_", "/")
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
# 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 copy
|
|
||||||
import xml.etree.ElementTree as ET
|
|
||||||
|
|
||||||
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
|
||||||
from svtplay_dl.error import ServiceError
|
|
||||||
from svtplay_dl.fetcher.rtmp import RTMP
|
|
||||||
|
|
||||||
|
|
||||||
class Qbrick(Service, OpenGraphThumbMixin):
|
|
||||||
supported_domains = ['di.seXX']
|
|
||||||
|
|
||||||
def get(self):
|
|
||||||
data = self.get_urldata()
|
|
||||||
|
|
||||||
if re.findall(r"di.se", self.url):
|
|
||||||
match = re.search("src=\"(http://qstream.*)\"></iframe", data)
|
|
||||||
if not match:
|
|
||||||
yield ServiceError("Can't find video info for: {0}".format(self.url))
|
|
||||||
return
|
|
||||||
data = self.http.request("get", match.group(1)).content
|
|
||||||
match = re.search(r"data-qbrick-ccid=\"([0-9A-Z]+)\"", data)
|
|
||||||
if not match:
|
|
||||||
yield ServiceError("Can't find video file for: {0}".format(self.url))
|
|
||||||
return
|
|
||||||
host = "http://vms.api.qbrick.com/rest/v3/getplayer/{0}".format(match.group(1))
|
|
||||||
else:
|
|
||||||
yield ServiceError("Can't find any info for {0}".format(self.url))
|
|
||||||
return
|
|
||||||
|
|
||||||
data = self.http.request("get", host).content
|
|
||||||
xml = ET.XML(data)
|
|
||||||
try:
|
|
||||||
url = xml.find("media").find("item").find("playlist").find("stream").find("format").find("substream").text
|
|
||||||
except AttributeError:
|
|
||||||
yield ServiceError("Can't find video file")
|
|
||||||
return
|
|
||||||
live = xml.find("media").find("item").find("playlist").find("stream").attrib["isLive"]
|
|
||||||
if live == "true":
|
|
||||||
self.config.set("live", True)
|
|
||||||
data = self.http.request("get", url).content
|
|
||||||
xml = ET.XML(data)
|
|
||||||
server = xml.find("head").find("meta").attrib["base"]
|
|
||||||
streams = xml.find("body").find("switch")
|
|
||||||
sa = list(streams.iter("video"))
|
|
||||||
|
|
||||||
for i in sa:
|
|
||||||
yield RTMP(copy.copy(self.config), server, i.attrib["system-bitrate"], output=self.output,
|
|
||||||
other="-y '{0}'".format(i.attrib["src"]))
|
|
@ -21,7 +21,6 @@ from svtplay_dl.service.nrk import Nrk
|
|||||||
from svtplay_dl.service.oppetarkiv import OppetArkiv
|
from svtplay_dl.service.oppetarkiv import OppetArkiv
|
||||||
from svtplay_dl.service.picsearch import Picsearch
|
from svtplay_dl.service.picsearch import Picsearch
|
||||||
from svtplay_dl.service.pokemon import Pokemon
|
from svtplay_dl.service.pokemon import Pokemon
|
||||||
from svtplay_dl.service.qbrick import Qbrick
|
|
||||||
from svtplay_dl.service.radioplay import Radioplay
|
from svtplay_dl.service.radioplay import Radioplay
|
||||||
from svtplay_dl.service.riksdagen import Riksdagen
|
from svtplay_dl.service.riksdagen import Riksdagen
|
||||||
from svtplay_dl.service.ruv import Ruv
|
from svtplay_dl.service.ruv import Ruv
|
||||||
@ -62,7 +61,6 @@ sites = [
|
|||||||
Mtvnn,
|
Mtvnn,
|
||||||
NHL,
|
NHL,
|
||||||
Nrk,
|
Nrk,
|
||||||
Qbrick,
|
|
||||||
Picsearch,
|
Picsearch,
|
||||||
Pokemon,
|
Pokemon,
|
||||||
Ruv,
|
Ruv,
|
||||||
|
@ -32,19 +32,19 @@ class PrioStreamsTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_custom_order(self):
|
def test_custom_order(self):
|
||||||
return self._gen_proto_case(
|
return self._gen_proto_case(
|
||||||
['http', 'rtmp', 'hds', 'hls'],
|
['http', 'hds', 'hls'],
|
||||||
['rtmp', 'hds', 'hls', 'http'],
|
['hds', 'hls', 'http'],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_custom_order_1(self):
|
def test_custom_order_1(self):
|
||||||
return self._gen_proto_case(
|
return self._gen_proto_case(
|
||||||
['http'],
|
['http'],
|
||||||
['rtmp', 'hds', 'hls', 'http'],
|
['hds', 'hls', 'http'],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_proto_unavail(self):
|
def test_proto_unavail(self):
|
||||||
return self._gen_proto_case(
|
return self._gen_proto_case(
|
||||||
['http', 'rtmp'],
|
['http', 'hds'],
|
||||||
['hds', 'hls', 'https'],
|
['hls', 'https'],
|
||||||
expected=[],
|
expected=[],
|
||||||
)
|
)
|
||||||
|
@ -65,7 +65,7 @@ def parser(version):
|
|||||||
general.add_argument("-f", "--force", action="store_true", dest="force", default=False,
|
general.add_argument("-f", "--force", action="store_true", dest="force", default=False,
|
||||||
help="overwrite if file exists already")
|
help="overwrite if file exists already")
|
||||||
general.add_argument("-r", "--resume", action="store_true", dest="resume", default=False,
|
general.add_argument("-r", "--resume", action="store_true", dest="resume", default=False,
|
||||||
help="resume a download (RTMP based ones)")
|
help="resume a download (RTMP obsolete)")
|
||||||
general.add_argument("-l", "--live", action="store_true", dest="live", default=False,
|
general.add_argument("-l", "--live", action="store_true", dest="live", default=False,
|
||||||
help="enable for live streams (RTMP based ones)")
|
help="enable for live streams (RTMP based ones)")
|
||||||
general.add_argument("-c", "--capture_time", default=-1, type=int, metavar="capture_time",
|
general.add_argument("-c", "--capture_time", default=-1, type=int, metavar="capture_time",
|
||||||
@ -105,10 +105,10 @@ def parser(version):
|
|||||||
quality.add_argument("-Q", "--flexible-quality", default=0, metavar="amount", dest="flexibleq",
|
quality.add_argument("-Q", "--flexible-quality", default=0, metavar="amount", dest="flexibleq",
|
||||||
help="allow given quality (as above) to differ by an amount")
|
help="allow given quality (as above) to differ by an amount")
|
||||||
quality.add_argument("-P", "--preferred", default=None, metavar="preferred",
|
quality.add_argument("-P", "--preferred", default=None, metavar="preferred",
|
||||||
help="preferred download method (dash, hls, hds, http or rtmp)")
|
help="preferred download method (dash, hls, hds, or http)")
|
||||||
quality.add_argument("--list-quality", dest="list_quality", action="store_true", default=False,
|
quality.add_argument("--list-quality", dest="list_quality", action="store_true", default=False,
|
||||||
help="list the quality for a video")
|
help="list the quality for a video")
|
||||||
quality.add_argument("--stream-priority", dest="stream_prio", default=None, metavar="dash,hls,hds,http,rtmp",
|
quality.add_argument("--stream-priority", dest="stream_prio", default=None, metavar="dash,hls,hds,http",
|
||||||
help="If two streams have the same quality, choose the one you prefer")
|
help="If two streams have the same quality, choose the one you prefer")
|
||||||
|
|
||||||
subtitle = parser.add_argument_group("Subtitle")
|
subtitle = parser.add_argument_group("Subtitle")
|
||||||
|
@ -6,8 +6,8 @@ from svtplay_dl import error
|
|||||||
|
|
||||||
|
|
||||||
# TODO: should be set as the default option in the argument parsing?
|
# TODO: should be set as the default option in the argument parsing?
|
||||||
DEFAULT_PROTOCOL_PRIO = ["dash", "hls", "hds", "http", "rtmp"]
|
DEFAULT_PROTOCOL_PRIO = ["dash", "hls", "hds", "http"]
|
||||||
LIVE_PROTOCOL_PRIO = ["hls", "dash", "hds", "http", "rtmp"]
|
LIVE_PROTOCOL_PRIO = ["hls", "dash", "hds", "http"]
|
||||||
|
|
||||||
|
|
||||||
def sort_quality(data):
|
def sort_quality(data):
|
||||||
@ -68,7 +68,7 @@ def select_quality(config, streams):
|
|||||||
optf = (high - quality) / 2
|
optf = (high - quality) / 2
|
||||||
optq = quality + (high - quality) / 2
|
optq = quality + (high - quality) / 2
|
||||||
|
|
||||||
# Extract protocol prio, in the form of "hls,hds,http,rtmp",
|
# Extract protocol prio, in the form of "hls,hds,http",
|
||||||
# we want it as a list
|
# we want it as a list
|
||||||
|
|
||||||
if config.get("stream_prio"):
|
if config.get("stream_prio"):
|
||||||
|
Loading…
Reference in New Issue
Block a user