mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 07:56:57 -05:00
commit
2c9fd12d6a
@ -4,6 +4,24 @@
|
|||||||
|
|
||||||
<h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels</h4>
|
<h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels</h4>
|
||||||
|
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<button onclick="OpenLink('/api/channels?method=scan&redirect=%2Fchannels')">Force Channel Update</a></button><p> Note: This may take some time.</p>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<table class="center" style="width:50%">
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% for key in list(channels_dict.keys()) %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ key }}</td>
|
||||||
|
<td>{{ channels_dict[key] }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
<table class="center" style="width:100%">
|
<table class="center" style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Play</th>
|
<th>Play</th>
|
||||||
|
|||||||
@ -4,11 +4,6 @@
|
|||||||
|
|
||||||
<h4 style="text-align: center;">{{ fhdhr.config.dict["main"]["servicename"] }} Status</h4>
|
<h4 style="text-align: center;">{{ fhdhr.config.dict["main"]["servicename"] }} Status</h4>
|
||||||
|
|
||||||
<div style="text-align: center;">
|
|
||||||
<button onclick="OpenLink('/api/channels?method=scan&redirect=%2Forigin')">Force Channel Update</a></button>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<table class="center" style="width:50%">
|
<table class="center" style="width:50%">
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
<th>Channel</th>
|
<th>Channel</th>
|
||||||
<th>Method</th>
|
<th>Method</th>
|
||||||
<th>Time Active</th>
|
<th>Time Active</th>
|
||||||
|
<th>Total Downloaded</th>
|
||||||
<th>Options</th>
|
<th>Options</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -22,10 +23,12 @@
|
|||||||
<td>{{ tuner_dict["channel_number"] }}</td>
|
<td>{{ tuner_dict["channel_number"] }}</td>
|
||||||
<td>{{ tuner_dict["method"] }}</td>
|
<td>{{ tuner_dict["method"] }}</td>
|
||||||
<td>{{ tuner_dict["play_duration"] }}</td>
|
<td>{{ tuner_dict["play_duration"] }}</td>
|
||||||
|
<td>{{ tuner_dict["downloaded"] }}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>N/A</td>
|
<td>N/A</td>
|
||||||
<td>N/A</td>
|
<td>N/A</td>
|
||||||
<td>N/A</td>
|
<td>N/A</td>
|
||||||
|
<td>N/A</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from multiprocessing import Process
|
import multiprocessing
|
||||||
|
import threading
|
||||||
|
|
||||||
|
|
||||||
class Station_Scan():
|
class Station_Scan():
|
||||||
@ -10,16 +11,24 @@ class Station_Scan():
|
|||||||
|
|
||||||
self.fhdhr.db.delete_fhdhr_value("station_scan", "scanning")
|
self.fhdhr.db.delete_fhdhr_value("station_scan", "scanning")
|
||||||
|
|
||||||
def scan(self):
|
def scan(self, waitfordone=False):
|
||||||
self.fhdhr.logger.info("Channel Scan Requested by Client.")
|
self.fhdhr.logger.info("Channel Scan Requested by Client.")
|
||||||
|
|
||||||
scan_status = self.fhdhr.db.get_fhdhr_value("station_scan", "scanning")
|
scan_status = self.fhdhr.db.get_fhdhr_value("station_scan", "scanning")
|
||||||
if not scan_status:
|
if scan_status:
|
||||||
self.fhdhr.db.set_fhdhr_value("station_scan", "scanning", 1)
|
|
||||||
chanscan = Process(target=self.runscan)
|
|
||||||
chanscan.start()
|
|
||||||
else:
|
|
||||||
self.fhdhr.logger.info("Channel Scan Already In Progress!")
|
self.fhdhr.logger.info("Channel Scan Already In Progress!")
|
||||||
|
else:
|
||||||
|
self.fhdhr.db.set_fhdhr_value("station_scan", "scanning", 1)
|
||||||
|
|
||||||
|
if waitfordone:
|
||||||
|
self.runscan()
|
||||||
|
else:
|
||||||
|
if self.fhdhr.config.dict["main"]["thread_method"] in ["multiprocessing"]:
|
||||||
|
chanscan = multiprocessing.Process(target=self.runscan)
|
||||||
|
elif self.fhdhr.config.dict["main"]["thread_method"] in ["threading"]:
|
||||||
|
chanscan = threading.Thread(target=self.runscan)
|
||||||
|
if self.fhdhr.config.dict["main"]["thread_method"] in ["multiprocessing", "threading"]:
|
||||||
|
chanscan.start()
|
||||||
|
|
||||||
def runscan(self):
|
def runscan(self):
|
||||||
self.channels.get_channels(forceupdate=True)
|
self.channels.get_channels(forceupdate=True)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import m3u8
|
import m3u8
|
||||||
|
|
||||||
@ -48,6 +49,8 @@ class Direct_Stream():
|
|||||||
|
|
||||||
self.fhdhr.logger.info("Passing Through Chunk #%s with size %s" % (chunk_counter, self.chunksize))
|
self.fhdhr.logger.info("Passing Through Chunk #%s with size %s" % (chunk_counter, self.chunksize))
|
||||||
yield chunk
|
yield chunk
|
||||||
|
chunk_size = int(sys.getsizeof(chunk))
|
||||||
|
self.tuner.add_downloaded_size(chunk_size)
|
||||||
|
|
||||||
chunk_counter += 1
|
chunk_counter += 1
|
||||||
|
|
||||||
@ -123,6 +126,8 @@ class Direct_Stream():
|
|||||||
|
|
||||||
self.fhdhr.logger.info("Passing Through Chunk: %s" % chunkurl)
|
self.fhdhr.logger.info("Passing Through Chunk: %s" % chunkurl)
|
||||||
yield chunk
|
yield chunk
|
||||||
|
chunk_size = int(sys.getsizeof(chunk))
|
||||||
|
self.tuner.add_downloaded_size(chunk_size)
|
||||||
|
|
||||||
if playlist.target_duration:
|
if playlist.target_duration:
|
||||||
time.sleep(int(playlist.target_duration))
|
time.sleep(int(playlist.target_duration))
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# from fHDHR.exceptions import TunerError
|
# from fHDHR.exceptions import TunerError
|
||||||
@ -21,11 +22,13 @@ class FFMPEG_Stream():
|
|||||||
try:
|
try:
|
||||||
while self.tuner.tuner_lock.locked():
|
while self.tuner.tuner_lock.locked():
|
||||||
|
|
||||||
videoData = ffmpeg_proc.stdout.read(self.bytes_per_read)
|
chunk = ffmpeg_proc.stdout.read(self.bytes_per_read)
|
||||||
if not videoData:
|
if not chunk:
|
||||||
break
|
break
|
||||||
# raise TunerError("807 - No Video Data")
|
# raise TunerError("807 - No Video Data")
|
||||||
yield videoData
|
yield chunk
|
||||||
|
chunk_size = int(sys.getsizeof(chunk))
|
||||||
|
self.tuner.add_downloaded_size(chunk_size)
|
||||||
self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed")
|
self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed")
|
||||||
|
|
||||||
except GeneratorExit:
|
except GeneratorExit:
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# from fHDHR.exceptions import TunerError
|
# from fHDHR.exceptions import TunerError
|
||||||
@ -22,11 +23,13 @@ class VLC_Stream():
|
|||||||
|
|
||||||
while self.tuner.tuner_lock.locked():
|
while self.tuner.tuner_lock.locked():
|
||||||
|
|
||||||
videoData = vlc_proc.stdout.read(self.bytes_per_read)
|
chunk = vlc_proc.stdout.read(self.bytes_per_read)
|
||||||
if not videoData:
|
if not chunk:
|
||||||
break
|
break
|
||||||
# raise TunerError("807 - No Video Data")
|
# raise TunerError("807 - No Video Data")
|
||||||
yield videoData
|
yield chunk
|
||||||
|
chunk_size = int(sys.getsizeof(chunk))
|
||||||
|
self.tuner.add_downloaded_size(chunk_size)
|
||||||
self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed")
|
self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed")
|
||||||
|
|
||||||
except GeneratorExit:
|
except GeneratorExit:
|
||||||
|
|||||||
@ -17,6 +17,10 @@ class Tuner():
|
|||||||
self.tuner_lock = threading.Lock()
|
self.tuner_lock = threading.Lock()
|
||||||
self.set_off_status()
|
self.set_off_status()
|
||||||
|
|
||||||
|
def add_downloaded_size(self, bytes_count):
|
||||||
|
if "downloaded" in list(self.status.keys()):
|
||||||
|
self.status["downloaded"] += bytes_count
|
||||||
|
|
||||||
def grab(self):
|
def grab(self):
|
||||||
if self.tuner_lock.locked():
|
if self.tuner_lock.locked():
|
||||||
self.fhdhr.logger.error("Tuner #" + str(self.number) + " is not available.")
|
self.fhdhr.logger.error("Tuner #" + str(self.number) + " is not available.")
|
||||||
@ -56,4 +60,5 @@ class Tuner():
|
|||||||
"channel": stream_args["channel"],
|
"channel": stream_args["channel"],
|
||||||
"proxied_url": stream_args["channelUri"],
|
"proxied_url": stream_args["channelUri"],
|
||||||
"time_start": datetime.datetime.utcnow(),
|
"time_start": datetime.datetime.utcnow(),
|
||||||
|
"downloaded": 0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class Channels():
|
|||||||
self.fhdhr.device.channels.set_channel_status("id", channel_id, updatedict)
|
self.fhdhr.device.channels.set_channel_status("id", channel_id, updatedict)
|
||||||
|
|
||||||
elif method == "scan":
|
elif method == "scan":
|
||||||
self.fhdhr.device.station_scan.scan()
|
self.fhdhr.device.station_scan.scan(waitfordone=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return "Invalid Method"
|
return "Invalid Method"
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class Lineup_Post():
|
|||||||
if 'scan' in list(request.args.keys()):
|
if 'scan' in list(request.args.keys()):
|
||||||
|
|
||||||
if request.args['scan'] == 'start':
|
if request.args['scan'] == 'start':
|
||||||
self.fhdhr.device.station_scan.scan()
|
self.fhdhr.device.station_scan.scan(waitfordone=False)
|
||||||
return Response(status=200, mimetype='text/html')
|
return Response(status=200, mimetype='text/html')
|
||||||
|
|
||||||
elif request.args['scan'] == 'abort':
|
elif request.args['scan'] == 'abort':
|
||||||
|
|||||||
@ -13,11 +13,18 @@ class Channels_HTML():
|
|||||||
|
|
||||||
def get(self, *args):
|
def get(self, *args):
|
||||||
|
|
||||||
|
channels_dict = {
|
||||||
|
"Total Channels": len(list(self.fhdhr.device.channels.list.keys())),
|
||||||
|
"Enabled": 0,
|
||||||
|
}
|
||||||
|
|
||||||
channelslist = []
|
channelslist = []
|
||||||
for fhdhr_id in list(self.fhdhr.device.channels.list.keys()):
|
for fhdhr_id in list(self.fhdhr.device.channels.list.keys()):
|
||||||
channel_obj = self.fhdhr.device.channels.list[fhdhr_id]
|
channel_obj = self.fhdhr.device.channels.list[fhdhr_id]
|
||||||
channel_dict = channel_obj.dict.copy()
|
channel_dict = channel_obj.dict.copy()
|
||||||
channel_dict["play_url"] = channel_obj.play_url()
|
channel_dict["play_url"] = channel_obj.play_url()
|
||||||
channelslist.append(channel_dict)
|
channelslist.append(channel_dict)
|
||||||
|
if channel_dict["enabled"]:
|
||||||
|
channels_dict["Enabled"] += 1
|
||||||
|
|
||||||
return render_template('channels.html', request=request, fhdhr=self.fhdhr, channelslist=channelslist)
|
return render_template('channels.html', request=request, fhdhr=self.fhdhr, channelslist=channelslist, channels_dict=channels_dict, list=list)
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
from flask import request, render_template
|
from flask import request, render_template
|
||||||
|
|
||||||
|
from fHDHR.tools import humanized_filesize
|
||||||
|
|
||||||
|
|
||||||
class Streams_HTML():
|
class Streams_HTML():
|
||||||
endpoints = ["/streams", "/streams.html"]
|
endpoints = ["/streams", "/streams.html"]
|
||||||
@ -24,6 +26,7 @@ class Streams_HTML():
|
|||||||
tuner_dict["channel_number"] = tuner_status[tuner]["channel"]
|
tuner_dict["channel_number"] = tuner_status[tuner]["channel"]
|
||||||
tuner_dict["method"] = tuner_status[tuner]["method"]
|
tuner_dict["method"] = tuner_status[tuner]["method"]
|
||||||
tuner_dict["play_duration"] = str(tuner_status[tuner]["Play Time"])
|
tuner_dict["play_duration"] = str(tuner_status[tuner]["Play Time"])
|
||||||
|
tuner_dict["downloaded"] = humanized_filesize(tuner_status[tuner]["downloaded"])
|
||||||
|
|
||||||
tuner_list.append(tuner_dict)
|
tuner_list.append(tuner_dict)
|
||||||
|
|
||||||
|
|||||||
@ -89,6 +89,14 @@ def hours_between_datetime(first_time, later_time):
|
|||||||
return (timebetween.total_seconds() / 60 / 60)
|
return (timebetween.total_seconds() / 60 / 60)
|
||||||
|
|
||||||
|
|
||||||
|
def humanized_filesize(size, decimal_places=2):
|
||||||
|
for unit in ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']:
|
||||||
|
if size < 1024.0 or unit == 'YiB':
|
||||||
|
break
|
||||||
|
size /= 1024.0
|
||||||
|
return f"{size:.{decimal_places}f} {unit}"
|
||||||
|
|
||||||
|
|
||||||
def humanized_time(countdownseconds):
|
def humanized_time(countdownseconds):
|
||||||
time = float(countdownseconds)
|
time = float(countdownseconds)
|
||||||
if time == 0:
|
if time == 0:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user