refactored handling of filenames
This commit is contained in:
parent
7f3a8f94b2
commit
0c3b92fc9d
19
coub-dl.py
19
coub-dl.py
@ -21,24 +21,23 @@ def getDuration(ffprobe_output):
|
||||
|
||||
argv.append('https://coub.com/view/aeeuu')
|
||||
|
||||
AUDIO_FILE = 'audio'
|
||||
VIDEO_FILE = 'video'
|
||||
FILES = {'AUDIO': 'audio', 'VIDEO': 'video'}
|
||||
URL = argv[1] if len(argv) > 0 else '' # youtube-dl error message will be shown if ''
|
||||
|
||||
|
||||
call(('/usr/bin/env', 'youtube-dl', '--extract-audio',
|
||||
'--output', '{}.%(ext)s'.format(AUDIO_FILE),
|
||||
'--output', '{}.%(ext)s'.format(FILES['AUDIO']),
|
||||
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))
|
||||
|
||||
for file in listdir():
|
||||
if match('^{}.*'.format(AUDIO_FILE), file):
|
||||
AUDIO_FILE = file
|
||||
if match('^{}.*'.format(VIDEO_FILE), file):
|
||||
VIDEO_FILE = file
|
||||
for filename in FILES:
|
||||
if match('^{}.*'.format(FILES[filename]), file):
|
||||
FILES[filename] = file
|
||||
|
||||
audioLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', AUDIO_FILE)))
|
||||
videoLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', VIDEO_FILE)))
|
||||
audioLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES['AUDIO'])))
|
||||
videoLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES['VIDEO'])))
|
||||
|
||||
print(audioLen)
|
||||
print(videoLen)
|
||||
|
Loading…
Reference in New Issue
Block a user