Skip to content

Commit

Permalink
[postprocessor/ffmpeg] sanitize ffmpeg version for Ubuntu and Arch Li…
Browse files Browse the repository at this point in the history
…nux systems(closes #18813)
  • Loading branch information
remitamine committed Jan 11, 2019
1 parent c469e88 commit a64646e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions youtube_dl/postprocessor/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ def _determine_executables(self):
programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe']
prefer_ffmpeg = True

def get_ffmpeg_version(path):
ver = get_exe_version(path, args=['-version'])
if ver:
regexs = [
r'([0-9.]+)-0ubuntu0\.[0-9.]+$', # Ubuntu

This comment has been minimized.

Copy link
@rautamiekka

rautamiekka Jan 11, 2019

Contributor

I wouldn't trust the 0ubuntu0 always being the case, [0-9][0-9.]*ubuntu[0-9][0-9.]* would be more like it.

r'n([0-9.]+)$', # Arch Linux
]
for regex in regexs:
mobj = re.match(regex, ver)
if mobj:
ver = mobj.group(1)
return ver

self.basename = None
self.probe_basename = None

Expand Down Expand Up @@ -110,11 +123,10 @@ def _determine_executables(self):
self._paths = dict(
(p, os.path.join(location, p)) for p in programs)
self._versions = dict(
(p, get_exe_version(self._paths[p], args=['-version']))
for p in programs)
(p, get_ffmpeg_version(self._paths[p])) for p in programs)
if self._versions is None:
self._versions = dict(
(p, get_exe_version(p, args=['-version'])) for p in programs)
(p, get_ffmpeg_version(p)) for p in programs)
self._paths = dict((p, p) for p in programs)

if prefer_ffmpeg is False:
Expand Down

0 comments on commit a64646e

Please sign in to comment.