simplify generate_placeholder

This commit is contained in:
jonathan 2021-06-22 18:04:09 +02:00
parent 7d139cce81
commit 6f38daec14

View File

@ -25,7 +25,6 @@ import socket
import time import time
from copy import deepcopy from copy import deepcopy
from datetime import timedelta from datetime import timedelta
from math import isclose
from pathlib import Path from pathlib import Path
from threading import Thread from threading import Thread
@ -34,7 +33,7 @@ import requests
from .filters.default import build_filtergraph from .filters.default import build_filtergraph
from .utils import (MediaProbe, check_sync, get_date, get_delta, get_float, from .utils import (MediaProbe, check_sync, get_date, get_delta, get_float,
get_time, messenger, playlist, src_or_dummy, stdin_args, get_time, messenger, playlist, src_or_dummy, stdin_args,
sync_op, valid_json) storage, sync_op, valid_json)
def handle_list_init(node): def handle_list_init(node):
@ -336,8 +335,6 @@ class GetSourceFromPlaylist:
delta += seek + 1 delta += seek + 1
next_start = begin - playlist.start + out + delta next_start = begin - playlist.start + out + delta
elif begin == playlist.start:
next_start = playlist.length + 1
else: else:
delta, _ = get_delta(begin) delta, _ = get_delta(begin)
next_start = begin - playlist.start + sync_op.threshold + delta next_start = begin - playlist.start + sync_op.threshold + delta
@ -374,32 +371,22 @@ class GetSourceFromPlaylist:
when playlist not exists, or is not long enough, when playlist not exists, or is not long enough,
generate a placeholder node generate a placeholder node
""" """
current_time = get_time('full_sec')
if playlist.start == 0: self.init_time()
current_time -= 86400 begin = self.last_time
# balance small difference to start time self.node = {
if playlist.start is not None and isclose(playlist.start, 'begin': begin,
current_time, abs_tol=1.5): 'number': 0,
self.node = None 'in': 0,
self.check_for_next_playlist(playlist.start) 'seek': 0,
else: 'out': duration,
self.init_time() 'duration': duration + 1,
begin = self.last_time 'source': storage.filler
}
self.node = { self.generate_cmd()
'begin': begin, self.check_for_next_playlist(begin)
'number': 0,
'in': 0,
'seek': 0,
'out': duration,
'duration': duration + 1,
'source': None
}
self.generate_cmd()
self.check_for_next_playlist(begin)
def eof_handling(self, begin): def eof_handling(self, begin):
""" """