[arcalife] add 'gifs' option (#5657)
This commit is contained in:
@@ -1405,6 +1405,17 @@ Description
|
|||||||
Download emoticon images.
|
Download emoticon images.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.arcalive.gifs
|
||||||
|
-----------------------
|
||||||
|
Type
|
||||||
|
``bool``
|
||||||
|
Default
|
||||||
|
``true``
|
||||||
|
Description
|
||||||
|
Check if ``.mp4`` videos have a ``.gif`` version
|
||||||
|
and download those instead.
|
||||||
|
|
||||||
|
|
||||||
extractor.artstation.external
|
extractor.artstation.external
|
||||||
-----------------------------
|
-----------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -103,7 +103,8 @@
|
|||||||
{
|
{
|
||||||
"sleep-request": "0.5-1.5",
|
"sleep-request": "0.5-1.5",
|
||||||
|
|
||||||
"emoticons": false
|
"emoticons": false,
|
||||||
|
"gifs" : true
|
||||||
},
|
},
|
||||||
"artstation":
|
"artstation":
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class ArcalivePostExtractor(ArcaliveExtractor):
|
|||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
self.emoticons = self.config("emoticons", False)
|
self.emoticons = self.config("emoticons", False)
|
||||||
|
self.gifs = self.config("gifs", True)
|
||||||
|
|
||||||
post = self.api.post(self.groups[0])
|
post = self.api.post(self.groups[0])
|
||||||
files = self._extract_files(post)
|
files = self._extract_files(post)
|
||||||
@@ -61,7 +62,7 @@ class ArcalivePostExtractor(ArcaliveExtractor):
|
|||||||
def _extract_files(self, post):
|
def _extract_files(self, post):
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
for media in self._extract_media(post["content"]):
|
for video, media in self._extract_media(post["content"]):
|
||||||
|
|
||||||
if not self.emoticons and 'class="arca-emoticon"' in media:
|
if not self.emoticons and 'class="arca-emoticon"' in media:
|
||||||
continue
|
continue
|
||||||
@@ -87,6 +88,13 @@ class ArcalivePostExtractor(ArcaliveExtractor):
|
|||||||
if ext != orig:
|
if ext != orig:
|
||||||
fallback = (url + "?type=orig",)
|
fallback = (url + "?type=orig",)
|
||||||
url = path + "." + orig
|
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:
|
||||||
|
fallback = (url + "?type=orig",)
|
||||||
|
url = url_gif
|
||||||
|
|
||||||
files.append({
|
files.append({
|
||||||
"url" : url + "?type=orig",
|
"url" : url + "?type=orig",
|
||||||
@@ -99,7 +107,7 @@ class ArcalivePostExtractor(ArcaliveExtractor):
|
|||||||
|
|
||||||
def _extract_media(self, content):
|
def _extract_media(self, content):
|
||||||
ArcalivePostExtractor._extract_media = extr = re.compile(
|
ArcalivePostExtractor._extract_media = extr = re.compile(
|
||||||
r"<(?:img|video) ([^>]+)").findall
|
r"<(?:img|vide(o)) ([^>]+)").findall
|
||||||
return extr(content)
|
return extr(content)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ __tests__ = (
|
|||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://arca.live/b/bluearchive/117240135",
|
"#url" : "https://arca.live/b/bluearchive/117240135",
|
||||||
"#comment": "video",
|
"#comment": ".mp4 video",
|
||||||
"#class" : arcalive.ArcalivePostExtractor,
|
"#class" : arcalive.ArcalivePostExtractor,
|
||||||
"#urls" : "https://ac.namu.la/20240926sac/16f07778a97f91b935c8a3394ead01a223d96b2a619fdb25c4628ddba88b5fad.mp4?type=orig",
|
"#urls" : "https://ac.namu.la/20240926sac/16f07778a97f91b935c8a3394ead01a223d96b2a619fdb25c4628ddba88b5fad.mp4?type=orig",
|
||||||
},
|
},
|
||||||
@@ -94,10 +94,8 @@ __tests__ = (
|
|||||||
{
|
{
|
||||||
"#url" : "https://arca.live/b/bluearchive/111191955",
|
"#url" : "https://arca.live/b/bluearchive/111191955",
|
||||||
"#comment": "fake .mp4 GIF",
|
"#comment": "fake .mp4 GIF",
|
||||||
"#skip" : "not implemented",
|
|
||||||
"#class" : arcalive.ArcalivePostExtractor,
|
"#class" : arcalive.ArcalivePostExtractor,
|
||||||
# "#urls" : "https://ac.namu.la/20240714sac/c8fcadeb0b578e5121eb7a7e8fb05984cb87c68e7a6e0481a1c8869bf0ecfd2b.gif?type=orig",
|
"#urls" : "https://ac.namu.la/20240714sac/c8fcadeb0b578e5121eb7a7e8fb05984cb87c68e7a6e0481a1c8869bf0ecfd2b.gif?type=orig",
|
||||||
"#urls" : "https://ac.namu.la/20240714sac/c8fcadeb0b578e5121eb7a7e8fb05984cb87c68e7a6e0481a1c8869bf0ecfd2b.mp4?type=orig",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user