simpler time conversion
This commit is contained in:
parent
ece2411624
commit
390396200d
@ -92,7 +92,7 @@ live_protocols = ["http", "https", "ftp", "rtmp", "rtmpe", "rtmps", "rtp", "rtsp
|
|||||||
[PLAYLIST]
|
[PLAYLIST]
|
||||||
playlist_mode = True
|
playlist_mode = True
|
||||||
path = /playlists
|
path = /playlists
|
||||||
day_start = 05:59:25.000
|
day_start = 05:59:25
|
||||||
length = 24:00:00
|
length = 24:00:00
|
||||||
|
|
||||||
|
|
||||||
|
34
ffplayout.py
34
ffplayout.py
@ -104,17 +104,12 @@ def load_config():
|
|||||||
"""
|
"""
|
||||||
cfg = configparser.ConfigParser()
|
cfg = configparser.ConfigParser()
|
||||||
|
|
||||||
def validate_time(t):
|
|
||||||
timeformat = "%H:%M:%S"
|
|
||||||
try:
|
|
||||||
datetime.strptime(t, timeformat)
|
|
||||||
return True
|
|
||||||
except ValueError:
|
|
||||||
print('wrong time format!')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def str_to_sec(s):
|
def str_to_sec(s):
|
||||||
return float(s[0]) * 3600 + float(s[1]) * 60 + float(s[2])
|
s = s.split(':')
|
||||||
|
try:
|
||||||
|
return float(s[0]) * 3600 + float(s[1]) * 60 + float(s[2])
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
if stdin_args.config:
|
if stdin_args.config:
|
||||||
cfg.read(stdin_args.config)
|
cfg.read(stdin_args.config)
|
||||||
@ -124,24 +119,11 @@ def load_config():
|
|||||||
cfg.read('ffplayout.conf')
|
cfg.read('ffplayout.conf')
|
||||||
|
|
||||||
if stdin_args.start:
|
if stdin_args.start:
|
||||||
if stdin_args.start == 'now':
|
p_start = str_to_sec(stdin_args.start)
|
||||||
p_start = None
|
|
||||||
elif validate_time(stdin_args.start):
|
|
||||||
p_start = str_to_sec(stdin_args.start.split(':'))
|
|
||||||
else:
|
else:
|
||||||
stime = cfg.get('PLAYLIST', 'day_start')
|
p_start = str_to_sec(cfg.get('PLAYLIST', 'day_start'))
|
||||||
|
|
||||||
if validate_time(stime):
|
p_length = str_to_sec(cfg.get('PLAYLIST', 'length'))
|
||||||
p_start = str_to_sec(stime.split(':'))
|
|
||||||
else:
|
|
||||||
p_start = None
|
|
||||||
|
|
||||||
ltime = cfg.get('PLAYLIST', 'length').split(':')
|
|
||||||
|
|
||||||
if ltime[0] and ltime[1] and ltime[2]:
|
|
||||||
p_length = str_to_sec(ltime)
|
|
||||||
else:
|
|
||||||
p_length = None
|
|
||||||
|
|
||||||
_general.stop = cfg.getboolean('GENERAL', 'stop_on_error')
|
_general.stop = cfg.getboolean('GENERAL', 'stop_on_error')
|
||||||
_general.threshold = cfg.getfloat('GENERAL', 'stop_threshold')
|
_general.threshold = cfg.getfloat('GENERAL', 'stop_threshold')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user