[openload] New --phantomjs-location option

This option allows users to use a phantomjs binary that is not in PATH

Closes #15146
This commit is contained in:
Pierre Rudloff 2018-01-25 12:36:54 +01:00
parent 9d6458a206
commit 6bc637d34a
4 changed files with 15 additions and 5 deletions

View File

@ -2246,7 +2246,7 @@ class YoutubeDL(object):
exe_versions = FFmpegPostProcessor.get_versions(self)
exe_versions['rtmpdump'] = rtmpdump_version()
exe_versions['phantomjs'] = PhantomJSwrapper._version()
exe_versions['phantomjs'] = PhantomJSwrapper._version(self)
exe_str = ', '.join(
'%s %s' % (exe, v)
for exe, v in sorted(exe_versions.items())

View File

@ -415,6 +415,7 @@ def _real_main(argv=None):
'match_filter': match_filter,
'no_color': opts.no_color,
'ffmpeg_location': opts.ffmpeg_location,
'phantomjs_location': opts.phantomjs_location,
'hls_prefer_native': opts.hls_prefer_native,
'hls_use_mpegts': opts.hls_use_mpegts,
'external_downloader_args': external_downloader_args,

View File

@ -108,13 +108,18 @@ class PhantomJSwrapper(object):
_TMP_FILE_NAMES = ['script', 'html', 'cookies']
@staticmethod
def _version():
return get_exe_version('phantomjs', version_re=r'([0-9.]+)')
def _get_path(downloader):
location = downloader.params.get('phantomjs_location') or 'phantomjs'
return location
@staticmethod
def _version(downloader):
return get_exe_version(PhantomJSwrapper._get_path(downloader), version_re=r'([0-9.]+)')
def __init__(self, extractor, required_version=None, timeout=10000):
self._TMP_FILES = {}
self.exe = check_executable('phantomjs', ['-v'])
self.exe = check_executable(self._get_path(extractor._downloader), ['-v'])
if not self.exe:
raise ExtractorError('PhantomJS executable not found in PATH, '
'download it from http://phantomjs.org',
@ -123,7 +128,7 @@ class PhantomJSwrapper(object):
self.extractor = extractor
if required_version:
version = self._version()
version = self._version(self.extractor._downloader)
if is_outdated_version(version, required_version):
self.extractor._downloader.report_warning(
'Your copy of PhantomJS is outdated, update it to version '

View File

@ -516,6 +516,10 @@ def parseOpts(overrideArguments=None):
'--external-downloader-args',
dest='external_downloader_args', metavar='ARGS',
help='Give these arguments to the external downloader')
downloader.add_option(
'--phantomjs-location', metavar='PATH',
dest='phantomjs_location',
help='Path to the phantomjs binary')
workarounds = optparse.OptionGroup(parser, 'Workarounds')
workarounds.add_option(