[ytdl] improve --xff/--geo-bypass detection (#3989)

check if --xff is supported in a try-except block
and select expected results accordingly
This commit is contained in:
Mike Fährmann
2023-05-01 18:26:37 +02:00
parent aa731c4298
commit df11214281

View File

@@ -235,12 +235,6 @@ class Test_CommandlineArguments(unittest.TestCase):
class Test_CommandlineArguments_YtDlp(Test_CommandlineArguments):
module_name = "yt_dlp"
@classmethod
def setUpClass(cls):
super().setUpClass()
if cls.module.version.__version__ > "2022.07.18": # last 3.6 release
cls.test_geo_bypass = cls._test_geo_bypass_xff
def test_retries_extractor(self):
inf = float("inf")
@@ -275,7 +269,13 @@ class Test_CommandlineArguments_YtDlp(Test_CommandlineArguments):
"title:%(artist)s - %(title)s")],
})
def _test_geo_bypass_xff(self):
def test_geo_bypass(self):
try:
ytdl.parse_command_line(self.module, ["--xff", "default"])
except Exception:
# before --xff (c16644642)
return Test_CommandlineArguments.test_geo_bypass(self)
self._(["--xff", "default"],
"geo_bypass", "default")
self._(["--xff", "never"],