started extracting UI logic from coub_dl class
This commit is contained in:
parent
a881bdaaf6
commit
093bcb5567
12
coub-dl.py
12
coub-dl.py
@ -31,6 +31,10 @@ class File(Enum):
|
||||
OUTPUT = 4
|
||||
|
||||
|
||||
class DownloadFailure(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
class coub_dl:
|
||||
default_files = {Stream.AUDIO: 'audio', Stream.VIDEO: 'video',
|
||||
File.LIST: 'list.txt', File.LOOP: 'loop', File.FRACTION: 'fraction',
|
||||
@ -49,8 +53,7 @@ class coub_dl:
|
||||
self.download_audio_stream()
|
||||
self.download_video_stream()
|
||||
self.read_extensions()
|
||||
try: self.check_downloads()
|
||||
except RuntimeError: exit('Failed to download streams! This usually happens when Coub changes something.')
|
||||
self.check_downloads()
|
||||
self.fix_video_stream()
|
||||
|
||||
# get stream lengths via ffprobe
|
||||
@ -108,7 +111,7 @@ class coub_dl:
|
||||
def check_downloads(self):
|
||||
check = {Stream.VIDEO, Stream.AUDIO}
|
||||
if not all({exists(self._files_dict[item]) for item in check}):
|
||||
raise RuntimeError('Download failed!')
|
||||
raise DownloadFailure()
|
||||
|
||||
|
||||
def fix_video_stream(self):
|
||||
@ -222,4 +225,5 @@ if __name__ == '__main__':
|
||||
|
||||
for url in set(args.URLs):
|
||||
print_opt('\nCreating video from {}'.format(url))
|
||||
run(url, args.output, args.extension)
|
||||
try: run(url, args.output, args.extension)
|
||||
except DownloadFailure: exit('Failed to download streams! This usually happens when Coub changes something.')
|
||||
|
Loading…
Reference in New Issue
Block a user