mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 11:56:57 -05:00
Compare commits
No commits in common. "eaf26457f0c11843818c89dae5e81e881cb8eb76" and "9c72f30a99524e6695d61b5a4943ebfbe9fee17b" have entirely different histories.
eaf26457f0
...
9c72f30a99
@ -164,7 +164,7 @@ class Channel():
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def api_stream_url(self):
|
def api_stream_url(self):
|
||||||
return '/api/tuners?method=stream&stream_method=%s&channel=%s&origin=%s' % (self.fhdhr.origins.origins_dict[self.origin].stream_method, self.dict["id"], self.origin)
|
return '/api/tuners?method=%s&channel=%s&origin=%s' % (self.fhdhr.config.dict["streaming"]["method"], self.dict["id"], self.origin)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def api_m3u_url(self):
|
def api_m3u_url(self):
|
||||||
|
|||||||
@ -85,7 +85,7 @@ class Tuner():
|
|||||||
|
|
||||||
def get_stream(self, stream_args, tuner):
|
def get_stream(self, stream_args, tuner):
|
||||||
stream = Stream(self.fhdhr, stream_args, tuner)
|
stream = Stream(self.fhdhr, stream_args, tuner)
|
||||||
return stream
|
return stream.get()
|
||||||
|
|
||||||
def set_status(self, stream_args):
|
def set_status(self, stream_args):
|
||||||
if self.status["status"] != "Active":
|
if self.status["status"] != "Active":
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class Tuners():
|
|||||||
if origin and origin not in origin_methods:
|
if origin and origin not in origin_methods:
|
||||||
return "%s Invalid channels origin" % origin
|
return "%s Invalid channels origin" % origin
|
||||||
|
|
||||||
if method == "stream":
|
if method in list(self.fhdhr.config.dict["streaming"]["valid_methods"].keys()):
|
||||||
|
|
||||||
channel_number = request.args.get('channel', None, type=str)
|
channel_number = request.args.get('channel', None, type=str)
|
||||||
if not channel_number:
|
if not channel_number:
|
||||||
@ -73,13 +73,6 @@ class Tuners():
|
|||||||
origin = chan_obj.origin
|
origin = chan_obj.origin
|
||||||
channel_number = chan_obj.number
|
channel_number = chan_obj.number
|
||||||
|
|
||||||
stream_method = request.args.get('stream_method', default=self.fhdhr.origins.origins_dict[origin].stream_method, type=str)
|
|
||||||
if stream_method not in list(self.fhdhr.config.dict["streaming"]["valid_methods"].keys()):
|
|
||||||
response = Response("Service Unavailable", status=503)
|
|
||||||
response = Response("Service Unavailable", status=503)
|
|
||||||
response.headers["X-fHDHR-Error"] = str("806 - Tune Failed")
|
|
||||||
abort(response)
|
|
||||||
|
|
||||||
duration = request.args.get('duration', default=0, type=int)
|
duration = request.args.get('duration', default=0, type=int)
|
||||||
|
|
||||||
transcode_quality = request.args.get('transcode', default=None, type=str)
|
transcode_quality = request.args.get('transcode', default=None, type=str)
|
||||||
@ -93,7 +86,7 @@ class Tuners():
|
|||||||
stream_args = {
|
stream_args = {
|
||||||
"channel": channel_number,
|
"channel": channel_number,
|
||||||
"origin": origin,
|
"origin": origin,
|
||||||
"method": stream_method,
|
"method": method,
|
||||||
"duration": duration,
|
"duration": duration,
|
||||||
"origin_quality": self.fhdhr.config.dict["streaming"]["origin_quality"],
|
"origin_quality": self.fhdhr.config.dict["streaming"]["origin_quality"],
|
||||||
"transcode_quality": transcode_quality or self.fhdhr.config.dict["streaming"]["transcode_quality"],
|
"transcode_quality": transcode_quality or self.fhdhr.config.dict["streaming"]["transcode_quality"],
|
||||||
@ -132,15 +125,7 @@ class Tuners():
|
|||||||
tuner.set_status(stream_args)
|
tuner.set_status(stream_args)
|
||||||
session["tuner_used"] = tunernum
|
session["tuner_used"] = tunernum
|
||||||
|
|
||||||
try:
|
return Response(stream_with_context(tuner.get_stream(stream_args, tuner)), mimetype=stream_args["content_type"])
|
||||||
stream = tuner.get_stream(stream_args, tuner)
|
|
||||||
except TunerError as e:
|
|
||||||
response.headers["X-fHDHR-Error"] = str(e)
|
|
||||||
self.fhdhr.logger.error(response.headers["X-fHDHR-Error"])
|
|
||||||
tuner.close()
|
|
||||||
abort(response)
|
|
||||||
|
|
||||||
return Response(stream_with_context(stream.get()), mimetype=stream_args["content_type"])
|
|
||||||
|
|
||||||
elif method == "close":
|
elif method == "close":
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class Auto():
|
|||||||
|
|
||||||
origin = self.source
|
origin = self.source
|
||||||
|
|
||||||
redirect_url = "/api/tuners?method=stream"
|
redirect_url = "/api/tuners?method=%s" % (self.fhdhr.config.dict["streaming"]["method"])
|
||||||
|
|
||||||
if channel.startswith("v"):
|
if channel.startswith("v"):
|
||||||
channel_number = channel.replace('v', '')
|
channel_number = channel.replace('v', '')
|
||||||
@ -40,7 +40,6 @@ class Auto():
|
|||||||
|
|
||||||
redirect_url += "&channel=%s" % str(channel_number)
|
redirect_url += "&channel=%s" % str(channel_number)
|
||||||
redirect_url += "&origin=%s" % str(origin)
|
redirect_url += "&origin=%s" % str(origin)
|
||||||
redirect_url += "&stream_method=%s" % self.fhdhr.origins.origins_dict[origin].stream_method
|
|
||||||
|
|
||||||
duration = request.args.get('duration', default=0, type=int)
|
duration = request.args.get('duration', default=0, type=int)
|
||||||
if duration:
|
if duration:
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class Tuner():
|
|||||||
|
|
||||||
origin = self.source
|
origin = self.source
|
||||||
|
|
||||||
redirect_url = "/api/tuners?method=stream"
|
redirect_url = "/api/tuners?method=%s" % (self.fhdhr.config.dict["streaming"]["method"])
|
||||||
|
|
||||||
redirect_url += "&tuner=%s" % (tuner_number)
|
redirect_url += "&tuner=%s" % (tuner_number)
|
||||||
|
|
||||||
@ -42,7 +42,6 @@ class Tuner():
|
|||||||
|
|
||||||
redirect_url += "&channel=%s" % str(channel_number)
|
redirect_url += "&channel=%s" % str(channel_number)
|
||||||
redirect_url += "&origin=%s" % str(origin)
|
redirect_url += "&origin=%s" % str(origin)
|
||||||
redirect_url += "&stream_method=%s" % self.fhdhr.origins.origins_dict[origin].stream_method
|
|
||||||
|
|
||||||
duration = request.args.get('duration', default=0, type=int)
|
duration = request.args.get('duration', default=0, type=int)
|
||||||
if duration:
|
if duration:
|
||||||
|
|||||||
@ -23,9 +23,12 @@ class RMG_Devices_DeviceKey_Media():
|
|||||||
response.headers["X-fHDHR-Error"] = "801 - Unknown devicekey"
|
response.headers["X-fHDHR-Error"] = "801 - Unknown devicekey"
|
||||||
self.fhdhr.logger.error(response.headers["X-fHDHR-Error"])
|
self.fhdhr.logger.error(response.headers["X-fHDHR-Error"])
|
||||||
abort(response)
|
abort(response)
|
||||||
origin = devicekey.split(self.fhdhr.config.dict["main"]["uuid"])[-1]
|
|
||||||
|
|
||||||
redirect_url = "/api/tuners?method=stream"
|
method = self.fhdhr.config.dict["streaming"]["method"]
|
||||||
|
redirect_url = "/api/tuners?method=%s" % (method)
|
||||||
|
|
||||||
|
origin = devicekey.split(self.fhdhr.config.dict["main"]["uuid"])[-1]
|
||||||
|
redirect_url += "&origin=%s" % (origin)
|
||||||
|
|
||||||
if str(channel).startswith('id://'):
|
if str(channel).startswith('id://'):
|
||||||
channel = str(channel).replace('id://', '')
|
channel = str(channel).replace('id://', '')
|
||||||
@ -33,10 +36,7 @@ class RMG_Devices_DeviceKey_Media():
|
|||||||
channel_tuple = channel.replace('triplet://', '').split(":")
|
channel_tuple = channel.replace('triplet://', '').split(":")
|
||||||
self.fhdhr.logger.error("Not Implemented %s" % ":".join(channel_tuple))
|
self.fhdhr.logger.error("Not Implemented %s" % ":".join(channel_tuple))
|
||||||
abort(501, "Not Implemented %s" % ":".join(channel_tuple))
|
abort(501, "Not Implemented %s" % ":".join(channel_tuple))
|
||||||
|
|
||||||
redirect_url += "&channel=%s" % (channel)
|
redirect_url += "&channel=%s" % (channel)
|
||||||
redirect_url += "&origin=%s" % (origin)
|
|
||||||
redirect_url += "&stream_method=%s" % self.fhdhr.origins.origins_dict[origin].stream_method
|
|
||||||
|
|
||||||
redirect_url += "&accessed=%s" % urllib.parse.quote(request.url)
|
redirect_url += "&accessed=%s" % urllib.parse.quote(request.url)
|
||||||
|
|
||||||
|
|||||||
@ -1,59 +1,23 @@
|
|||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from fHDHR.exceptions import TunerError
|
|
||||||
|
|
||||||
|
|
||||||
def setup(plugin):
|
def setup(plugin):
|
||||||
|
try:
|
||||||
|
ffmpeg_command = [plugin.config.dict["ffmpeg"]["path"],
|
||||||
|
"-version",
|
||||||
|
"pipe:stdout"
|
||||||
|
]
|
||||||
|
|
||||||
# Check config for ffmpeg path
|
ffmpeg_proc = subprocess.Popen(ffmpeg_command, stdout=subprocess.PIPE)
|
||||||
ffmpeg_path = None
|
ffmpeg_version = ffmpeg_proc.stdout.read()
|
||||||
if plugin.config.dict["ffmpeg"]["path"]:
|
|
||||||
# verify path is valid
|
|
||||||
if os.path.isfile(plugin.config.dict["ffmpeg"]["path"]):
|
|
||||||
ffmpeg_path = plugin.config.dict["ffmpeg"]["path"]
|
|
||||||
else:
|
|
||||||
plugin.logger.warning("Failed to find ffmpeg at %s." % plugin.config.dict["ffmpeg"]["path"])
|
|
||||||
|
|
||||||
if not ffmpeg_path:
|
|
||||||
plugin.logger.info("Attempting to find ffmpeg in PATH.")
|
|
||||||
if plugin.config.internal["versions"]["Operating System"]["version"] in ["Linux", "Darwin"]:
|
|
||||||
find_ffmpeg_command = ["which", "ffmpeg"]
|
|
||||||
elif plugin.config.internal["versions"]["Operating System"]["version"] in ["Windows"]:
|
|
||||||
find_ffmpeg_command = ["where", "ffmpeg"]
|
|
||||||
|
|
||||||
ffmpeg_proc = subprocess.Popen(find_ffmpeg_command, stdout=subprocess.PIPE)
|
|
||||||
ffmpeg_path = ffmpeg_proc.stdout.read().decode().strip("\n")
|
|
||||||
ffmpeg_proc.terminate()
|
ffmpeg_proc.terminate()
|
||||||
ffmpeg_proc.communicate()
|
ffmpeg_proc.communicate()
|
||||||
ffmpeg_proc.kill()
|
ffmpeg_proc.kill()
|
||||||
if not ffmpeg_path:
|
ffmpeg_version = ffmpeg_version.decode().split("version ")[1].split(" ")[0]
|
||||||
ffmpeg_path = None
|
except FileNotFoundError:
|
||||||
elif ffmpeg_path.isspace():
|
|
||||||
ffmpeg_path = None
|
|
||||||
|
|
||||||
if ffmpeg_path:
|
|
||||||
plugin.config.dict["ffmpeg"]["path"] = ffmpeg_path
|
|
||||||
|
|
||||||
if ffmpeg_path:
|
|
||||||
ffmpeg_command = [ffmpeg_path, "-version", "pipe:stdout"]
|
|
||||||
try:
|
|
||||||
ffmpeg_proc = subprocess.Popen(ffmpeg_command, stdout=subprocess.PIPE)
|
|
||||||
ffmpeg_version = ffmpeg_proc.stdout.read().decode().split("version ")[1].split(" ")[0]
|
|
||||||
except FileNotFoundError:
|
|
||||||
ffmpeg_version = None
|
|
||||||
except PermissionError:
|
|
||||||
ffmpeg_version = None
|
|
||||||
finally:
|
|
||||||
ffmpeg_proc.terminate()
|
|
||||||
ffmpeg_proc.communicate()
|
|
||||||
ffmpeg_proc.kill()
|
|
||||||
|
|
||||||
if not ffmpeg_version:
|
|
||||||
ffmpeg_version = "Missing"
|
ffmpeg_version = "Missing"
|
||||||
plugin.logger.warning("Failed to find ffmpeg.")
|
plugin.logger.warning("Failed to find ffmpeg.")
|
||||||
|
|
||||||
plugin.config.register_version("ffmpeg", ffmpeg_version, "env")
|
plugin.config.register_version("ffmpeg", ffmpeg_version, "env")
|
||||||
|
|
||||||
|
|
||||||
@ -65,9 +29,6 @@ class Plugin_OBJ():
|
|||||||
self.stream_args = stream_args
|
self.stream_args = stream_args
|
||||||
self.tuner = tuner
|
self.tuner = tuner
|
||||||
|
|
||||||
if self.plugin_utils.config.internal["versions"]["ffmpeg"]["version"] == "Missing":
|
|
||||||
raise TunerError("806 - Tune Failed: FFMPEG Missing")
|
|
||||||
|
|
||||||
self.bytes_per_read = int(plugin_utils.config.dict["streaming"]["bytes_per_read"])
|
self.bytes_per_read = int(plugin_utils.config.dict["streaming"]["bytes_per_read"])
|
||||||
self.ffmpeg_command = self.ffmpeg_command_assemble(stream_args)
|
self.ffmpeg_command = self.ffmpeg_command_assemble(stream_args)
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ffmpeg":{
|
"ffmpeg":{
|
||||||
"path":{
|
"path":{
|
||||||
"value": "none",
|
"value": "ffmpeg",
|
||||||
"config_file": true,
|
"config_file": true,
|
||||||
"config_web": true
|
"config_web": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,59 +1,23 @@
|
|||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from fHDHR.exceptions import TunerError
|
|
||||||
|
|
||||||
|
|
||||||
def setup(plugin):
|
def setup(plugin):
|
||||||
|
try:
|
||||||
|
vlc_command = [plugin.config.dict["vlc"]["path"],
|
||||||
|
"--version",
|
||||||
|
"pipe:stdout"
|
||||||
|
]
|
||||||
|
|
||||||
# Check config for vlc path
|
vlc_proc = subprocess.Popen(vlc_command, stdout=subprocess.PIPE)
|
||||||
vlc_path = None
|
vlc_version = vlc_proc.stdout.read()
|
||||||
if plugin.config.dict["vlc"]["path"]:
|
|
||||||
# verify path is valid
|
|
||||||
if os.path.isfile(plugin.config.dict["vlc"]["path"]):
|
|
||||||
vlc_path = plugin.config.dict["vlc"]["path"]
|
|
||||||
else:
|
|
||||||
plugin.logger.warning("Failed to find vlc at %s." % plugin.config.dict["vlc"]["path"])
|
|
||||||
|
|
||||||
if not vlc_path:
|
|
||||||
plugin.logger.info("Attempting to find vlc in PATH.")
|
|
||||||
if plugin.config.internal["versions"]["Operating System"]["version"] in ["Linux", "Darwin"]:
|
|
||||||
find_vlc_command = ["which", "vlc"]
|
|
||||||
elif plugin.config.internal["versions"]["Operating System"]["version"] in ["Windows"]:
|
|
||||||
find_vlc_command = ["where", "vlc"]
|
|
||||||
|
|
||||||
vlc_proc = subprocess.Popen(find_vlc_command, stdout=subprocess.PIPE)
|
|
||||||
vlc_path = vlc_proc.stdout.read().decode().strip("\n")
|
|
||||||
vlc_proc.terminate()
|
vlc_proc.terminate()
|
||||||
vlc_proc.communicate()
|
vlc_proc.communicate()
|
||||||
vlc_proc.kill()
|
vlc_proc.kill()
|
||||||
if not vlc_path:
|
vlc_version = vlc_version.decode().split("version ")[1].split('\n')[0]
|
||||||
vlc_path = None
|
except FileNotFoundError:
|
||||||
elif vlc_path.isspace():
|
|
||||||
vlc_path = None
|
|
||||||
|
|
||||||
if vlc_path:
|
|
||||||
plugin.config.dict["vlc"]["path"] = vlc_path
|
|
||||||
|
|
||||||
if vlc_path:
|
|
||||||
vlc_command = [vlc_path, "--version", "pipe:stdout"]
|
|
||||||
try:
|
|
||||||
vlc_proc = subprocess.Popen(vlc_command, stdout=subprocess.PIPE)
|
|
||||||
vlc_version = vlc_proc.stdout.read().decode().split("version ")[1].split('\n')[0]
|
|
||||||
except FileNotFoundError:
|
|
||||||
vlc_version = None
|
|
||||||
except PermissionError:
|
|
||||||
vlc_version = None
|
|
||||||
finally:
|
|
||||||
vlc_proc.terminate()
|
|
||||||
vlc_proc.communicate()
|
|
||||||
vlc_proc.kill()
|
|
||||||
|
|
||||||
if not vlc_version:
|
|
||||||
vlc_version = "Missing"
|
vlc_version = "Missing"
|
||||||
plugin.logger.warning("Failed to find vlc.")
|
plugin.logger.warning("Failed to find vlc.")
|
||||||
|
|
||||||
plugin.config.register_version("vlc", vlc_version, "env")
|
plugin.config.register_version("vlc", vlc_version, "env")
|
||||||
|
|
||||||
|
|
||||||
@ -65,9 +29,6 @@ class Plugin_OBJ():
|
|||||||
self.stream_args = stream_args
|
self.stream_args = stream_args
|
||||||
self.tuner = tuner
|
self.tuner = tuner
|
||||||
|
|
||||||
if self.plugin_utils.config.internal["versions"]["vlc"]["version"] == "Missing":
|
|
||||||
raise TunerError("806 - Tune Failed: VLC Missing")
|
|
||||||
|
|
||||||
self.bytes_per_read = int(self.plugin_utils.config.dict["streaming"]["bytes_per_read"])
|
self.bytes_per_read = int(self.plugin_utils.config.dict["streaming"]["bytes_per_read"])
|
||||||
self.vlc_command = self.vlc_command_assemble(stream_args)
|
self.vlc_command = self.vlc_command_assemble(stream_args)
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"vlc":{
|
"vlc":{
|
||||||
"path":{
|
"path":{
|
||||||
"value": "none",
|
"value": "cvlc",
|
||||||
"config_file": true,
|
"config_file": true,
|
||||||
"config_web": true
|
"config_web": true
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user