[inkbunny] handle gallery/scraps URLs (#283)
This commit is contained in:
@@ -26,9 +26,10 @@ class InkbunnyExtractor(Extractor):
|
|||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
Extractor.__init__(self, match)
|
Extractor.__init__(self, match)
|
||||||
self.item = match.group(1)
|
self.api = InkbunnyAPI(self)
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
|
self.api.authenticate()
|
||||||
to_bool = ("deleted", "digitalsales", "favorite", "forsale",
|
to_bool = ("deleted", "digitalsales", "favorite", "forsale",
|
||||||
"friends_only", "guest_block", "hidden", "printsales",
|
"friends_only", "guest_block", "hidden", "printsales",
|
||||||
"public", "scraps")
|
"public", "scraps")
|
||||||
@@ -56,56 +57,82 @@ class InkbunnyExtractor(Extractor):
|
|||||||
|
|
||||||
|
|
||||||
class InkbunnyUserExtractor(InkbunnyExtractor):
|
class InkbunnyUserExtractor(InkbunnyExtractor):
|
||||||
"""Extractor for inkbunny user profile"""
|
"""Extractor for inkbunny user profiles"""
|
||||||
subcategory = "user"
|
subcategory = "user"
|
||||||
pattern = BASE_PATTERN + r"/(?!s/)([^/?&#]+)"
|
pattern = BASE_PATTERN + r"/(?!s/)(gallery/|scraps/)?([^/?&#]+)"
|
||||||
test = ("https://inkbunny.net/soina", {
|
test = (
|
||||||
"pattern": r"https://[\w.]+\.metapix\.net/files/full/\d+/\d+_soina_.+",
|
("https://inkbunny.net/soina", {
|
||||||
"range": "20-50",
|
"pattern": r"https://[\w.]+\.metapix\.net/files/full"
|
||||||
"keyword": {
|
r"/\d+/\d+_soina_.+",
|
||||||
"date": "type:datetime",
|
"range": "20-50",
|
||||||
"deleted": bool,
|
"keyword": {
|
||||||
"file_id": "re:[0-9]+",
|
|
||||||
"filename": r"re:[0-9]+_soina_\w+",
|
|
||||||
"full_file_md5": "re:[0-9a-f]{32}",
|
|
||||||
"mimetype": str,
|
|
||||||
"submission_file_order": "re:[0-9]+",
|
|
||||||
"submission_id": "re:[0-9]+",
|
|
||||||
"user_id": "20969",
|
|
||||||
"post": {
|
|
||||||
"comments_count": "re:[0-9]+",
|
|
||||||
"date": "type:datetime",
|
"date": "type:datetime",
|
||||||
"deleted": bool,
|
"deleted": bool,
|
||||||
"digitalsales": bool,
|
"file_id": "re:[0-9]+",
|
||||||
"favorite": bool,
|
"filename": r"re:[0-9]+_soina_\w+",
|
||||||
"favorites_count": "re:[0-9]+",
|
"full_file_md5": "re:[0-9a-f]{32}",
|
||||||
"forsale": bool,
|
"mimetype": str,
|
||||||
"friends_only": bool,
|
"submission_file_order": "re:[0-9]+",
|
||||||
"guest_block": bool,
|
|
||||||
"hidden": bool,
|
|
||||||
"pagecount": "re:[0-9]+",
|
|
||||||
"pools": list,
|
|
||||||
"pools_count": int,
|
|
||||||
"printsales": bool,
|
|
||||||
"public": bool,
|
|
||||||
"rating_id": "re:[0-9]+",
|
|
||||||
"rating_name": str,
|
|
||||||
"ratings": list,
|
|
||||||
"scraps": bool,
|
|
||||||
"submission_id": "re:[0-9]+",
|
"submission_id": "re:[0-9]+",
|
||||||
"tags": list,
|
|
||||||
"title": str,
|
|
||||||
"type_name": str,
|
|
||||||
"user_id": "20969",
|
"user_id": "20969",
|
||||||
"username": "soina",
|
"post": {
|
||||||
"views": str,
|
"comments_count" : "re:[0-9]+",
|
||||||
|
"date" : "type:datetime",
|
||||||
|
"deleted" : bool,
|
||||||
|
"digitalsales" : bool,
|
||||||
|
"favorite" : bool,
|
||||||
|
"favorites_count": "re:[0-9]+",
|
||||||
|
"forsale" : bool,
|
||||||
|
"friends_only" : bool,
|
||||||
|
"guest_block" : bool,
|
||||||
|
"hidden" : bool,
|
||||||
|
"pagecount" : "re:[0-9]+",
|
||||||
|
"pools" : list,
|
||||||
|
"pools_count" : int,
|
||||||
|
"printsales" : bool,
|
||||||
|
"public" : bool,
|
||||||
|
"rating_id" : "re:[0-9]+",
|
||||||
|
"rating_name" : str,
|
||||||
|
"ratings" : list,
|
||||||
|
"scraps" : bool,
|
||||||
|
"submission_id" : "re:[0-9]+",
|
||||||
|
"tags" : list,
|
||||||
|
"title" : str,
|
||||||
|
"type_name" : str,
|
||||||
|
"user_id" : "20969",
|
||||||
|
"username" : "soina",
|
||||||
|
"views" : str,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
})
|
("https://inkbunny.net/gallery/soina", {
|
||||||
|
"range": "1-25",
|
||||||
|
"keyword": {"post": {"scraps": False}},
|
||||||
|
}),
|
||||||
|
("https://inkbunny.net/scraps/soina", {
|
||||||
|
"range": "1-25",
|
||||||
|
"keyword": {"post": {"scraps": True}},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, match):
|
||||||
|
kind, self.user = match.groups()
|
||||||
|
if not kind:
|
||||||
|
self.scraps = None
|
||||||
|
elif kind[0] == "g":
|
||||||
|
self.subcategory = "gallery"
|
||||||
|
self.scraps = "no"
|
||||||
|
else:
|
||||||
|
self.subcategory = "scraps"
|
||||||
|
self.scraps = "only"
|
||||||
|
InkbunnyExtractor.__init__(self, match)
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
api = InkbunnyAPI(self)
|
params = {
|
||||||
return api.search(username=self.item)
|
"username": self.user,
|
||||||
|
"scraps": self.scraps,
|
||||||
|
}
|
||||||
|
return self.api.search(params)
|
||||||
|
|
||||||
|
|
||||||
class InkbunnyPostExtractor(InkbunnyExtractor):
|
class InkbunnyPostExtractor(InkbunnyExtractor):
|
||||||
@@ -123,9 +150,12 @@ class InkbunnyPostExtractor(InkbunnyExtractor):
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __init__(self, match):
|
||||||
|
InkbunnyExtractor.__init__(self, match)
|
||||||
|
self.submission_id = match.group(1)
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
api = InkbunnyAPI(self)
|
return self.api.detail(self.submission_id)
|
||||||
return api.detail(self.item)
|
|
||||||
|
|
||||||
|
|
||||||
class InkbunnyAPI():
|
class InkbunnyAPI():
|
||||||
@@ -143,9 +173,8 @@ class InkbunnyAPI():
|
|||||||
params = {"submission_ids": submission_ids}
|
params = {"submission_ids": submission_ids}
|
||||||
return self._call("submissions", params)["submissions"]
|
return self._call("submissions", params)["submissions"]
|
||||||
|
|
||||||
def search(self, username):
|
def search(self, params):
|
||||||
"""Perform a search"""
|
"""Perform a search"""
|
||||||
params = {"username": username}
|
|
||||||
return self._pagination_search(params)
|
return self._pagination_search(params)
|
||||||
|
|
||||||
def set_allowed_ratings(self, nudity=True, sexual=True,
|
def set_allowed_ratings(self, nudity=True, sexual=True,
|
||||||
@@ -170,9 +199,6 @@ class InkbunnyAPI():
|
|||||||
self.set_allowed_ratings()
|
self.set_allowed_ratings()
|
||||||
|
|
||||||
def _call(self, endpoint, params):
|
def _call(self, endpoint, params):
|
||||||
if not self.session_id:
|
|
||||||
self.authenticate()
|
|
||||||
|
|
||||||
url = "https://inkbunny.net/api_" + endpoint + ".php"
|
url = "https://inkbunny.net/api_" + endpoint + ".php"
|
||||||
params["sid"] = self.session_id
|
params["sid"] = self.session_id
|
||||||
data = self.extractor.request(url, params=params).json()
|
data = self.extractor.request(url, params=params).json()
|
||||||
|
|||||||
Reference in New Issue
Block a user