merge #6613: [itaku] add 'search' extractor
This commit is contained in:
@@ -478,7 +478,7 @@ Consider all listed sites to potentially be NSFW.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Itaku</td>
|
<td>Itaku</td>
|
||||||
<td>https://itaku.ee/</td>
|
<td>https://itaku.ee/</td>
|
||||||
<td>Galleries, individual Images</td>
|
<td>Galleries, individual Images, Search Results</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -78,6 +78,16 @@ class ItakuImageExtractor(ItakuExtractor):
|
|||||||
return (self.api.image(self.item),)
|
return (self.api.image(self.item),)
|
||||||
|
|
||||||
|
|
||||||
|
class ItakuSearchExtractor(ItakuExtractor):
|
||||||
|
subcategory = "search"
|
||||||
|
pattern = BASE_PATTERN + r"/home/images/?\?([^#]+)"
|
||||||
|
example = "https://itaku.ee/home/images?tags=SEARCH"
|
||||||
|
|
||||||
|
def posts(self):
|
||||||
|
params = text.parse_query_list(self.item)
|
||||||
|
return self.api.search_images(params)
|
||||||
|
|
||||||
|
|
||||||
class ItakuAPI():
|
class ItakuAPI():
|
||||||
|
|
||||||
def __init__(self, extractor):
|
def __init__(self, extractor):
|
||||||
@@ -87,6 +97,42 @@ class ItakuAPI():
|
|||||||
"Accept": "application/json, text/plain, */*",
|
"Accept": "application/json, text/plain, */*",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def search_images(self, params):
|
||||||
|
endpoint = "/galleries/images/"
|
||||||
|
required_tags = []
|
||||||
|
negative_tags = []
|
||||||
|
optional_tags = []
|
||||||
|
|
||||||
|
tags = params.pop("tags", None)
|
||||||
|
if not tags:
|
||||||
|
tags = ()
|
||||||
|
elif isinstance(tags, str):
|
||||||
|
tags = (tags,)
|
||||||
|
|
||||||
|
for tag in tags:
|
||||||
|
if not tag:
|
||||||
|
pass
|
||||||
|
elif tag[0] == "-":
|
||||||
|
negative_tags.append(tag[1:])
|
||||||
|
elif tag[0] == "~":
|
||||||
|
optional_tags.append(tag[1:])
|
||||||
|
else:
|
||||||
|
required_tags.append(tag)
|
||||||
|
|
||||||
|
api_params = {
|
||||||
|
"required_tags": required_tags,
|
||||||
|
"negative_tags": negative_tags,
|
||||||
|
"optional_tags": optional_tags,
|
||||||
|
"date_range": "",
|
||||||
|
"maturity_rating": ("SFW", "Questionable", "NSFW"),
|
||||||
|
"ordering" : "-date_added",
|
||||||
|
"page" : "1",
|
||||||
|
"page_size" : "30",
|
||||||
|
"visibility": ("PUBLIC", "PROFILE_ONLY"),
|
||||||
|
}
|
||||||
|
api_params.update(params)
|
||||||
|
return self._pagination(endpoint, api_params, self.image)
|
||||||
|
|
||||||
def galleries_images(self, username, section=None):
|
def galleries_images(self, username, section=None):
|
||||||
endpoint = "/galleries/images/"
|
endpoint = "/galleries/images/"
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
@@ -78,4 +78,28 @@ __tests__ = (
|
|||||||
"#urls" : "https://itaku.ee/api/media/gallery_vids/sleepy_af_OY5GHWw.mp4",
|
"#urls" : "https://itaku.ee/api/media/gallery_vids/sleepy_af_OY5GHWw.mp4",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://itaku.ee/home/images?tags=cute",
|
||||||
|
"#comment" : "simple search",
|
||||||
|
"#category": ("", "itaku", "search"),
|
||||||
|
"#class" : itaku.ItakuSearchExtractor,
|
||||||
|
"#range" : "1-10",
|
||||||
|
"#count" : 10,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://itaku.ee/home/images?maturity_rating=SFW&date_range=&ordering=-date_added&text=hello&is_video=true",
|
||||||
|
"#comment" : "search for videos",
|
||||||
|
"#category": ("", "itaku", "search"),
|
||||||
|
"#class" : itaku.ItakuSearchExtractor,
|
||||||
|
"#count" : range(5, 50),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://itaku.ee/home/images?tags=%2Bcute&tags=-cute&tags=~cute&maturity_rating=SFW&date_range=&ordering=-date_added",
|
||||||
|
"#comment" : "search with postive, negative, and optional tags",
|
||||||
|
"#category": ("", "itaku", "search"),
|
||||||
|
"#class" : itaku.ItakuSearchExtractor,
|
||||||
|
"#count" : 0,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user