Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aryion] Add favorite extractor #5870

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,22 @@ def posts(self):
def metadata(self):
"""Return general metadata"""

def _pagination_params(self, url, params=None):
def _pagination_params(self, url, params=None, favorite_items=False):
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='"

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, begin, "'"):
cnt += 1
yield post_id

Expand Down Expand Up @@ -199,6 +203,19 @@ def posts(self):
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"
categorytransfer = True
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct here? I copied it from the gallery extractor, but I don't understand what it does.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it so that child extractors use the same settings as their parent by default (extractor.category-transfer). Not really necessary here I think, but it probably won't hurt to have this enabled just in case.

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)

class AryionTagExtractor(AryionExtractor):
"""Extractor for tag searches on eka's portal"""
Expand Down
Loading