Skip to content

Commit

Permalink
[furaffinity] add 'submissions' extractor (#5954)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Aug 7, 2024
1 parent b4733b7 commit 846512f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>Fur Affinity</td>
<td>https://www.furaffinity.net/</td>
<td>Favorites, Followed Users, Galleries, Posts, Scraps, Search Results, User Profiles</td>
<td>Favorites, Followed Users, Galleries, Posts, Scraps, Search Results, New Submissions, User Profiles</td>
<td><a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a></td>
</tr>
<tr>
Expand Down
26 changes: 26 additions & 0 deletions gallery_dl/extractor/furaffinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,29 @@ def items(self):
if url.endswith(path):
return
url = self.root + path


class FuraffinitySubmissionsExtractor(FuraffinityExtractor):
"""Extractor for new furaffinity submissions"""
subcategory = "submissions"
pattern = BASE_PATTERN + r"(/msg/submissions(?:/[^/?#]+)?)"
example = "https://www.furaffinity.net/msg/submissions"

def posts(self):
self.user = None
url = self.root + self.groups[0]
return self._pagination_submissions(url)

def _pagination_submissions(self, url):
while True:
page = self.request(url).text

for post_id in text.extract_iter(page, 'id="sid-', '"'):
yield post_id

path = (text.extr(page, '<a class="button standard more" href="', '"') or # noqa 501
text.extr(page, '<a class="more-half" href="', '"') or
text.extr(page, '<a class="more" href="', '"'))
if not path:
return
url = self.root + text.unescape(path)
3 changes: 3 additions & 0 deletions scripts/supportedsites.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
"fapello": {
"path": "Videos, Trending Posts, Popular Videos, Top Models",
},
"furaffinity": {
"submissions": "New Submissions",
},
"hatenablog": {
"archive": "Archive",
"entry" : "Individual Posts",
Expand Down
17 changes: 17 additions & 0 deletions test/results/furaffinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,21 @@
"#count" : 50,
},

{
"#url" : "https://www.furaffinity.net/msg/submissions",
"#category": ("", "furaffinity", "submissions"),
"#class" : furaffinity.FuraffinitySubmissionsExtractor,
"#auth" : True,
"#pattern" : r"https://d\d?\.f(uraffinity|acdn)\.net/art/mirlinthloth/\d+/\d+.\w+\.\w+",
"#range" : "45-50",
"#count" : 6,
},

{
"#url" : "https://www.furaffinity.net/msg/submissions/new~56789000@48/",
"#category": ("", "furaffinity", "submissions"),
"#class" : furaffinity.FuraffinitySubmissionsExtractor,
"#auth" : True,
},

)

0 comments on commit 846512f

Please sign in to comment.