aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/__init__.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2020-12-29 17:32:40 -0500
committerJesús <heckyel@hyperbola.info>2020-12-29 17:32:40 -0500
commit7c046d82eec7a666a311b48fa2a243b9b16a3365 (patch)
treed9c5f968a0efa23ffad1f3b6970cb596a2a31347 /youtube/__init__.py
parent0f78e73e80dd1801bbcadb31e2bd3de11b68b267 (diff)
downloadyt-local-7c046d82eec7a666a311b48fa2a243b9b16a3365.tar.lz
yt-local-7c046d82eec7a666a311b48fa2a243b9b16a3365.tar.xz
yt-local-7c046d82eec7a666a311b48fa2a243b9b16a3365.zip
General theme: Fix script generate for timestamp
Also add support librejs
Diffstat (limited to 'youtube/__init__.py')
-rw-r--r--youtube/__init__.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/youtube/__init__.py b/youtube/__init__.py
index ff5c984..3c85d47 100644
--- a/youtube/__init__.py
+++ b/youtube/__init__.py
@@ -62,10 +62,26 @@ def timestamp_replacement(match):
for part in match.group(0).split(':'):
time_seconds = 60*time_seconds + int(part)
return (
- '<a href="#" onclick="document.getElementById(\'js-video-player\').currentTime='
- + str(time_seconds)
- + '">' + match.group(0)
- + '</a>'
+ """
+ <a href="#" id="timestamp%s">%s</a>
+ <script>
+ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
+ (function main() {
+ 'use strict';
+ const player = document.getElementById('js-video-player');
+ const a = document.getElementById('timestamp%s');
+ a.addEventListener('click', function(event) {
+ player.currentTime = %s
+ });
+ }());
+ // @license-end
+ </script>
+ """ % (
+ str(time_seconds),
+ match.group(0),
+ str(time_seconds),
+ str(time_seconds)
+ )
)