fix delta check when start time is 00:00:00, cleanup
This commit is contained in:
parent
04a7439a07
commit
19d1d34e00
@ -667,10 +667,6 @@ def get_date(seek_day):
|
|||||||
if seek_day and get_time('full_sec') < _playlist.start:
|
if seek_day and get_time('full_sec') < _playlist.start:
|
||||||
return (d - timedelta(1)).strftime('%Y-%m-%d')
|
return (d - timedelta(1)).strftime('%Y-%m-%d')
|
||||||
else:
|
else:
|
||||||
if _playlist.start == 0 and \
|
|
||||||
4 > 86400.0 - get_time('full_sec') > 0:
|
|
||||||
return (d + timedelta(1)).strftime('%Y-%m-%d')
|
|
||||||
|
|
||||||
return d.strftime('%Y-%m-%d')
|
return d.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
|
||||||
@ -697,7 +693,7 @@ def valid_json(file):
|
|||||||
json_object = json.load(file)
|
json_object = json.load(file)
|
||||||
return json_object
|
return json_object
|
||||||
except ValueError:
|
except ValueError:
|
||||||
messenger.error(f'Playlist {file} is not JSON conform')
|
messenger.error(f'Playlist {file.name} is not JSON conform')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -893,12 +889,17 @@ def get_delta(begin):
|
|||||||
"""
|
"""
|
||||||
current_time = get_time('full_sec')
|
current_time = get_time('full_sec')
|
||||||
|
|
||||||
if _playlist.length:
|
if stdin_args.length:
|
||||||
|
target_playtime = stdin_args.length
|
||||||
|
elif _playlist.length:
|
||||||
target_playtime = _playlist.length
|
target_playtime = _playlist.length
|
||||||
else:
|
else:
|
||||||
target_playtime = 86400.0
|
target_playtime = 86400.0
|
||||||
|
|
||||||
if _playlist.start >= current_time and not begin == _playlist.start:
|
if begin == _playlist.start == 0:
|
||||||
|
current_time -= target_playtime
|
||||||
|
|
||||||
|
elif _playlist.start >= current_time and not begin == _playlist.start:
|
||||||
current_time += target_playtime
|
current_time += target_playtime
|
||||||
|
|
||||||
current_delta = begin - current_time
|
current_delta = begin - current_time
|
||||||
@ -977,11 +978,8 @@ def handle_list_end(probe, new_length, src, begin, dur, seek, out):
|
|||||||
return src_cmd, seek, new_out, new_playlist
|
return src_cmd, seek, new_out, new_playlist
|
||||||
|
|
||||||
|
|
||||||
def read_playlist(list_date, modification_time, clip_nodes):
|
def read_playlist(list_date, modification_time=0.0):
|
||||||
"""
|
nodes = None
|
||||||
read playlists from remote url or local file
|
|
||||||
and give his nodes and modification time back
|
|
||||||
"""
|
|
||||||
|
|
||||||
if stdin_args.playlist:
|
if stdin_args.playlist:
|
||||||
json_file = stdin_args.playlist
|
json_file = stdin_args.playlist
|
||||||
@ -1001,10 +999,10 @@ def read_playlist(list_date, modification_time, clip_nodes):
|
|||||||
|
|
||||||
if mod_time > modification_time:
|
if mod_time > modification_time:
|
||||||
if isinstance(result.json(), dict):
|
if isinstance(result.json(), dict):
|
||||||
clip_nodes = result.json()
|
nodes = result.json()
|
||||||
modification_time = mod_time
|
modification_time = mod_time
|
||||||
messenger.info('Open: ' + json_file)
|
messenger.info('Open: ' + json_file)
|
||||||
validate_thread(clip_nodes)
|
validate_thread(nodes)
|
||||||
except (requests.exceptions.ConnectionError, socket.timeout):
|
except (requests.exceptions.ConnectionError, socket.timeout):
|
||||||
messenger.error(f'No valid playlist from url: {json_file}')
|
messenger.error(f'No valid playlist from url: {json_file}')
|
||||||
|
|
||||||
@ -1013,13 +1011,13 @@ def read_playlist(list_date, modification_time, clip_nodes):
|
|||||||
mod_time = os.path.getmtime(json_file)
|
mod_time = os.path.getmtime(json_file)
|
||||||
if mod_time > modification_time:
|
if mod_time > modification_time:
|
||||||
with open(json_file, 'r', encoding='utf-8') as f:
|
with open(json_file, 'r', encoding='utf-8') as f:
|
||||||
clip_nodes = valid_json(f)
|
nodes = valid_json(f)
|
||||||
|
|
||||||
modification_time = mod_time
|
modification_time = mod_time
|
||||||
messenger.info('Open: ' + json_file)
|
messenger.info('Open: ' + json_file)
|
||||||
validate_thread(clip_nodes)
|
validate_thread(nodes)
|
||||||
|
|
||||||
return clip_nodes, modification_time
|
return nodes, modification_time
|
||||||
|
|
||||||
|
|
||||||
def timed_source(probe, src, begin, dur, seek, out, first, last):
|
def timed_source(probe, src, begin, dur, seek, out, first, last):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user