fix: Member instructables page no longer returns 500 if there are no instructables

Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
Skylar "The Cobra" Widulski 2023-06-10 11:26:21 -04:00
parent 9cf9257554
commit 446132c6fb
Signed by: cobra
GPG Key ID: 4FD8F812083FF6F9
2 changed files with 18 additions and 13 deletions

29
main.py
View File

@ -423,22 +423,25 @@ def route_member_instructables(member):
header = soup.select(".profile-header.profile-header-social")[0]
header_content = member_header(header)
ibles = soup.select("ul.ible-list-items")[0]
ibles = soup.select("ul.ible-list-items")
ible_list = []
for ible in ibles.select("li"):
link = ible.select("div.thumbnail-image")[0].a.get("href")
img = proxy(ible.select("div.thumbnail-image a noscript img")[0].get("src"))
title = ible.select("div.caption-inner a.title")[0].text
if ibles != []:
ibles = ibles[0]
for ible in ibles.select("li"):
link = ible.select("div.thumbnail-image")[0].a.get("href")
img = proxy(ible.select("div.thumbnail-image a noscript img")[0].get("src"))
title = ible.select("div.caption-inner a.title")[0].text
stats = ible.select("div.ible-stats-right-col")[0]
views = 0
if stats.select("span.ible-views") != []:
views = stats.select("span.ible-views")[0].text
favorites = 0
if stats.select("span.ible-favorites") != []:
favorites = stats.select("span.ible-favorites")[0].text
stats = ible.select("div.ible-stats-right-col")[0]
views = 0
if stats.select("span.ible-views") != []:
views = stats.select("span.ible-views")[0].text
favorites = 0
if stats.select("span.ible-favorites") != []:
favorites = stats.select("span.ible-favorites")[0].text
ible_list.append([link, img, title, views, favorites])
ible_list.append([link, img, title, views, favorites])
return render_template("member-instructables.html", data=header_content + [ible_list])

View File

@ -24,6 +24,7 @@
{% if data[9] != "" %}
<hr>
{% endif %}
{% if data[10] != [] %}
<h2>{{ data[9] }}</h2>
{% for ible in data[10] %}
<div class="member-list">
@ -35,6 +36,7 @@
{% endfor %}
<p><a href="/member/{{ data[1] }}/instructables/">View all Instructables</a></p>
<br>
{% endif %}
<h2>{{ data[11] }}</h2>
{% for ach in data[12] %}
<div class="member-list">