aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2020-12-30 16:17:48 -0500
committerJesús <heckyel@hyperbola.info>2020-12-30 16:52:26 -0500
commit1f4d7cc9586bc0fbb19936efe5dad32109dfb952 (patch)
treeec25c1c4f7fc36b2d83b332a7bdad011b84126d3 /youtube
parent056c3be3f2ab9a19d8b2c38396826aaad9d4081d (diff)
downloadyt-local-1f4d7cc9586bc0fbb19936efe5dad32109dfb952.tar.lz
yt-local-1f4d7cc9586bc0fbb19936efe5dad32109dfb952.tar.xz
yt-local-1f4d7cc9586bc0fbb19936efe5dad32109dfb952.zip
General theme: fix syntax W3C markup and add improve 'Published' date
Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube')
-rw-r--r--youtube/static/js/comments.js4
-rw-r--r--youtube/templates/comments.html4
-rw-r--r--youtube/templates/watch.html2
-rw-r--r--youtube/util.py7
-rw-r--r--youtube/watch.py2
5 files changed, 14 insertions, 5 deletions
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 @@
<a class="author" href="{{ comment['author_url'] }}" title="{{ comment['author'] }}">{{ comment['author'] }}</a>
</address>
<a class="permalink" href="{{ comment['permalink'] }}" title="permalink">
- <time datetime="2012-01-14T15:23:44+02:00">{{ comment['time_published'] }}</time>
+ <span>{{ comment['time_published'] }}</span>
</a>
{% if timestamp_links %}
@@ -24,7 +24,7 @@
<span class="comment-likes">{{ comment['likes_text'] if comment['like_count'] else ''}}</span>
<div class="button-row">
{% if settings.use_comments_js and comment['reply_count'] %}
- <details class="replies" src="{{ comment['replies_url'] }}">
+ <details class="replies" data-src="{{ comment['replies_url'] }}">
<summary>{{ comment['view_replies_text'] }}</summary>
<a href="{{ comment['replies_url'] }}" class="replies-open-new-tab" target="_blank">Open in new tab</a>
<div class="comment_page">loading..</div>
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 @@
<address class="v-uploaded">Uploaded by <a href="{{ uploader_channel_url }}">{{ uploader }}</a></address>
<span class="v-views">{{ view_count }} views</span>
- <time class="v-published" datetime="$upload_date">Published on {{ time_published }}</time>
+ <time class="v-published" datetime="{{ time_published_utc }}">Published on {{ time_published }}</time>
<span class="v-likes-dislikes">{{ like_count }} likes {{ dislike_count }} dislikes</span>
<div class="external-player-controls">
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)),