mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 08:26:57 -05:00
Add Downloaded Size Parameter to Tuner Status
This commit is contained in:
parent
cd88725dd9
commit
c61df94ae4
@ -11,6 +11,7 @@
|
||||
<th>Channel</th>
|
||||
<th>Method</th>
|
||||
<th>Time Active</th>
|
||||
<th>Total Downloaded</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
|
||||
@ -22,10 +23,12 @@
|
||||
<td>{{ tuner_dict["channel_number"] }}</td>
|
||||
<td>{{ tuner_dict["method"] }}</td>
|
||||
<td>{{ tuner_dict["play_duration"] }}</td>
|
||||
<td>{{ tuner_dict["downloaded"] }}</td>
|
||||
{% else %}
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<div>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import time
|
||||
import m3u8
|
||||
|
||||
@ -48,6 +49,8 @@ class Direct_Stream():
|
||||
|
||||
self.fhdhr.logger.info("Passing Through Chunk #%s with size %s" % (chunk_counter, self.chunksize))
|
||||
yield chunk
|
||||
chunk_size = int(sys.getsizeof(chunk))
|
||||
self.tuner.add_downloaded_size(chunk_size)
|
||||
|
||||
chunk_counter += 1
|
||||
|
||||
@ -123,6 +126,8 @@ class Direct_Stream():
|
||||
|
||||
self.fhdhr.logger.info("Passing Through Chunk: %s" % chunkurl)
|
||||
yield chunk
|
||||
chunk_size = int(sys.getsizeof(chunk))
|
||||
self.tuner.add_downloaded_size(chunk_size)
|
||||
|
||||
if playlist.target_duration:
|
||||
time.sleep(int(playlist.target_duration))
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
# from fHDHR.exceptions import TunerError
|
||||
@ -21,11 +22,13 @@ class FFMPEG_Stream():
|
||||
try:
|
||||
while self.tuner.tuner_lock.locked():
|
||||
|
||||
videoData = ffmpeg_proc.stdout.read(self.bytes_per_read)
|
||||
if not videoData:
|
||||
chunk = ffmpeg_proc.stdout.read(self.bytes_per_read)
|
||||
if not chunk:
|
||||
break
|
||||
# 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")
|
||||
|
||||
except GeneratorExit:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
# from fHDHR.exceptions import TunerError
|
||||
@ -22,11 +23,13 @@ class VLC_Stream():
|
||||
|
||||
while self.tuner.tuner_lock.locked():
|
||||
|
||||
videoData = vlc_proc.stdout.read(self.bytes_per_read)
|
||||
if not videoData:
|
||||
chunk = vlc_proc.stdout.read(self.bytes_per_read)
|
||||
if not chunk:
|
||||
break
|
||||
# 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")
|
||||
|
||||
except GeneratorExit:
|
||||
|
||||
@ -17,6 +17,10 @@ class Tuner():
|
||||
self.tuner_lock = threading.Lock()
|
||||
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):
|
||||
if self.tuner_lock.locked():
|
||||
self.fhdhr.logger.error("Tuner #" + str(self.number) + " is not available.")
|
||||
@ -56,4 +60,5 @@ class Tuner():
|
||||
"channel": stream_args["channel"],
|
||||
"proxied_url": stream_args["channelUri"],
|
||||
"time_start": datetime.datetime.utcnow(),
|
||||
"downloaded": 0
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
from flask import request, render_template
|
||||
|
||||
from fHDHR.tools import humanized_filesize
|
||||
|
||||
|
||||
class Streams_HTML():
|
||||
endpoints = ["/streams", "/streams.html"]
|
||||
@ -24,6 +26,7 @@ class Streams_HTML():
|
||||
tuner_dict["channel_number"] = tuner_status[tuner]["channel"]
|
||||
tuner_dict["method"] = tuner_status[tuner]["method"]
|
||||
tuner_dict["play_duration"] = str(tuner_status[tuner]["Play Time"])
|
||||
tuner_dict["downloaded"] = humanized_filesize(tuner_status[tuner]["downloaded"])
|
||||
|
||||
tuner_list.append(tuner_dict)
|
||||
|
||||
|
||||
@ -89,6 +89,14 @@ def hours_between_datetime(first_time, later_time):
|
||||
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):
|
||||
time = float(countdownseconds)
|
||||
if time == 0:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user