[xenforo] implement '"order-posts": "reaction"' (#8997)

This commit is contained in:
Mike Fährmann
2026-02-04 21:51:55 +01:00
parent 3d36ee0e53
commit 42407afb6d
3 changed files with 30 additions and 7 deletions

View File

@@ -7307,15 +7307,20 @@ extractor.[xenforo].order-posts
Type
``string``
Default
``"desc"``
``thread``
``"desc"``
otherwise
``"asc"``
Description
Controls the order in which
posts of a ``thread`` are processed.
posts of a ``thread`` or `media` files are processed.
``"asc"``
Ascending order (oldest first)
``"desc"`` | ``"reverse"``
Descending order (newest first)
``"reaction"`` | ``"score"``
Reaction Score order (``threads`` only)
extractor.ytdl.cmdline-args

View File

@@ -198,14 +198,14 @@ class XenforoExtractor(BaseExtractor):
if cookie.domain.endswith(self.cookies_domain)
}
def _pagination(self, base, pnum=None, callback=None):
def _pagination(self, base, pnum=None, callback=None, params=""):
base = self.root + base
if pnum is None:
url = base + "/"
url = f"{base}/{params}"
pnum = 1
else:
url = f"{base}/page-{pnum}"
url = f"{base}/page-{pnum}{params}"
pnum = None
page = self.request_page(url).text
@@ -217,7 +217,7 @@ class XenforoExtractor(BaseExtractor):
if pnum is None or "pageNav-jump--next" not in page:
return
pnum += 1
page = self.request_page(f"{base}/page-{pnum}").text
page = self.request_page(f"{base}/page-{pnum}{params}").text
def _pagination_reverse(self, base, pnum=None, callback=None):
base = self.root + base
@@ -485,7 +485,12 @@ class XenforoThreadExtractor(XenforoExtractor):
if (order := self.config("order-posts")) and \
order[0] not in ("d", "r"):
pages = self._pagination(path, pnum)
params = "?order=reaction_score" if order[0] == "s" else ""
pages = self._pagination(path, pnum, params=params)
reverse = False
elif order == "reaction":
pages = self._pagination(
path, pnum, params="?order=reaction_score")
reverse = False
else:
pages = self._pagination_reverse(path, pnum)

View File

@@ -302,6 +302,19 @@ __tests__ = (
"#class" : xenforo.XenforoThreadExtractor,
},
{
"#url" : "https://simpcity.cr/threads/ririkana-rr_loveit.10731/",
"#comment" : "post order by reaction score (#8997)",
"#category": ("xenforo", "simpcity", "thread"),
"#class" : xenforo.XenforoThreadExtractor,
"#auth" : True,
"#options" : {
"post-range" : 1,
"order-posts": "reaction",
},
"#results" : "https://bunkr.cr/v/BKLYkkr9KK6dg",
},
{
"#url" : "https://simpcity.cr/forums/asians.48/",
"#category": ("xenforo", "simpcity", "forum"),