refactored handling of filenames

This commit is contained in:
Kjistóf 2017-01-15 20:14:01 +01:00
parent 7f3a8f94b2
commit 0c3b92fc9d

View File

@ -21,24 +21,23 @@ def getDuration(ffprobe_output):
argv.append('https://coub.com/view/aeeuu') argv.append('https://coub.com/view/aeeuu')
AUDIO_FILE = 'audio' FILES = {'AUDIO': 'audio', 'VIDEO': 'video'}
VIDEO_FILE = 'video'
URL = argv[1] if len(argv) > 0 else '' # youtube-dl error message will be shown if '' URL = argv[1] if len(argv) > 0 else '' # youtube-dl error message will be shown if ''
call(('/usr/bin/env', 'youtube-dl', '--extract-audio', call(('/usr/bin/env', 'youtube-dl', '--extract-audio',
'--output', '{}.%(ext)s'.format(AUDIO_FILE), '--output', '{}.%(ext)s'.format(FILES['AUDIO']),
URL)) URL))
call(('/usr/bin/env', 'youtube-dl', '--output', '{}.%(ext)s'.format(VIDEO_FILE), call(('/usr/bin/env', 'youtube-dl', '--output', '{}.%(ext)s'.format(FILES['VIDEO']),
URL)) URL))
for file in listdir(): for file in listdir():
if match('^{}.*'.format(AUDIO_FILE), file): for filename in FILES:
AUDIO_FILE = file if match('^{}.*'.format(FILES[filename]), file):
if match('^{}.*'.format(VIDEO_FILE), file): FILES[filename] = file
VIDEO_FILE = file
audioLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', AUDIO_FILE))) audioLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES['AUDIO'])))
videoLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', VIDEO_FILE))) videoLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES['VIDEO'])))
print(audioLen) print(audioLen)
print(videoLen) print(videoLen)