[ytdl] detect yt-dlp independent of module name (#7599)
This commit is contained in:
@@ -71,7 +71,7 @@ def construct_YoutubeDL(module, obj, user_opts, system_opts=None):
|
||||
def parse_command_line(module, argv):
|
||||
parser, opts, args = module.parseOpts(argv)
|
||||
|
||||
ytdlp = (module.__name__ == "yt_dlp")
|
||||
ytdlp = hasattr(module, "cookies")
|
||||
std_headers = module.std_headers
|
||||
|
||||
try:
|
||||
|
||||
@@ -26,6 +26,7 @@ class Test_CommandlineArguments(unittest.TestCase):
|
||||
raise unittest.SkipTest("cannot import module '{}'".format(
|
||||
cls.module_name))
|
||||
cls.default = ytdl.parse_command_line(cls.module, [])
|
||||
cls.ytdlp = hasattr(cls.module, "cookies")
|
||||
|
||||
def test_ignore_errors(self):
|
||||
self._("--ignore-errors" , "ignoreerrors", True)
|
||||
@@ -155,21 +156,21 @@ class Test_CommandlineArguments(unittest.TestCase):
|
||||
def test_subs(self):
|
||||
opts = self._(["--convert-subs", "srt"])
|
||||
conv = {"key": "FFmpegSubtitlesConvertor", "format": "srt"}
|
||||
if self.module_name == "yt_dlp":
|
||||
if self.ytdlp:
|
||||
conv["when"] = "before_dl"
|
||||
self.assertEqual(opts["postprocessors"][0], conv)
|
||||
|
||||
def test_embed(self):
|
||||
subs = {"key": "FFmpegEmbedSubtitle"}
|
||||
thumb = {"key": "EmbedThumbnail", "already_have_thumbnail": False}
|
||||
if self.module_name == "yt_dlp":
|
||||
if self.ytdlp:
|
||||
subs["already_have_subtitle"] = False
|
||||
|
||||
opts = self._(["--embed-subs", "--embed-thumbnail"])
|
||||
self.assertEqual(opts["postprocessors"][:2], [subs, thumb])
|
||||
|
||||
thumb["already_have_thumbnail"] = True
|
||||
if self.module_name == "yt_dlp":
|
||||
if self.ytdlp:
|
||||
subs["already_have_subtitle"] = True
|
||||
thumb["already_have_thumbnail"] = "all"
|
||||
|
||||
@@ -212,7 +213,7 @@ class Test_CommandlineArguments(unittest.TestCase):
|
||||
"--ignore-config",
|
||||
]
|
||||
|
||||
if self.module_name != "yt_dlp":
|
||||
if not self.ytdlp:
|
||||
cmdline.extend((
|
||||
"--dump-json",
|
||||
"--dump-single-json",
|
||||
|
||||
Reference in New Issue
Block a user