[xenforo] implement '"order-posts": "reaction"' (#8997)
This commit is contained in:
@@ -7307,15 +7307,20 @@ extractor.[xenforo].order-posts
|
|||||||
Type
|
Type
|
||||||
``string``
|
``string``
|
||||||
Default
|
Default
|
||||||
``"desc"``
|
``thread``
|
||||||
|
``"desc"``
|
||||||
|
otherwise
|
||||||
|
``"asc"``
|
||||||
Description
|
Description
|
||||||
Controls the order in which
|
Controls the order in which
|
||||||
posts of a ``thread`` are processed.
|
posts of a ``thread`` or `media` files are processed.
|
||||||
|
|
||||||
``"asc"``
|
``"asc"``
|
||||||
Ascending order (oldest first)
|
Ascending order (oldest first)
|
||||||
``"desc"`` | ``"reverse"``
|
``"desc"`` | ``"reverse"``
|
||||||
Descending order (newest first)
|
Descending order (newest first)
|
||||||
|
``"reaction"`` | ``"score"``
|
||||||
|
Reaction Score order (``threads`` only)
|
||||||
|
|
||||||
|
|
||||||
extractor.ytdl.cmdline-args
|
extractor.ytdl.cmdline-args
|
||||||
|
|||||||
@@ -198,14 +198,14 @@ class XenforoExtractor(BaseExtractor):
|
|||||||
if cookie.domain.endswith(self.cookies_domain)
|
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
|
base = self.root + base
|
||||||
|
|
||||||
if pnum is None:
|
if pnum is None:
|
||||||
url = base + "/"
|
url = f"{base}/{params}"
|
||||||
pnum = 1
|
pnum = 1
|
||||||
else:
|
else:
|
||||||
url = f"{base}/page-{pnum}"
|
url = f"{base}/page-{pnum}{params}"
|
||||||
pnum = None
|
pnum = None
|
||||||
|
|
||||||
page = self.request_page(url).text
|
page = self.request_page(url).text
|
||||||
@@ -217,7 +217,7 @@ class XenforoExtractor(BaseExtractor):
|
|||||||
if pnum is None or "pageNav-jump--next" not in page:
|
if pnum is None or "pageNav-jump--next" not in page:
|
||||||
return
|
return
|
||||||
pnum += 1
|
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):
|
def _pagination_reverse(self, base, pnum=None, callback=None):
|
||||||
base = self.root + base
|
base = self.root + base
|
||||||
@@ -485,7 +485,12 @@ class XenforoThreadExtractor(XenforoExtractor):
|
|||||||
|
|
||||||
if (order := self.config("order-posts")) and \
|
if (order := self.config("order-posts")) and \
|
||||||
order[0] not in ("d", "r"):
|
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
|
reverse = False
|
||||||
else:
|
else:
|
||||||
pages = self._pagination_reverse(path, pnum)
|
pages = self._pagination_reverse(path, pnum)
|
||||||
|
|||||||
@@ -302,6 +302,19 @@ __tests__ = (
|
|||||||
"#class" : xenforo.XenforoThreadExtractor,
|
"#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/",
|
"#url" : "https://simpcity.cr/forums/asians.48/",
|
||||||
"#category": ("xenforo", "simpcity", "forum"),
|
"#category": ("xenforo", "simpcity", "forum"),
|
||||||
|
|||||||
Reference in New Issue
Block a user