From 1f4d7cc9586bc0fbb19936efe5dad32109dfb952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Wed, 30 Dec 2020 16:17:48 -0500 Subject: General theme: fix syntax W3C markup and add improve 'Published' date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jesús --- youtube/static/js/comments.js | 4 ++-- youtube/templates/comments.html | 4 ++-- youtube/templates/watch.html | 2 +- youtube/util.py | 7 +++++++ youtube/watch.py | 2 ++ 5 files changed, 14 insertions(+), 5 deletions(-) (limited to 'youtube') diff --git a/youtube/static/js/comments.js b/youtube/static/js/comments.js index ccf5e39..fdd089f 100644 --- a/youtube/static/js/comments.js +++ b/youtube/static/js/comments.js @@ -2,7 +2,7 @@ function onClickReplies(e) { var details = e.target.parentElement; // e.preventDefault(); console.log("loading replies .."); - doXhr(details.getAttribute("src") + "&slim=1", (html) => { + doXhr(details.getAttribute("data-src") + "&slim=1", (html) => { var div = details.querySelector(".comment_page"); div.innerHTML = html; }); @@ -14,7 +14,7 @@ window.addEventListener('DOMContentLoaded', function() { details.addEventListener('click', onClickReplies); details.addEventListener('auxclick', (e) => { if (e.target.parentElement !== details) return; - if (e.button == 1) window.open(details.getAttribute("src")); + if (e.button == 1) window.open(details.getAttribute("data-src")); }); }); }); diff --git a/youtube/templates/comments.html b/youtube/templates/comments.html index a128b44..ceb31b8 100644 --- a/youtube/templates/comments.html +++ b/youtube/templates/comments.html @@ -12,7 +12,7 @@ {{ comment['author'] }} {% if timestamp_links %} @@ -24,7 +24,7 @@ {{ comment['likes_text'] if comment['like_count'] else ''}}
{% if settings.use_comments_js and comment['reply_count'] %} -
+
{{ comment['view_replies_text'] }} Open in new tab
loading..
diff --git a/youtube/templates/watch.html b/youtube/templates/watch.html index 1b47e57..70f5692 100644 --- a/youtube/templates/watch.html +++ b/youtube/templates/watch.html @@ -71,7 +71,7 @@
Uploaded by {{ uploader }}
{{ view_count }} views - + {{ like_count }} likes {{ dislike_count }} dislikes
diff --git a/youtube/util.py b/youtube/util.py index 3d5546a..fd6ca1a 100644 --- a/youtube/util.py +++ b/youtube/util.py @@ -1,3 +1,4 @@ +from datetime import datetime import settings import socks import sockshandler @@ -607,3 +608,9 @@ def strip_non_ascii(string): ''' Returns the string without non ASCII characters''' stripped = (c for c in string if 0 < ord(c) < 127) return ''.join(stripped) + + +def time_utc_isoformat(string): + t = datetime.strptime(string, '%Y-%m-%d') + t = t.astimezone().isoformat() + return t diff --git a/youtube/watch.py b/youtube/watch.py index a7d712a..9e0ddf7 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -1,6 +1,7 @@ import youtube from youtube import yt_app from youtube import util, comments, local_playlist, yt_data_extract +from youtube.util import time_utc_isoformat import settings from flask import request @@ -491,6 +492,7 @@ def get_watch_page(video_id=None): header_playlist_names = local_playlist.get_playlist_names(), uploader_channel_url = ('/' + info['author_url']) if info['author_url'] else '', time_published = info['time_published'], + time_published_utc=time_utc_isoformat(info['time_published']), view_count = (lambda x: '{:,}'.format(x) if x is not None else "")(info.get("view_count", None)), like_count = (lambda x: '{:,}'.format(x) if x is not None else "")(info.get("like_count", None)), dislike_count = (lambda x: '{:,}'.format(x) if x is not None else "")(info.get("dislike_count", None)), -- cgit v1.2.3