Skip to content

Commit 17e1d25

Browse files
committed
[scrolller] add 'user' extractor (#8961)
1 parent f99c8f5 commit 17e1d25

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed

docs/supportedsites.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ Consider all listed sites to potentially be NSFW.
988988
<tr id="scrolller" title="scrolller">
989989
<td>Scrolller</td>
990990
<td>https://scrolller.com/</td>
991-
<td>Followed Subreddits, Posts, Subreddits</td>
991+
<td>Followed Subreddits, Posts, Subreddits, Reddit Users</td>
992992
<td>Supported</td>
993993
</tr>
994994
<tr id="senmanga" title="senmanga">

gallery_dl/extractor/scrolller.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,32 @@ def posts(self):
170170
"SubredditChildrenQuery", variables, subreddit["children"])
171171

172172

173+
class ScrolllerUserExtractor(ScrolllerExtractor):
174+
"""Extractor for media from a scrolller Reddit user"""
175+
subcategory = "user"
176+
directory_fmt = ("{category}", "User", "{posted_by}")
177+
pattern = BASE_PATTERN + r"/reddit-user/([^/?#]+)(?:/?\?([^#]+))?"
178+
example = "https://scrolller.com/reddit-user/USER"
179+
180+
def posts(self):
181+
query = "UserPostsQuery"
182+
variables = {
183+
"username": text.unquote(self.groups[0]),
184+
"iterator": None,
185+
"limit" : 40,
186+
"filter" : None,
187+
"sortBy" : "RANDOM",
188+
"isNsfw" : True,
189+
}
190+
191+
posts = self._request_graphql(query, variables)["getUserPosts"]
192+
if not posts.get("items"):
193+
posts = None
194+
variables["isNsfw"] = False
195+
196+
return self._pagination(query, variables, posts)
197+
198+
173199
class ScrolllerFollowingExtractor(ScrolllerExtractor):
174200
"""Extractor for followed scrolller subreddits"""
175201
subcategory = "following"

gallery_dl/extractor/utils/scrolller_graphql.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,39 @@
2525
}
2626
"""
2727

28+
UserPostsQuery = """\
29+
query UserPostsQuery(
30+
$username: String!
31+
$iterator: String
32+
$limit: Int!
33+
$filter: GalleryFilter
34+
$sortBy: GallerySortBy
35+
$isNsfw: Boolean
36+
) {
37+
getUserPosts(
38+
data: {
39+
username: $username
40+
iterator: $iterator
41+
limit: $limit
42+
filter: $filter
43+
sortBy: $sortBy
44+
isNsfw: $isNsfw
45+
}
46+
) {
47+
iterator items {
48+
__typename id url title posted_by reddit_posted_by subredditId
49+
subredditTitle subredditUrl subredditIsFollowing redditPath isNsfw
50+
hasAudio fullLengthSource gfycatSource redgifsSource ownerAvatar
51+
username displayName favoriteCount isPaid tags commentsCount
52+
commentsRepliesCount duration createdAt isFavorite
53+
albumContent { mediaSources { url width height isOptimized } }
54+
mediaSources { url width height isOptimized }
55+
blurredMediaSources { url width height isOptimized type }
56+
}
57+
}
58+
}
59+
"""
60+
2861
SubredditQuery = """\
2962
query SubredditQuery(
3063
$url: String!

scripts/supportedsites.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@
414414
"books": "Book Searches",
415415
},
416416
"scrolller": {
417+
"user" : "Reddit Users",
417418
"following": "Followed Subreddits",
418419
},
419420
"sexcom": {

test/results/scrolller.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,49 @@
115115
"#auth" : True,
116116
},
117117

118+
{
119+
"#url" : "https://scrolller.com/reddit-user/Jonttufromesbo",
120+
"#class" : scrolller.ScrolllerUserExtractor,
121+
"#pattern" : (
122+
r"https://images\.scrolller\.com/\w+/cabin-in-northern-finland-93vjsuxmcz.jpg",
123+
r"https://images\.scrolller\.com/\w+/northern-lights-in-northern-finland-6ibp3516z1.jpg",
124+
),
125+
126+
"blurredMediaSources": [],
127+
"commentsCount" : 0,
128+
"commentsRepliesCount": 0,
129+
"count" : 1,
130+
"createdAt" : "iso:8601",
131+
"displayName" : None,
132+
"duration" : None,
133+
"extension" : "jpg",
134+
"favoriteCount" : 0,
135+
"filename" : str,
136+
"fullLengthSource": None,
137+
"gfycatSource" : None,
138+
"hasAudio" : False,
139+
"width" : {1080, 2048},
140+
"height" : {1350, 1638},
141+
"id" : {10478722, 32426595},
142+
"isFavorite" : False,
143+
"isNsfw" : False,
144+
"isOptimized" : False,
145+
"isPaid" : False,
146+
"num" : 0,
147+
"ownerAvatar" : None,
148+
"posted_by" : "Jonttufromesbo",
149+
"redditPath" : r"re:/r/AmateurPhotography/comments/\w+/\w+/",
150+
"reddit_posted_by": "Jonttufromesbo",
151+
"redgifsSource" : None,
152+
"subredditId" : 413,
153+
"subredditIsFollowing": False,
154+
"subredditTitle" : "AmateurPhotography",
155+
"subredditUrl" : "/r/AmateurPhotography",
156+
"tags" : None,
157+
"title" : str,
158+
"url" : "re:https://images.scrolller.com/.+",
159+
"username" : "",
160+
"mediaSources" : list
161+
},
162+
118163
)

0 commit comments

Comments
 (0)