[danbooru][e621] remove constructors
This commit is contained in:
@@ -205,12 +205,8 @@ class DanbooruTagExtractor(DanbooruExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/posts\?(?:[^&#]*&)*tags=([^&#]*)"
|
pattern = BASE_PATTERN + r"/posts\?(?:[^&#]*&)*tags=([^&#]*)"
|
||||||
example = "https://danbooru.donmai.us/posts?tags=TAG"
|
example = "https://danbooru.donmai.us/posts?tags=TAG"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
DanbooruExtractor.__init__(self, match)
|
|
||||||
tags = match.group(match.lastindex)
|
|
||||||
self.tags = text.unquote(tags.replace("+", " "))
|
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
|
self.tags = text.unquote(self.groups[-1].replace("+", " "))
|
||||||
return {"search_tags": self.tags}
|
return {"search_tags": self.tags}
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
@@ -239,11 +235,8 @@ class DanbooruPoolExtractor(DanbooruExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/pool(?:s|/show)/(\d+)"
|
pattern = BASE_PATTERN + r"/pool(?:s|/show)/(\d+)"
|
||||||
example = "https://danbooru.donmai.us/pools/12345"
|
example = "https://danbooru.donmai.us/pools/12345"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
DanbooruExtractor.__init__(self, match)
|
|
||||||
self.pool_id = match.group(match.lastindex)
|
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
|
self.pool_id = self.groups[-1]
|
||||||
url = "{}/pools/{}.json".format(self.root, self.pool_id)
|
url = "{}/pools/{}.json".format(self.root, self.pool_id)
|
||||||
pool = self.request(url).json()
|
pool = self.request(url).json()
|
||||||
pool["name"] = pool["name"].replace("_", " ")
|
pool["name"] = pool["name"].replace("_", " ")
|
||||||
@@ -262,12 +255,8 @@ class DanbooruPostExtractor(DanbooruExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/post(?:s|/show)/(\d+)"
|
pattern = BASE_PATTERN + r"/post(?:s|/show)/(\d+)"
|
||||||
example = "https://danbooru.donmai.us/posts/12345"
|
example = "https://danbooru.donmai.us/posts/12345"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
DanbooruExtractor.__init__(self, match)
|
|
||||||
self.post_id = match.group(match.lastindex)
|
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
url = "{}/posts/{}.json".format(self.root, self.post_id)
|
url = "{}/posts/{}.json".format(self.root, self.groups[-1])
|
||||||
post = self.request(url).json()
|
post = self.request(url).json()
|
||||||
if self.includes:
|
if self.includes:
|
||||||
params = {"only": self.includes}
|
params = {"only": self.includes}
|
||||||
@@ -283,12 +272,8 @@ class DanbooruPopularExtractor(DanbooruExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/(?:explore/posts/)?popular(?:\?([^#]*))?"
|
pattern = BASE_PATTERN + r"/(?:explore/posts/)?popular(?:\?([^#]*))?"
|
||||||
example = "https://danbooru.donmai.us/explore/posts/popular"
|
example = "https://danbooru.donmai.us/explore/posts/popular"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
DanbooruExtractor.__init__(self, match)
|
|
||||||
self.params = match.group(match.lastindex)
|
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
self.params = params = text.parse_query(self.params)
|
self.params = params = text.parse_query(self.groups[-1])
|
||||||
scale = params.get("scale", "day")
|
scale = params.get("scale", "day")
|
||||||
date = params.get("date") or datetime.date.today().isoformat()
|
date = params.get("date") or datetime.date.today().isoformat()
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class E621PoolExtractor(E621Extractor, danbooru.DanbooruPoolExtractor):
|
|||||||
example = "https://e621.net/pools/12345"
|
example = "https://e621.net/pools/12345"
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
self.log.info("Fetching posts of pool %s", self.pool_id)
|
self.log.info("Collecting posts of pool %s", self.pool_id)
|
||||||
|
|
||||||
id_to_post = {
|
id_to_post = {
|
||||||
post["id"]: post
|
post["id"]: post
|
||||||
@@ -126,7 +126,7 @@ class E621PostExtractor(E621Extractor, danbooru.DanbooruPostExtractor):
|
|||||||
example = "https://e621.net/posts/12345"
|
example = "https://e621.net/posts/12345"
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
url = "{}/posts/{}.json".format(self.root, self.post_id)
|
url = "{}/posts/{}.json".format(self.root, self.groups[-1])
|
||||||
return (self.request(url).json()["post"],)
|
return (self.request(url).json()["post"],)
|
||||||
|
|
||||||
|
|
||||||
@@ -147,11 +147,8 @@ class E621FavoriteExtractor(E621Extractor):
|
|||||||
pattern = BASE_PATTERN + r"/favorites(?:\?([^#]*))?"
|
pattern = BASE_PATTERN + r"/favorites(?:\?([^#]*))?"
|
||||||
example = "https://e621.net/favorites"
|
example = "https://e621.net/favorites"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
E621Extractor.__init__(self, match)
|
|
||||||
self.query = text.parse_query(match.group(match.lastindex))
|
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
|
self.query = text.parse_query(self.groups[-1])
|
||||||
return {"user_id": self.query.get("user_id", "")}
|
return {"user_id": self.query.get("user_id", "")}
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user