[bellazon] fix errors when handling guest users (#8397)
This commit is contained in:
@@ -130,7 +130,7 @@ class BellazonExtractor(Extractor):
|
||||
author = schema["author"]
|
||||
stats = schema["interactionStatistic"]
|
||||
url_t = schema["url"]
|
||||
url_a = author["url"]
|
||||
url_a = author.get("url") or ""
|
||||
|
||||
path = text.split_html(text.extr(
|
||||
page, '<nav class="ipsBreadcrumb', "</nav>"))[2:-1]
|
||||
@@ -151,8 +151,12 @@ class BellazonExtractor(Extractor):
|
||||
|
||||
thread["id"], _, thread["slug"] = \
|
||||
url_t.rsplit("/", 2)[1].partition("-")
|
||||
thread["author_id"], _, thread["author_slug"] = \
|
||||
url_a.rsplit("/", 2)[1].partition("-")
|
||||
|
||||
if url_a:
|
||||
thread["author_id"], _, thread["author_slug"] = \
|
||||
url_a.rsplit("/", 2)[1].partition("-")
|
||||
else:
|
||||
thread["author_id"] = thread["author_slug"] = ""
|
||||
|
||||
return thread
|
||||
|
||||
@@ -169,8 +173,11 @@ class BellazonExtractor(Extractor):
|
||||
if (pos := post["content"].find(">")) >= 0:
|
||||
post["content"] = post["content"][pos+1:].strip()
|
||||
|
||||
post["author_id"], _, post["author_slug"] = \
|
||||
post["author_url"].rsplit("/", 2)[1].partition("-")
|
||||
if url_a := post["author_url"]:
|
||||
post["author_id"], _, post["author_slug"] = \
|
||||
url_a.rsplit("/", 2)[1].partition("-")
|
||||
else:
|
||||
post["author_id"] = post["author_slug"] = ""
|
||||
|
||||
return post
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
|
||||
__version__ = "1.30.10"
|
||||
__version__ = "1.31.0-dev"
|
||||
__variant__ = None
|
||||
|
||||
@@ -307,6 +307,49 @@ __tests__ = (
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.bellazon.com/main/topic/56-candids/",
|
||||
"#comment" : "'Guest' author (#8397)",
|
||||
"#class" : bellazon.BellazonThreadExtractor,
|
||||
"#options" : {"order-posts": "asc"},
|
||||
"#range" : "1",
|
||||
"#results" : (
|
||||
"https://www.bellazon.com/main/uploads/monthly_11_2004/post-0-0-1593851439-26962.jpg",
|
||||
),
|
||||
|
||||
"post" : {
|
||||
"author_id" : "",
|
||||
"author_slug": "",
|
||||
"author_url" : "",
|
||||
"content" : """<a href="https://www.bellazon.com/main/uploads/monthly_11_2004/post-0-0-1593851439-26962.jpg" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="292" src="https://www.bellazon.com/main/uploads/monthly_11_2004/post-0-0-1593851439-26962_thumb.jpg" class="ipsImage ipsImage_thumbnailed" alt="sss.jpg" loading="lazy"></a>""",
|
||||
"count" : 1,
|
||||
"date" : "dt:2004-11-21 03:09:51",
|
||||
"id" : "292",
|
||||
},
|
||||
"thread" : {
|
||||
"author" : "Guest",
|
||||
"author_id" : "",
|
||||
"author_slug" : "",
|
||||
"author_url" : "",
|
||||
"date" : "dt:2004-11-21 01:44:59",
|
||||
"date_updated": "type:datetime",
|
||||
"description" : "Welcome to the Alessandra Ambrosio Candids gallery. Please only post candid, unposed, off-guard, or funny images in this thread.",
|
||||
"id" : "56",
|
||||
"posts" : range(13_000, 30_000),
|
||||
"section" : "Alessandra Ambrosio",
|
||||
"slug" : "candids",
|
||||
"title" : "Candids",
|
||||
"url" : "https://www.bellazon.com/main/topic/56-candids/",
|
||||
"views" : range(8_000_000, 10_000_000),
|
||||
"path" : [
|
||||
"Females",
|
||||
"Female Fashion Models",
|
||||
"Alessandra Ambrosio",
|
||||
"Candids",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.bellazon.com/main/forum/3-actresses/",
|
||||
"#class" : bellazon.BellazonForumExtractor,
|
||||
|
||||
Reference in New Issue
Block a user