mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 15:06:59 -05:00
commit
10db19aa6f
@ -65,8 +65,11 @@ class HDHR_Hub():
|
|||||||
def get_image(self, request_args):
|
def get_image(self, request_args):
|
||||||
return self.images.get_image(request_args)
|
return self.images.get_image(request_args)
|
||||||
|
|
||||||
def get_stream(self, request_args):
|
def get_stream_info(self, request_args):
|
||||||
return self.watch.get_stream(request_args)
|
return self.watch.get_stream_info(request_args)
|
||||||
|
|
||||||
|
def get_stream(self, channel_id, method, channelUri, content_type):
|
||||||
|
return self.watch.get_stream(channel_id, method, channelUri, content_type)
|
||||||
|
|
||||||
|
|
||||||
hdhr = HDHR_Hub()
|
hdhr = HDHR_Hub()
|
||||||
@ -148,8 +151,14 @@ class HDHR_HTTP_Server():
|
|||||||
@app.route('/watch', methods=['GET'])
|
@app.route('/watch', methods=['GET'])
|
||||||
def watch():
|
def watch():
|
||||||
if 'method' in list(request.args.keys()) and 'channel' in list(request.args.keys()):
|
if 'method' in list(request.args.keys()) and 'channel' in list(request.args.keys()):
|
||||||
return Response(stream_with_context(hdhr.get_stream(request.args)))
|
channel_id = str(request.args["channel"])
|
||||||
else:
|
method = str(request.args["method"])
|
||||||
|
method, channelUri, content_type = hdhr.get_stream_info(request.args)
|
||||||
|
if channelUri:
|
||||||
|
if method == "direct":
|
||||||
|
return Response(hdhr.get_stream(channel_id, method, channelUri, content_type), content_type=content_type, direct_passthrough=True)
|
||||||
|
elif method == "ffmpeg":
|
||||||
|
return Response(stream_with_context(hdhr.get_stream(channel_id, method, channelUri, content_type)), mimetype="video/mpeg")
|
||||||
abort(503)
|
abort(503)
|
||||||
|
|
||||||
@app.route('/lineup.post', methods=['POST'])
|
@app.route('/lineup.post', methods=['POST'])
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class WatchStream():
|
|||||||
self.tuners = tuners
|
self.tuners = tuners
|
||||||
self.web = fHDHR.tools.WebReq()
|
self.web = fHDHR.tools.WebReq()
|
||||||
|
|
||||||
def direct_stream(self, channelUri):
|
def direct_stream(self, channel_id, method, channelUri, content_type):
|
||||||
chunksize = int(self.tuners.config.dict["direct_stream"]['chunksize'])
|
chunksize = int(self.tuners.config.dict["direct_stream"]['chunksize'])
|
||||||
|
|
||||||
req = self.web.session.get(channelUri, stream=True)
|
req = self.web.session.get(channelUri, stream=True)
|
||||||
@ -28,7 +28,7 @@ class WatchStream():
|
|||||||
|
|
||||||
return generate()
|
return generate()
|
||||||
|
|
||||||
def ffmpeg_stream(self, channelUri):
|
def ffmpeg_stream(self, channel_id, method, channelUri, content_type):
|
||||||
bytes_per_read = int(self.config.dict["ffmpeg"]["bytes_per_read"])
|
bytes_per_read = int(self.config.dict["ffmpeg"]["bytes_per_read"])
|
||||||
|
|
||||||
ffmpeg_command = [self.config.dict["ffmpeg"]["ffmpeg_path"],
|
ffmpeg_command = [self.config.dict["ffmpeg"]["ffmpeg_path"],
|
||||||
@ -61,10 +61,7 @@ class WatchStream():
|
|||||||
self.tuners.tuner_close()
|
self.tuners.tuner_close()
|
||||||
return generate()
|
return generate()
|
||||||
|
|
||||||
def get_stream(self, request_args):
|
def get_stream(self, channel_id, method, channelUri, content_type):
|
||||||
|
|
||||||
method = str(request_args["method"])
|
|
||||||
channel_id = str(request_args["channel"])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.tuners.tuner_grab()
|
self.tuners.tuner_grab()
|
||||||
@ -75,10 +72,21 @@ class WatchStream():
|
|||||||
|
|
||||||
print("Attempting a " + method + " stream request for channel " + str(channel_id))
|
print("Attempting a " + method + " stream request for channel " + str(channel_id))
|
||||||
|
|
||||||
channelUri = self.origserv.get_channel_stream(channel_id)
|
|
||||||
# print("Proxy URL determined as " + str(channelUri))
|
|
||||||
|
|
||||||
if method == "ffmpeg":
|
if method == "ffmpeg":
|
||||||
return self.ffmpeg_stream(channelUri)
|
return self.ffmpeg_stream(channel_id, method, channelUri, content_type)
|
||||||
elif method == "direct":
|
elif method == "direct":
|
||||||
return self.direct_stream(channelUri)
|
return self.direct_stream(channel_id, method, channelUri, content_type)
|
||||||
|
|
||||||
|
def get_stream_info(self, request_args):
|
||||||
|
|
||||||
|
method = str(request_args["method"])
|
||||||
|
channel_id = str(request_args["channel"])
|
||||||
|
|
||||||
|
channelUri = self.origserv.get_channel_stream(channel_id)
|
||||||
|
if not channelUri:
|
||||||
|
return None, None, None
|
||||||
|
|
||||||
|
channelUri_headers = self.web.session.head(channelUri).headers
|
||||||
|
content_type = channelUri_headers['Content-Type']
|
||||||
|
|
||||||
|
return method, channelUri, content_type
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user