Skip to content

Commit

Permalink
merge #5870: [aryion] add 'favorite' extractor (#4511)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jul 21, 2024
2 parents 36a64a3 + 156a70b commit db9833c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
23 changes: 20 additions & 3 deletions gallery_dl/extractor/aryion.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,20 @@ def posts(self):
def metadata(self):
"""Return general metadata"""

def _pagination_params(self, url, params=None):
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 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, "class='gallery-item' id='", "'"):
for post_id in text.extract_iter(page, needle, "'"):
cnt += 1
yield post_id

Expand Down Expand Up @@ -200,6 +202,21 @@ def posts(self):
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 posts(self):
url = "{}/g4/favorites/{}".format(self.root, self.user)
return self._pagination_params(
url, None, "class='gallery-item favorite' id='")


class AryionTagExtractor(AryionExtractor):
"""Extractor for tag searches on eka's portal"""
subcategory = "tag"
Expand Down
13 changes: 12 additions & 1 deletion test/results/aryion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@
},

{
"#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",
Expand Down

0 comments on commit db9833c

Please sign in to comment.