mirror of https://github.com/rebane2001/hobune
comments
This commit is contained in:
parent
4cf5f5900a
commit
2a6ddecdc1
|
@ -1,3 +1,3 @@
|
|||
<div class="ui container main">
|
||||
<div class="container">
|
||||
<p>This is an example of a custom page</p>
|
||||
</div>
|
|
@ -33,28 +33,33 @@ def getCommentsHTML(title, videoid):
|
|||
with open(f"{comments_path}/{videoid}.jsonl", "r") as f:
|
||||
header = json.loads(f.readline())
|
||||
# Hacky workaround if you don't use my format of comments (w/header)
|
||||
if not "time_fetched" in header:
|
||||
if "time_fetched" not in header:
|
||||
comments.append(header)
|
||||
header = {"time_fetched": "N/A"}
|
||||
for l in f:
|
||||
comments.append(json.loads(l))
|
||||
except Exception:
|
||||
return False, 0
|
||||
comments_html = f"""<div class="ui container main">
|
||||
<h1 class="ui big header">{title}</h1>
|
||||
<a href="/videos/{videoid}">Back to video page</a> | <a href="/comments/{videoid}.jsonl">Download comments jsonl</a>
|
||||
<h2 class="ui header">Comments (archived {header["time_fetched"][:16].replace("T", " ")})</h2>
|
||||
<div class="comments">\n"""
|
||||
comments_html = ""
|
||||
comments_count = 0
|
||||
total_count = 0
|
||||
for comment in comments:
|
||||
comments_count += 1
|
||||
total_count += 1
|
||||
csnip = comment["snippet"]["topLevelComment"]["snippet"]
|
||||
comment_html = getCommentHTML(csnip)
|
||||
if "replies" in comment:
|
||||
replies = ""
|
||||
for reply in comment["replies"]["comments"][::-1]:
|
||||
total_count += 1
|
||||
replies += f'<div class="reply">{getCommentHTML(reply["snippet"])}</div>\n'
|
||||
comment_html += f"<details><summary>Replies ({len(comment['replies']['comments'])})</summary>\n{replies}</details>"
|
||||
comments_html += f'<div class="comment">{comment_html}</div>\n'
|
||||
comments_html += "</div></div>"
|
||||
comments_html = f"""<div class="container">
|
||||
<h1>{title}</h1>
|
||||
<a href="/videos/{videoid}">Back to video page</a> | <a href="/comments/{videoid}.jsonl">Download comments jsonl</a>
|
||||
<h2>Comments (archived {header["time_fetched"][:16].replace("T", " ")}; {comments_count} top, {total_count} total comments)</h2>
|
||||
<div class="comments">\n
|
||||
{comments_html}
|
||||
</div></div>"""
|
||||
return comments_html, comments_count
|
|
@ -46,7 +46,7 @@ def create_video_pages(config, channels, templates, html_ext):
|
|||
with open(os.path.join(config.output_path, f"comments/{no_traverse(v['id'])}.html"), "w") as f:
|
||||
f.write(templates["base"].format(title=html.escape(v['title'] + ' - Comments'), meta=page_meta,
|
||||
content=comments_html))
|
||||
comments_link = f'<p class="comments"><a href="/comments/{v["id"]}">View comments ({comments_count})</a></p>'
|
||||
comments_link = f'<p class="comments"><a href="/comments/{v["id"]}{html_ext}">View comments ({comments_count})</a></p>'
|
||||
# Set mp4 path
|
||||
mp4path = f"{os.path.join(config.files_web_path + root[len(config.files_path):], base)}.mp4"
|
||||
for ext in ["mp4", "webm", "mkv"]:
|
||||
|
|
|
@ -394,7 +394,7 @@ a {
|
|||
}
|
||||
|
||||
.comment p {
|
||||
margin-bottom: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.comment .reply {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="ui container main">
|
||||
<div class="container">
|
||||
<br>
|
||||
<div class="ui">
|
||||
<video controls poster="{thumbnail}" class="rounded video">
|
||||
|
|
Loading…
Reference in New Issue