diff --git a/docs/configuration.rst b/docs/configuration.rst index 0f5e7386..b7615cf1 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1408,12 +1408,22 @@ Description extractor.arcalive.gifs ----------------------- Type - ``bool`` + * ``bool`` + * ``string`` Default ``true`` Description - Check if ``.mp4`` videos have a ``.gif`` version - and download those instead. + Try to download ``.gif`` versions of ``.mp4`` videos. + + ``true`` | ``"fallback`` + Use the ``.gif`` version as primary URL + and provide the ``.mp4`` one as + `fallback `__. + ``"check"`` + Check whether a ``.gif`` version is available + by sending an extra HEAD request. + ``false`` + Always download the ``.mp4`` version. extractor.artstation.external diff --git a/gallery_dl/extractor/arcalive.py b/gallery_dl/extractor/arcalive.py index 8e832fe4..8c44256f 100644 --- a/gallery_dl/extractor/arcalive.py +++ b/gallery_dl/extractor/arcalive.py @@ -41,7 +41,9 @@ class ArcalivePostExtractor(ArcaliveExtractor): def items(self): self.emoticons = self.config("emoticons", False) - self.gifs = self.config("gifs", True) + self.gifs = gifs = self.config("gifs", True) + if gifs: + self.gifs_fallback = (gifs != "check") post = self.api.post(self.groups[0]) files = self._extract_files(post) @@ -90,11 +92,15 @@ class ArcalivePostExtractor(ArcaliveExtractor): url = path + "." + orig elif video and self.gifs: url_gif = url.rpartition(".")[0] + ".gif" - response = self.request( - url_gif + "?type=orig", method="HEAD", fatal=False) - if response.status_code < 400: + if self.gifs_fallback: fallback = (url + "?type=orig",) url = url_gif + else: + response = self.request( + url_gif + "?type=orig", method="HEAD", fatal=False) + if response.status_code < 400: + fallback = (url + "?type=orig",) + url = url_gif files.append({ "url" : url + "?type=orig", diff --git a/test/results/arcalive.py b/test/results/arcalive.py index 4159ab01..b09600f3 100644 --- a/test/results/arcalive.py +++ b/test/results/arcalive.py @@ -88,6 +88,7 @@ __tests__ = ( "#url" : "https://arca.live/b/bluearchive/117240135", "#comment": ".mp4 video", "#class" : arcalive.ArcalivePostExtractor, + "#options": {"gifs": "check"}, "#urls" : "https://ac.namu.la/20240926sac/16f07778a97f91b935c8a3394ead01a223d96b2a619fdb25c4628ddba88b5fad.mp4?type=orig", }, @@ -95,7 +96,18 @@ __tests__ = ( "#url" : "https://arca.live/b/bluearchive/111191955", "#comment": "fake .mp4 GIF", "#class" : arcalive.ArcalivePostExtractor, + "#options": {"gifs": True}, "#urls" : "https://ac.namu.la/20240714sac/c8fcadeb0b578e5121eb7a7e8fb05984cb87c68e7a6e0481a1c8869bf0ecfd2b.gif?type=orig", + + "_fallback": ("https://ac.namu.la/20240714sac/c8fcadeb0b578e5121eb7a7e8fb05984cb87c68e7a6e0481a1c8869bf0ecfd2b.mp4?type=orig",), +}, + +{ + "#url" : "https://arca.live/b/bluearchive/111191955", + "#comment": "fake .mp4 GIF", + "#class" : arcalive.ArcalivePostExtractor, + "#options": {"gifs": False}, + "#urls" : "https://ac.namu.la/20240714sac/c8fcadeb0b578e5121eb7a7e8fb05984cb87c68e7a6e0481a1c8869bf0ecfd2b.mp4?type=orig", }, {