Debian Codegraph @

gallery_dl/extractor/xenforo.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright 2025-2026 Mike Fährmann
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation.
8
9 """Extractors for XenForo forums"""
10
11 from .common import BaseExtractor, Message
12 from .. import text, util
13
14
15 class XenforoExtractor(BaseExtractor):
16 """Base class for xenforo extractors"""
17 basecategory = "xenforo"
18 directory_fmt = ("{category}", "{thread[section]}",
19 "{thread[title]} ({thread[id]})")
20 filename_fmt = "{post[id]}_{num:>02}{id:?_//}_{filename}.{extension}"
21 archive_fmt = "{post[id]}/{type[0]}{id}_{filename}"
22
23 def __init__(self, match):
24 BaseExtractor.__init__(self, match)
25 self.cookies_domain = self.root.split("/")[2]
26 self.cookies_names = self.config_instance("cookies") or ("xf_user",)
27
28 def items(self):
29 self.login()
30
31 extract_urls = text.re(
32 r'(?s)(?:'
33 r'<video (.*?\ssrc="[^"]+".*?)</video>'
34 r'|<a [^>]*?'
35 r'href="([^"]*?/(?:index\.php\?)?attachments/[^"]+".*?)</a>'
36 r'|<div class="bb(?:Image|Media)Wrapper[^>]*?'
37 r'data-src="([^"]+".*?) />'
38 r'|(?:<a [^>]*?href="|<iframe [^>]*?src="|'
39 r'''onclick="loadMedia\(this, ')([^"']+[^<]*?<)'''
40 r')'
41 ).findall
42
43 embeds = self.config("embeds", True)
44 quotes = self.config("quoted", False)
45 attachments = self.config("attachments", True)
46
47 root = self.root
48 base = root if (pos := root.find("/", 8)) < 0 else root[:pos]
49 for post in self.posts():
50 content = post["content"]
51 if not quotes:
52 content = self._remove_quotes(content)
53
54 urls = extract_urls(content)
55 if embeds and "data-s9e-mediaembed-iframe=" in content:
56 self._extract_embeds(urls, post, content)
57 if attachments and post["attachments"]:
58 self._extract_attachments(urls, post)
59
60 data = {"post": post}
61 post["count"] = data["count"] = len(urls)
62 yield Message.Directory, "", data
63
64 id_last = None
65 data["_http_expected_status"] = (403,)
66 data["_http_validate"] = self._validate
67 data["num"] = data["num_internal"] = data["num_external"] = 0
68 for video, inl, bb, ext in urls:
69 if ext:
70 if ext[0] == "#":
71 continue
72 if ext[0] == "/":
73 if ext[1] == "/":
74 if "'" in ext:
75 ext = ext[:ext.find("'")]
76 ext = "https:" + ext
77 elif ext.startswith("/goto/link-confirmation?"):
78 params = text.parse_query(text.unescape(ext[24:]))
79 ext = self._b64decode(params["url"])
80 elif ext.startswith("/redirect/"):
81 if to := text.extr(ext, "?to=", "&"):
82 ext = self._b64decode(to)
83 elif html := text.extr(ext, ">", "<").strip():
84 ext = text.unescape(html)
85 else:
86 continue
87 elif '"' in ext:
88 ext = ext[:ext.find('"')]
89 if ext.startswith("https://anonym.es/?"):
90 ext = text.unquote(ext[19:])
91 data["num"] += 1
92 data["num_external"] += 1
93 data["type"] = "external"
94 yield Message.Queue, ext, data
95
96 elif video:
97 data["num"] += 1
98 data["num_internal"] += 1
99 data["type"] = "video"
100 url = text.extr(video, 'src="', '"')
101 text.nameext_from_url(url, data)
102 data["id"] = text.parse_int(
103 data["filename"].partition("-")[0])
104 if url[0] == "/":
105 url = base + url
106 yield Message.Url, url, data
107
108 elif (inline := bb or inl):
109 url = inline[:inline.find('"')]
110 name, _, id = url[url.rfind("/", 0, -1):].strip(
111 "/").rpartition(".")
112 data["id"] = id = text.parse_int(id)
113 if id:
114 if id == id_last:
115 id_last = None
116 continue
117 else:
118 id_last = id
119 if alt := (text.extr(inline, 'alt="', '"') or
120 text.extr(inline, 'title="', '"')):
121 text.nameext_from_name(alt, data)
122 if not data["extension"]:
123 data["extension"] = name.rpartition("-")[2]
124 else:
125 data["filename"], _, data["extension"] = \
126 name.rpartition("-")
127 data["num"] += 1
128 data["num_internal"] += 1
129 data["type"] = "inline"
130 if url[0] == "/":
131 url = base + url
132 yield Message.Url, url, data
133
134 def items_media(self, path, pnum, callback=None):
135 if (order := self.config("order-posts")) and \
136 order[0] in {"d", "r"}:
137 pages = self._pagination_reverse(path, pnum, callback)
138 reverse = True
139 else:
140 pages = self._pagination(path, pnum, callback)
141 reverse = False
142
143 if self.config("metadata"):
144 extr_media = self._extract_media_ex
145 meta = True
146 else:
147 extr_media = self._extract_media
148 meta = False
149
150 root = self.root
151 base = root if (pos := root.find("/", 8)) < 0 else root[:pos]
152 for page in pages:
153 posts = page.split(
154 '<div class="itemList-item js-inlineModContainer')
155 del posts[0]
156
157 if reverse:
158 posts.reverse()
159
160 for html in posts:
161 href, pos = text.extract(html, 'href="', '"')
162 name, pos = text.extract(html, "alt='", "'", pos)
163
164 url, media = extr_media(
165 base + href, href[href.rfind("/", 0, -1)+1:-1])
166 if url.endswith("/register/full"):
167 self._warn_auth()
168 continue
169 if not meta and name:
170 text.nameext_from_name(text.unescape(name), media)
171
172 yield Message.Directory, "", media
173 yield Message.Url, url, media
174
175 def request_page(self, url):
176 try:
177 response = self.request(url)
178 if response.history and response.url.endswith("/register"):
179 self._require_auth(response)
180 return response
181 except self.exc.HttpError as exc:
182 if exc.status == 403 and b">Log in<" in exc.response.content:
183 self._require_auth(exc.response)
184 raise
185
186 def login(self):
187 if self.cookies_names and self.cookies_check(
188 self.cookies_names, subdomains=True):
189 return
190
191 username, password = self._get_auth_info()
192 if username:
193 return self.cookies_update(self.cache(
194 self._login_impl, username, password,
195 _exp=365*86400, _mem=False))
196
197 def _login_impl(self, username, password):
198 self.log.info("Logging in as %s", username)
199
200 url = self.root + "/login/login"
201 page = self.request(url).text
202 data = {
203 "_xfToken": text.extr(page, 'name="_xfToken" value="', '"'),
204 "login" : username,
205 "password": password,
206 "remember": "1",
207 "_xfRedirect": "",
208 }
209 response = self.request(url, method="POST", data=data)
210
211 if not response.history:
212 err = self._extract_error(response.text)
213 err = f'"{err}"' if err else None
214 raise self.exc.AuthenticationError(err)
215
216 return {
217 cookie.name: cookie.value
218 for cookie in self.cookies
219 if cookie.domain.endswith(self.cookies_domain)
220 }
221
222 def _pagination(self, base, pnum=None, callback=None, params=""):
223 base = self.root + base
224
225 if pnum is None:
226 url = f"{base}/{params}"
227 pnum = 1
228 else:
229 url = f"{base}/page-{pnum}{params}"
230 pnum = None
231
232 page = self.request_page(url).text
233 if callback is not None:
234 callback(page)
235 while True:
236 yield page
237
238 if pnum is None or "pageNav-jump--next" not in page:
239 return
240 pnum += 1
241 page = self.request_page(f"{base}/page-{pnum}{params}").text
242
243 def _pagination_reverse(self, base, pnum=None, callback=None):
244 base = self.root + base
245
246 url = f"{base}/page-{'9999' if pnum is None else pnum}"
247 with self.request_page(url) as response:
248 if pnum is None and not response.history:
249 self._require_auth()
250 url = response.url
251 if url[-1] == "/":
252 pnum = 1
253 else:
254 pnum = text.parse_int(url[url.rfind("-")+1:], 1)
255 page = response.text
256
257 if callback is not None:
258 callback(page)
259 while True:
260 yield page
261
262 pnum -= 1
263 if pnum > 1:
264 url = f"{base}/page-{pnum}"
265 elif pnum == 1:
266 url = base + "/"
267 else:
268 return
269
270 page = self.request_page(url).text
271
272 def _remove_quotes(self, content):
273 while "<blockquote" in content:
274 beg = content.index("<blockquote")
275 end = content.index("</blockquote", beg)
276 for _ in range(content.count("<blockquote", beg+11, end)):
277 end = content.index("</blockquote", end+13)
278 content = content[:beg] + content[end+13:]
279 return content
280
281 def _b64decode(self, value):
282 return util.b64decode(value.replace("-", "+").replace("_", "/") + "==")
283
284 def _extract_error(self, html):
285 if msg := (text.extr(html, "blockMessage--error", "</") or
286 text.extr(html, '"blockMessage"', "</div>")):
287 return text.unescape(msg[msg.find(">")+1:].strip())
288
289 def _parse_post(self, html):
290 extr = text.extract_from(html)
291
292 post = {
293 "author": extr('data-author="', '"'),
294 "id": (extr('data-content="post-', '"') or
295 extr('data-content="profile-post-', '"')),
296 "author_url": (extr('itemprop="url" content="', '"') or
297 extr('<a href="', '"')),
298 "date": self.parse_datetime_iso(extr('datetime="', '"')),
299 "content": (extr('class="message-body',
300 '<div class="js-selectToQuote') or
301 extr('class="message-body',
302 '</article>')),
303 "attachments": extr('<section class="message-attachments">',
304 '</section>'),
305 }
306
307 url_a = post["author_url"]
308 post["author_slug"], _, post["author_id"] = \
309 url_a[url_a.rfind("/", 0, -1)+1:-1].rpartition(".")
310
311 con = post["content"]
312 if (pos := con.find('<div class="bbWrapper')) >= 0:
313 con = con[pos:]
314 post["content"] = con.strip()
315
316 return post
317
318 def _parse_thread(self, page):
319 try:
320 data = self._extract_jsonld(page)
321 except ValueError:
322 return {}
323
324 path = text.split_html(text.extr(
325 page, 'class="p-breadcrumbs', "</ul>"))
326 del path[0]
327
328 main = data.get("mainEntity", data)
329 url = main.get("url") or main.get("@id") or ""
330
331 self.kwdict["thread"] = thread = self._parse_author(main["author"], {
332 "id" : url[url.rfind(".")+1:-1],
333 "url" : url,
334 "title": main["headline"],
335 "date" : self.parse_datetime_iso(main["datePublished"]),
336 "tags" : (main["keywords"].split(", ")
337 if "keywords" in main else ()),
338 "section": main["articleSection"],
339 "path" : path,
340 })
341
342 stats = main["interactionStatistic"]
343 if isinstance(stats, list):
344 thread["views"] = stats[0]["userInteractionCount"]
345 thread["posts"] = stats[1]["userInteractionCount"]
346 else:
347 thread["views"] = -1
348 thread["posts"] = stats["userInteractionCount"]
349
350 return thread
351
352 def _parse_album(self, page):
353 data = self._extract_jsonld(page)
354 main = data.get("mainEntity") or data
355 url = main.get("url") or main.get("@id") or ""
356 slug, _, id = url[url.rfind("/", 0, -1)+1:-1].rpartition(".")
357
358 self.kwdict["album"] = album = self._parse_author(main["author"], {
359 "id" : id,
360 "url" : url,
361 "slug" : text.unquote(slug),
362 "title": main["headline"],
363 "description": main.get("description"),
364 "date": self.parse_datetime_iso(main["dateCreated"]),
365 })
366
367 stats = main["interactionStatistic"]
368 if isinstance(stats, list):
369 album["count"] = stats[0]["userInteractionCount"]
370 album["likes"] = stats[1]["userInteractionCount"]
371 album["views"] = stats[2]["userInteractionCount"]
372 album["comments"] = stats[3]["userInteractionCount"]
373
374 return album
375
376 def _parse_profile(self, page):
377 user = self._extract_jsonld(page)
378 main = user["mainEntity"]
379 url = user.get("url") or main.get("@id") or ""
380 slug, _, id = url[url.rfind("/", 0, -1)+1:-1].rpartition(".")
381
382 self.kwdict["profile"] = profile = {
383 "id" : main.get("identifier") or id,
384 "url" : url,
385 "slug" : text.unquote(slug),
386 "name" : main.get("name"),
387 "avatar": main.get("image"),
388 "description": main.get("description"),
389 "date" : self.parse_datetime_iso(user.get("dateCreated")),
390 }
391
392 stats = main.get("interactionStatistic")
393 if isinstance(stats, list):
394 profile["follows"] = stats[0]["userInteractionCount"]
395 profile["likes"] = stats[1]["userInteractionCount"]
396
397 return profile
398
399 def _parse_author(self, author, data):
400 data["author"] = author.get("name") or ""
401 if url := author.get("url"):
402 data["author_url"] = url
403 data["author_slug"], _, data["author_id"] = \
404 url[url.rfind("/", 0, -1)+1:-1].rpartition(".")
405 else:
406 data["author_url"] = ""
407 data["author_slug"] = text.slugify(data["author"][:15])
408 data["author_id"] = data["author"][15:]
409 return data
410
411 def _extract_attachments(self, urls, post):
412 find = text.re(r"(?s)\shref=[\"'](.+)").search
413 for att in text.extract_iter(post["attachments"], "<li", "</li>"):
414 urls.append((None, find(att)[1], None, None))
415
416 def _extract_embeds(self, urls, post, content):
417 for embed in text.extract_iter(
418 content, "data-s9e-mediaembed-iframe='", "'"):
419 data = {}
420 key = None
421 for value in util.json_loads(embed):
422 if key is None:
423 key = value
424 else:
425 data[key] = value
426 key = None
427
428 src = data.get("src")
429 if not src:
430 self.log.debug(data)
431 continue
432
433 type = data.get("data-s9e-mediaembed")
434 frag = src[src.find("#")+1:]
435 if type == "tiktok":
436 url = "https://www.tiktok.com/@/video/" + frag
437 elif type == "reddit":
438 url = "https://embed.reddit.com/r/" + frag
439 elif type == "imgur":
440 url = "https://imgur.com/" + frag
441 else:
442 self.log.warning("%s: Unsupported media embed type '%s'",
443 post["id"], type)
444 continue
445 urls.append((None, None, None, url))
446
447 def _extract_media(self, url, file):
448 media = {}
449 name, _, media["id"] = file.rpartition(".")
450 media["filename"], _, media["extension"] = name.rpartition("-")
451 return url + "full", media
452
453 def _extract_media_ex(self, url, file):
454 page = self.request_page(url).text
455
456 schema = self._extract_jsonld(page)
457 main = schema["mainEntity"]
458 stats = main["interactionStatistic"]
459
460 media = text.nameext_from_name(main["name"], {
461 "schema": schema,
462 "id" : file.rpartition(".")[2],
463 "size" : main.get("contentSize"),
464 "description": main.get("description"),
465 "date" : self.parse_datetime_iso(main.get("dateCreated")),
466 "width" : (w := main.get("width")) and text.parse_int(
467 w["name"].partition(" ")[0]) or 0,
468 "height": (h := main.get("height")) and text.parse_int(
469 h["name"].partition(" ")[0]) or 0,
470 })
471
472 self._parse_author(main["author"], media)
473 if ext := main.get("encodingFormat"):
474 media["extension"] = ext
475
476 if isinstance(stats, list):
477 media["views"] = stats[0]["userInteractionCount"]
478 media["likes"] = stats[1]["userInteractionCount"]
479 media["comments"] = stats[2]["userInteractionCount"]
480
481 return main["contentUrl"], media
482
483 def _require_auth(self, response=None):
484 raise self.exc.AuthRequired(
485 ("username & password", "authenticated cookies"), None,
486 None if response is None else self._extract_error(response.text))
487
488 def _warn_auth(self):
489 try:
490 self._require_auth()
491 except Exception as exc:
492 self.log.warning(exc)
493
494 def _validate(self, response):
495 if response.status_code == 403 and b">Log in<" in response.content:
496 self._require_auth(response)
497 return True
498
499
500 BASE_PATTERN = XenforoExtractor.update({
501 "simpcity": {
502 "root": "https://simpcity.cr",
503 "pattern": r"(?:www\.)?simpcity\.(?:cr|su)",
504 "cookies": ("ogaddgmetaprof_user",),
505 },
506 "nudostarforum": {
507 "root": "https://nudostar.com/forum",
508 "pattern": r"(?:www\.)?nudostar\.com/forum",
509 },
510 "atfforum": {
511 "root": "https://allthefallen.moe/forum",
512 "pattern": r"(?:www\.)?allthefallen\.moe/forum",
513 },
514 "celebforum": {
515 "root": "https://celebforum.cc",
516 "pattern": r"(?:www\.)?celebforum\.(?:cc|to)",
517 },
518 "titsintops": {
519 "root": "https://titsintops.com/phpBB2",
520 "pattern": r"(?:www\.)?titsintops\.com/phpBB2",
521 },
522 "socialmediagirlsforum": {
523 "root": "https://forums.socialmediagirls.com",
524 "pattern": r"forums\.socialmediagirls\.com",
525 },
526 "blacktowhite": {
527 "root": "https://www.blacktowhite.net",
528 "pattern": r"(?:www\.)?blacktowhite\.net",
529 },
530 "thefappeningforum": {
531 "root": "https://thefappeningblog.com/forum",
532 "pattern": r"(?:www\.)?thefappeningblog\.com/forum",
533 },
534 "thirsthub": {
535 "root": "https://thirsthub.cc",
536 "pattern": r"thirsthub\.cc",
537 },
538 })
539
540
541 class XenforoPostExtractor(XenforoExtractor):
542 subcategory = "post"
543 pattern = (BASE_PATTERN + r"(/(?:index\.php\?)?th(?:reads|ema)"
544 r"/[^/?#]+/(?:page-\d+)?#?post-|/posts/)(\d+)")
545 example = "https://simpcity.cr/threads/TITLE.12345/post-54321"
546
547 def posts(self):
548 path = self.groups[-2]
549 post_id = self.groups[-1]
550 url = f"{self.root}{path}{post_id}/"
551 page = self.request_page(url).text
552
553 pos = page.find(f'data-content="post-{post_id}"')
554 if pos < 0:
555 raise self.exc.NotFoundError("post")
556 html = text.extract(page, "<article ", "<footer", pos-200)[0]
557
558 self._parse_thread(page)
559 return (self._parse_post(html),)
560
561
562 class XenforoThreadExtractor(XenforoExtractor):
563 subcategory = "thread"
564 pattern = (BASE_PATTERN + r"(/(?:index\.php\?)?th(?:reads|ema)"
565 r"/(?:[^/?#]+\.)?\d+)(?:/page-(\d+))?")
566 example = "https://simpcity.cr/threads/TITLE.12345/"
567
568 def posts(self):
569 path = self.groups[-2]
570 pnum = self.groups[-1]
571
572 if (order := self.config("order-posts")) and \
573 order[0] not in {"d", "r"}:
574 params = "?order=reaction_score" if order[0] == "s" else ""
575 pages = self._pagination(path, pnum, params=params)
576 reverse = False
577 elif order == "reaction":
578 pages = self._pagination(
579 path, pnum, params="?order=reaction_score")
580 reverse = False
581 else:
582 pages = self._pagination_reverse(path, pnum)
583 reverse = True
584
585 for page in pages:
586 if "thread" not in self.kwdict:
587 self._parse_thread(page)
588 posts = text.extract_iter(page, "<article ", "<footer")
589 if reverse:
590 posts = list(posts)
591 posts.reverse()
592 for html in posts:
593 yield self._parse_post(html)
594
595
596 class XenforoForumExtractor(XenforoExtractor):
597 subcategory = "forum"
598 pattern = (BASE_PATTERN + r"(/(?:index\.php\?)?forums?"
599 r"/(?:[^/?#]+\.)?[^/?#]+)(?:/page-(\d+))?")
600 example = "https://simpcity.cr/forums/TITLE.123/"
601
602 def items(self):
603 extract_threads = text.re(
604 r'(/(?:index\.php\?)?threads/[^"]+)"[^>]+data-xf-init=').findall
605
606 data = {"_extractor": XenforoThreadExtractor}
607 path = self.groups[-2]
608 pnum = self.groups[-1]
609 for page in self._pagination(path, pnum):
610 for path in extract_threads(page):
611 yield Message.Queue, self.root + text.unquote(path), data
612
613
614 class XenforoMediaUserExtractor(XenforoExtractor):
615 subcategory = "media-user"
616 directory_fmt = ("{category}", "Media", "{author_slug}")
617 filename_fmt = "{filename}.{extension}"
618 archive_fmt = "{id}"
619 pattern = (BASE_PATTERN + r"(/(?:index\.php\?)?)me(?:"
620 r"dia/users/([^/?#]+)(?:/page-(\d+))?|"
621 r"mbers/([^/?#]+)/#xfmgMedia)")
622 example = "https://simpcity.cr/media/users/USER.123/"
623
624 def items(self):
625 groups = self.groups
626
627 user = groups[-3]
628 if user is None:
629 user = groups[-1]
630 pnum = None
631 else:
632 pnum = groups[-2]
633
634 if not self.config("metadata"):
635 self.kwdict["author_slug"], _, self.kwdict["author_id"] = \
636 user.rpartition(".")
637
638 return self.items_media(f"{groups[-4]}media/users/{user}", pnum)
639
640
641 class XenforoMediaAlbumExtractor(XenforoExtractor):
642 subcategory = "media-album"
643 directory_fmt = ("{category}", "Media", "Albums",
644 "{album[slug]} ({album[id]})")
645 filename_fmt = "{filename}.{extension}"
646 archive_fmt = "{id}"
647 pattern = (BASE_PATTERN + r"(/(?:index\.php\?)?"
648 r"media/albums/([^/?#]+))(?:/page-(\d+))?")
649 example = "https://simpcity.cr/media/albums/ALBUM.123/"
650
651 def items(self):
652 return self.items_media(
653 self.groups[-3], self.groups[-1], self._parse_album)
654
655
656 class XenforoMediaCategoryExtractor(XenforoExtractor):
657 subcategory = "media-category"
658 directory_fmt = ("{category}", "Media", "Category", "{mcategory}")
659 filename_fmt = "{filename}.{extension}"
660 archive_fmt = "{id}"
661 pattern = (BASE_PATTERN + r"(/(?:index\.php\?)?"
662 r"media/categories/([^/?#]+))(?:/page-(\d+))?")
663 example = "https://simpcity.cr/media/categories/CATEGORY.123/"
664
665 def items(self):
666 self.kwdict["mcategory"], _, self.kwdict["mcategory_id"] = \
667 self.groups[-2].rpartition(".")
668 return self.items_media(self.groups[-3], self.groups[-1])
669
670
671 class XenforoMediaItemExtractor(XenforoExtractor):
672 subcategory = "media-item"
673 directory_fmt = ("{category}", "Media", "{author_slug|''}")
674 filename_fmt = "{filename}.{extension}"
675 archive_fmt = "{id}"
676 pattern = BASE_PATTERN + r"(/(?:index\.php\?)?media/((?:[^/?#]+\.)\d+))"
677 example = "https://simpcity.cr/media/NAME.123/"
678
679 def items(self):
680 url = f"{self.root}{self.groups[-2]}/"
681 url, media = (self._extract_media_ex if self.config("metadata") else
682 self._extract_media)(url, self.groups[-1])
683 yield Message.Directory, "", media
684 yield Message.Url, url, media
685
686
687 class XenforoProfileExtractor(XenforoExtractor):
688 subcategory = "profile"
689 directory_fmt = ("{category}", "Profiles", "{profile[name]}")
690 archive_fmt = "{id}"
691 pattern = (BASE_PATTERN + r"(/(?:index\.php\?)?"
692 r"members/[^/?#]+)(?:/page-(\d+))?")
693 example = "https://simpcity.cr/members/USER.123/"
694
695 def posts(self):
696 path = self.groups[-2]
697 pnum = self.groups[-1]
698
699 if (order := self.config("order-posts")) and \
700 order[0] in {"d", "r"}:
701 pages = self._pagination_reverse(path, pnum)
702 reverse = True
703 else:
704 pages = self._pagination(path, pnum)
705 reverse = False
706
707 for page in pages:
708 if "profile" not in self.kwdict:
709 self._parse_profile(page)
710 posts = text.extract_iter(page, "<article ", "<footer")
711 if reverse:
712 posts = list(posts)
713 posts.reverse()
714 for html in posts:
715 yield self._parse_post(html)