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 watchdog.observers import Observer
from .filters.default import build_filtergraph 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 # folder watcher
@ -189,7 +190,7 @@ class GetSourceFromFolder:
self.probe = deepcopy(self.next_probe) self.probe = deepcopy(self.next_probe)
else: else:
self.probe.load(self._media.store[self.index]) 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 = { self.node = {
'in': 0, 'in': 0,
'seek': 0, 'seek': 0,
@ -200,7 +201,8 @@ class GetSourceFromFolder:
} }
if self.index < len(self._media.store) - 1: if self.index < len(self._media.store) - 1:
self.next_probe.load(self._media.store[self.index + 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 = { self.node_next = {
'in': 0, 'in': 0,
'seek': 0, 'seek': 0,

View File

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