add settings for enabling/disabling comments, comment avatars, & related vids
This commit is contained in:
parent
2ffc727b51
commit
97545f9b3b
@ -9,6 +9,10 @@ subtitles_mode = 0
|
|||||||
|
|
||||||
# ISO 639 language code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
# ISO 639 language code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
||||||
subtitles_language = "en"
|
subtitles_language = "en"
|
||||||
|
|
||||||
|
enable_related_videos = True
|
||||||
|
enable_comments = True
|
||||||
|
enable_comment_avatars = True
|
||||||
'''
|
'''
|
||||||
exec(default_settings)
|
exec(default_settings)
|
||||||
try:
|
try:
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
grid-row: 1 / span 3;
|
grid-row: 1 / span 3;
|
||||||
align-self: start;
|
align-self: start;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
height:32px;
|
||||||
|
width:32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment address{
|
.comment address{
|
||||||
|
@ -6,11 +6,12 @@ from string import Template
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib
|
import urllib
|
||||||
import html
|
import html
|
||||||
|
import settings
|
||||||
comment_template = Template('''
|
comment_template = Template('''
|
||||||
<div class="comment-container">
|
<div class="comment-container">
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<a class="author-avatar" href="$author_url" title="$author">
|
<a class="author-avatar" href="$author_url" title="$author">
|
||||||
<img class="author-avatar-img" src="$author_avatar">
|
$avatar
|
||||||
</a>
|
</a>
|
||||||
<address>
|
<address>
|
||||||
<a class="author" href="$author_url" title="$author">$author</a>
|
<a class="author" href="$author_url" title="$author">$author</a>
|
||||||
@ -23,6 +24,8 @@ $replies
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
''')
|
''')
|
||||||
|
comment_avatar_template = Template(''' <img class="author-avatar-img" src="$author_avatar">''')
|
||||||
|
|
||||||
reply_link_template = Template('''
|
reply_link_template = Template('''
|
||||||
<a href="$url" class="replies">View replies</a>
|
<a href="$url" class="replies">View replies</a>
|
||||||
''')
|
''')
|
||||||
@ -143,10 +146,17 @@ def get_comments_html(result):
|
|||||||
replies = ''
|
replies = ''
|
||||||
if comment['replies_url']:
|
if comment['replies_url']:
|
||||||
replies = reply_link_template.substitute(url=comment['replies_url'])
|
replies = reply_link_template.substitute(url=comment['replies_url'])
|
||||||
|
if settings.enable_comment_avatars:
|
||||||
|
avatar = comment_avatar_template.substitute(
|
||||||
|
author_url = URL_ORIGIN + comment['author_url'],
|
||||||
|
author_avatar = '/' + comment['author_avatar'],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
avatar = ''
|
||||||
html_result += comment_template.substitute(
|
html_result += comment_template.substitute(
|
||||||
author=html.escape(comment['author']),
|
author=html.escape(comment['author']),
|
||||||
author_url = URL_ORIGIN + comment['author_url'],
|
author_url = URL_ORIGIN + comment['author_url'],
|
||||||
author_avatar = '/' + comment['author_avatar'],
|
avatar = avatar,
|
||||||
likes = str(comment['likes']) + ' likes' if str(comment['likes']) != '0' else '',
|
likes = str(comment['likes']) + ' likes' if str(comment['likes']) != '0' else '',
|
||||||
published = comment['published'],
|
published = comment['published'],
|
||||||
text = format_text_runs(comment['text']),
|
text = format_text_runs(comment['text']),
|
||||||
@ -157,8 +167,10 @@ def get_comments_html(result):
|
|||||||
return html_result, result['ctoken']
|
return html_result, result['ctoken']
|
||||||
|
|
||||||
def video_comments(video_id, sort=0, offset=0, secret_key=''):
|
def video_comments(video_id, sort=0, offset=0, secret_key=''):
|
||||||
|
if settings.enable_comments:
|
||||||
result = parse_comments(request_comments(make_comment_ctoken(video_id, sort, offset, secret_key)))
|
result = parse_comments(request_comments(make_comment_ctoken(video_id, sort, offset, secret_key)))
|
||||||
return get_comments_html(result)
|
return get_comments_html(result)
|
||||||
|
return '', ''
|
||||||
|
|
||||||
more_comments_template = Template('''<a class="page-button more-comments" href="$url">More comments</a>''')
|
more_comments_template = Template('''<a class="page-button more-comments" href="$url">More comments</a>''')
|
||||||
|
|
||||||
|
@ -314,7 +314,10 @@ def get_watch_page(query_string):
|
|||||||
upload_day = info["upload_date"][6:8]
|
upload_day = info["upload_date"][6:8]
|
||||||
upload_date = upload_month + "/" + upload_day + "/" + upload_year
|
upload_date = upload_month + "/" + upload_day + "/" + upload_year
|
||||||
|
|
||||||
|
if settings.enable_related_videos:
|
||||||
related_videos_html = get_related_items_html(info)
|
related_videos_html = get_related_items_html(info)
|
||||||
|
else:
|
||||||
|
related_videos_html = ''
|
||||||
|
|
||||||
page = yt_watch_template.substitute(
|
page = yt_watch_template.substitute(
|
||||||
video_title = html.escape(info["title"]),
|
video_title = html.escape(info["title"]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user