mirror of
https://github.com/mikf/gallery-dl.git
synced 2025-01-31 11:41:35 +01:00
[aryion] update favorite extractor
- add test case - add docs/supportedsites entry - add custom directory_fmt and archive_fmt - remove constructor - appease flake8
This commit is contained in:
parent
19e98ef8e9
commit
156a70bec0
@ -184,7 +184,7 @@ Consider all listed sites to potentially be NSFW.
|
||||
<tr>
|
||||
<td>Eka's Portal</td>
|
||||
<td>https://aryion.com/</td>
|
||||
<td>Galleries, Posts, Tag Searches</td>
|
||||
<td>Favorites, Galleries, Posts, Tag Searches</td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -79,22 +79,20 @@ class AryionExtractor(Extractor):
|
||||
def metadata(self):
|
||||
"""Return general metadata"""
|
||||
|
||||
def _pagination_params(self, url, params=None, favorite_items=False):
|
||||
def _pagination_params(self, url, params=None, needle=None):
|
||||
if params is None:
|
||||
params = {"p": 1}
|
||||
else:
|
||||
params["p"] = text.parse_int(params.get("p"), 1)
|
||||
|
||||
if favorite_items == True:
|
||||
begin = "class='gallery-item favorite' id='"
|
||||
else:
|
||||
begin = "class='gallery-item' id='"
|
||||
if needle is None:
|
||||
needle = "class='gallery-item' id='"
|
||||
|
||||
while True:
|
||||
page = self.request(url, params=params).text
|
||||
|
||||
cnt = 0
|
||||
for post_id in text.extract_iter(page, begin, "'"):
|
||||
for post_id in text.extract_iter(page, needle, "'"):
|
||||
cnt += 1
|
||||
yield post_id
|
||||
|
||||
@ -203,19 +201,21 @@ class AryionGalleryExtractor(AryionExtractor):
|
||||
url = "{}/g4/latest.php?name={}".format(self.root, self.user)
|
||||
return util.advance(self._pagination_next(url), self.offset)
|
||||
|
||||
|
||||
class AryionFavoriteExtractor(AryionExtractor):
|
||||
"""Extractor for a user's favorites gallery"""
|
||||
subcategory = "favorite"
|
||||
directory_fmt = ("{category}", "{user!l}", "favorites")
|
||||
archive_fmt = "f_{user}_{id}"
|
||||
categorytransfer = True
|
||||
pattern = BASE_PATTERN + r"/favorites/([^/?#]+)"
|
||||
example = "https://aryion.com/g4/favorites/USER"
|
||||
|
||||
def __init__(self, match):
|
||||
AryionExtractor.__init__(self, match)
|
||||
|
||||
def posts(self):
|
||||
url = "{}/g4/favorites/{}".format(self.root, self.user)
|
||||
return self._pagination_params(url, favorite_items=True)
|
||||
return self._pagination_params(
|
||||
url, None, "class='gallery-item favorite' id='")
|
||||
|
||||
|
||||
class AryionTagExtractor(AryionExtractor):
|
||||
"""Extractor for tag searches on eka's portal"""
|
||||
|
@ -31,7 +31,18 @@ __tests__ = (
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://aryion.com/g4/tags.php?tag=star+wars&p=19",
|
||||
"#url" : "https://aryion.com/g4/favorites/jameshoward",
|
||||
"#category": ("", "aryion", "favorite"),
|
||||
"#class" : aryion.AryionFavoriteExtractor,
|
||||
"#range" : "1-10",
|
||||
"#count" : 10,
|
||||
|
||||
"user" : "jameshoward",
|
||||
"artist" : "re:^((?!jameshoward).)*$",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://aryion.com/g4/tags.php?tag=star+wars&p=28",
|
||||
"#category": ("", "aryion", "tag"),
|
||||
"#class" : aryion.AryionTagExtractor,
|
||||
"#count" : ">= 5",
|
||||
|
Loading…
x
Reference in New Issue
Block a user