Skip to content

Commit 42407af

Browse files
committed
[xenforo] implement '"order-posts": "reaction"' (#8997)
1 parent 3d36ee0 commit 42407af

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

docs/configuration.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7307,15 +7307,20 @@ extractor.[xenforo].order-posts
73077307
Type
73087308
``string``
73097309
Default
7310-
``"desc"``
7310+
``thread``
7311+
``"desc"``
7312+
otherwise
7313+
``"asc"``
73117314
Description
73127315
Controls the order in which
7313-
posts of a ``thread`` are processed.
7316+
posts of a ``thread`` or `media` files are processed.
73147317

73157318
``"asc"``
73167319
Ascending order (oldest first)
73177320
``"desc"`` | ``"reverse"``
73187321
Descending order (newest first)
7322+
``"reaction"`` | ``"score"``
7323+
Reaction Score order (``threads`` only)
73197324

73207325

73217326
extractor.ytdl.cmdline-args

gallery_dl/extractor/xenforo.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ def _login_impl(self, username, password):
198198
if cookie.domain.endswith(self.cookies_domain)
199199
}
200200

201-
def _pagination(self, base, pnum=None, callback=None):
201+
def _pagination(self, base, pnum=None, callback=None, params=""):
202202
base = self.root + base
203203

204204
if pnum is None:
205-
url = base + "/"
205+
url = f"{base}/{params}"
206206
pnum = 1
207207
else:
208-
url = f"{base}/page-{pnum}"
208+
url = f"{base}/page-{pnum}{params}"
209209
pnum = None
210210

211211
page = self.request_page(url).text
@@ -217,7 +217,7 @@ def _pagination(self, base, pnum=None, callback=None):
217217
if pnum is None or "pageNav-jump--next" not in page:
218218
return
219219
pnum += 1
220-
page = self.request_page(f"{base}/page-{pnum}").text
220+
page = self.request_page(f"{base}/page-{pnum}{params}").text
221221

222222
def _pagination_reverse(self, base, pnum=None, callback=None):
223223
base = self.root + base
@@ -485,7 +485,12 @@ def posts(self):
485485

486486
if (order := self.config("order-posts")) and \
487487
order[0] not in ("d", "r"):
488-
pages = self._pagination(path, pnum)
488+
params = "?order=reaction_score" if order[0] == "s" else ""
489+
pages = self._pagination(path, pnum, params=params)
490+
reverse = False
491+
elif order == "reaction":
492+
pages = self._pagination(
493+
path, pnum, params="?order=reaction_score")
489494
reverse = False
490495
else:
491496
pages = self._pagination_reverse(path, pnum)

test/results/simpcity.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,19 @@
302302
"#class" : xenforo.XenforoThreadExtractor,
303303
},
304304

305+
{
306+
"#url" : "https://simpcity.cr/threads/ririkana-rr_loveit.10731/",
307+
"#comment" : "post order by reaction score (#8997)",
308+
"#category": ("xenforo", "simpcity", "thread"),
309+
"#class" : xenforo.XenforoThreadExtractor,
310+
"#auth" : True,
311+
"#options" : {
312+
"post-range" : 1,
313+
"order-posts": "reaction",
314+
},
315+
"#results" : "https://bunkr.cr/v/BKLYkkr9KK6dg",
316+
},
317+
305318
{
306319
"#url" : "https://simpcity.cr/forums/asians.48/",
307320
"#category": ("xenforo", "simpcity", "forum"),

0 commit comments

Comments
 (0)