mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[ytdl] ignore SyntaxErrors when trying to import a module
This commit is contained in:
parent
cf8e04d999
commit
127aa45834
@ -42,8 +42,9 @@ class YoutubeDLDownloader(DownloaderBase):
|
|||||||
if not ytdl_instance:
|
if not ytdl_instance:
|
||||||
try:
|
try:
|
||||||
module = ytdl.import_module(self.config("module"))
|
module = ytdl.import_module(self.config("module"))
|
||||||
except ImportError as exc:
|
except (ImportError, SyntaxError) as exc:
|
||||||
self.log.error("Cannot import module '%s'", exc.name)
|
self.log.error("Cannot import module '%s'",
|
||||||
|
getattr(exc, "name", ""))
|
||||||
self.log.debug("", exc_info=True)
|
self.log.debug("", exc_info=True)
|
||||||
self.download = lambda u, p: False
|
self.download = lambda u, p: False
|
||||||
return False
|
return False
|
||||||
|
@ -18,7 +18,7 @@ def import_module(module_name):
|
|||||||
if module_name is None:
|
if module_name is None:
|
||||||
try:
|
try:
|
||||||
return __import__("yt_dlp")
|
return __import__("yt_dlp")
|
||||||
except ImportError:
|
except (ImportError, SyntaxError):
|
||||||
return __import__("youtube_dl")
|
return __import__("youtube_dl")
|
||||||
return __import__(module_name.replace("-", "_"))
|
return __import__(module_name.replace("-", "_"))
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class Test_CommandlineArguments(unittest.TestCase):
|
|||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
try:
|
try:
|
||||||
cls.module = __import__(cls.module_name)
|
cls.module = __import__(cls.module_name)
|
||||||
except ImportError:
|
except (ImportError, SyntaxError):
|
||||||
raise unittest.SkipTest("cannot import module '{}'".format(
|
raise unittest.SkipTest("cannot import module '{}'".format(
|
||||||
cls.module_name))
|
cls.module_name))
|
||||||
cls.default = ytdl.parse_command_line(cls.module, [])
|
cls.default = ytdl.parse_command_line(cls.module, [])
|
||||||
|
Loading…
Reference in New Issue
Block a user