From 8706364d90551cd716fdcc1974be4e5a2a752dd1 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 19 Nov 2018 16:24:21 -0600 Subject: [PATCH] Add support for watchEndpoints in comment templating --- src/invidious/comments.cr | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index f4398b58..5f7b34c0 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -491,8 +491,7 @@ def content_to_comment_html(content) end if run["navigationEndpoint"]? - url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s - if url + if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s url = URI.parse(url) if !url.host || {"m.youtube.com", "www.youtube.com", "youtu.be"}.includes? url.host @@ -502,11 +501,16 @@ def content_to_comment_html(content) url = url.full_path end end - else - url = run["navigationEndpoint"]["commandMetadata"]?.try &.["webCommandMetadata"]["url"].as_s - end - text = %(#{text}) + text = %(#{text}) + elsif watch_endpoint = run["navigationEndpoint"]["watchEndpoint"]? + length_seconds = watch_endpoint["startTimeSeconds"].as_i + video_id = watch_endpoint["videoId"].as_s + + text = %(#{text}) + elsif url = run["navigationEndpoint"]["commandMetadata"]?.try &.["webCommandMetadata"]["url"].as_s + text = %(#{text}) + end end text