chenge None type from MediaProbe to empty dict

This commit is contained in:
jb-alvarado 2022-01-11 14:59:20 +01:00
parent 6eabf81752
commit 7d23bbb907
2 changed files with 20 additions and 25 deletions

View File

@ -28,7 +28,8 @@ from watchdog.events import PatternMatchingEventHandler
from watchdog.observers import Observer
from .filters.default import build_filtergraph
from .utils import MediaProbe, ff_proc, messenger, stdin_args, storage
from .utils import (MediaProbe, ff_proc, get_float, messenger, stdin_args,
storage)
# ------------------------------------------------------------------------------
# folder watcher
@ -189,7 +190,7 @@ class GetSourceFromFolder:
self.probe = deepcopy(self.next_probe)
else:
self.probe.load(self._media.store[self.index])
duration = float(self.probe.format['duration'])
duration = get_float(self.probe.format.get('duration'), 0)
self.node = {
'in': 0,
'seek': 0,
@ -200,7 +201,8 @@ class GetSourceFromFolder:
}
if self.index < len(self._media.store) - 1:
self.next_probe.load(self._media.store[self.index + 1])
next_duration = float(self.next_probe.format['duration'])
next_duration = get_float(
self.next_probe.format.get('duration'), 0)
self.node_next = {
'in': 0,
'seek': 0,

View File

@ -598,7 +598,7 @@ class MediaProbe:
def __init__(self):
self.remote_source = ['http', 'https', 'ftp', 'smb', 'sftp']
self.src = None
self.format = None
self.format = {}
self.audio = []
self.video = []
self.is_remote = False
@ -608,7 +608,7 @@ class MediaProbe:
load media file with ffprobe and get info's out of it
"""
self.src = file
self.format = None
self.format = {}
self.audio = []
self.video = []
@ -881,31 +881,24 @@ def gen_filler(node):
node['probe'] = probe
if probe.format:
if probe.format.get('duration'):
node['duration'] = float(probe.format['duration'])
node['source'] = storage.filler
if node['duration'] > duration:
# cut filler
messenger.info(
f'Generate filler')
node['src_cmd'] = ['-i', storage.filler] + set_length(
node['duration'], 0, duration)
return node
# loop file n times
node['src_cmd'] = loop_input(
storage.filler, node['duration'], duration)
if probe.format.get('duration'):
node['duration'] = float(probe.format['duration'])
node['source'] = storage.filler
if node['duration'] > duration:
# cut filler
messenger.info(
f'Generate filler')
node['src_cmd'] = ['-i', storage.filler] + set_length(
node['duration'], 0, duration)
return node
messenger.error("Can't get filler length, generate dummy!")
dummy = gen_dummy(duration)
node['source'] = dummy[3]
node['src_cmd'] = dummy
# loop file n times
node['src_cmd'] = loop_input(storage.filler, node['duration'],
duration)
return node
# when no filler is set, generate a dummy
messenger.warning('No filler is set!')
messenger.warning('No filler clipt is set! Add dummy...')
dummy = gen_dummy(duration)
node['source'] = dummy[3]
node['src_cmd'] = dummy