-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
638a676
commit 19e32e8
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ | |
"gelbooru", | ||
"gelbooru_v01", | ||
"gelbooru_v02", | ||
"girlsreleased", | ||
"gofile", | ||
"hatenablog", | ||
"hentai2read", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2023 Mike Fährmann | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 as | ||
# published by the Free Software Foundation. | ||
|
||
"""Extractors for https://girlsreleased.com/""" | ||
|
||
from .common import Extractor, Message | ||
from .. import text, util, exception | ||
from ..cache import cache | ||
|
||
BASE_PATTERN = r"(?:https?://)?(?:www\.)?girlsreleased\.com" | ||
|
||
|
||
class GirlsreleasedExtractor(Extractor): | ||
"""Base class for girlsreleased extractors""" | ||
category = "girlsreleased" | ||
root = "https://www.girlsreleased.com/api/0.1" | ||
request_interval = 0.5 | ||
request_interval_min = 0.2 | ||
|
||
def _init(self): | ||
domain = self.config("domain") | ||
if domain: | ||
self.root = text.ensure_http_scheme(domain) | ||
|
||
def _images(self, json): | ||
data = { | ||
"title": json["name"] or json["id"], | ||
"id": json["id"], | ||
"site": json["site"], | ||
"model": ", ".join(model for _, model in json["models"]) | ||
} | ||
yield Message.Directory, data | ||
for image in json["images"]: | ||
yield Message.Queue, image[3], data | ||
|
||
def items(self): | ||
posts = self.posts() | ||
|
||
if "images" in posts: | ||
yield from self._images(posts) | ||
else: | ||
for gallery in posts: | ||
url = "{}/set/{}".format(self.root, gallery[0]) | ||
yield from self._images(self.request(url).json()["set"]) | ||
|
||
|
||
class GirlsreleasedGalleryExtractor(GirlsreleasedExtractor): | ||
"""Extractor for girlsreleased galleries""" | ||
subcategory = "gallery" | ||
pattern = BASE_PATTERN + r"/set/(\d+)" | ||
example = "https://girlsreleased.com/set/12345" | ||
|
||
def __init__(self, match): | ||
GirlsreleasedExtractor.__init__(self, match) | ||
self.id = match.group(1) | ||
|
||
def posts(self): | ||
url = "{}/set/{}".format(self.root, self.id) | ||
return self.request(url).json()["set"] | ||
|
||
|
||
class GirlsreleasedModelExtractor(GirlsreleasedExtractor): | ||
"""Extractor for girlsreleased models""" | ||
subcategory = "model" | ||
pattern = BASE_PATTERN + r"/model/(\d+(?:/?.+)?)" | ||
example = "https://girlsreleased.com/model/12345/MODEL" | ||
|
||
def __init__(self, match): | ||
GirlsreleasedExtractor.__init__(self, match) | ||
self.id = match.group(1) | ||
|
||
def posts(self): | ||
url = "{}/sets/model/{}".format(self.root, self.id) | ||
return self.request(url).json()["sets"] | ||
|
||
|
||
class GirlsreleasedSiteExtractor(GirlsreleasedExtractor): | ||
"""Extractor for girlsreleased sites""" | ||
subcategory = "site" | ||
pattern = BASE_PATTERN + r"/site/(.+(?:/model/\d+(?:/?.+)?)?)" | ||
example = "https://girlsreleased.com/site/SITE" | ||
|
||
def __init__(self, match): | ||
GirlsreleasedExtractor.__init__(self, match) | ||
self.id = match.group(1) | ||
|
||
def posts(self): | ||
url = "{}/sets/site/{}".format(self.root, self.id) | ||
return self.request(url).json()["sets"] |