diff options
| -rw-r--r-- | assets/css/default.css | 6 | ||||
| -rw-r--r-- | src/invidious.cr | 16 | ||||
| -rw-r--r-- | src/invidious/helpers/utils.cr | 6 | ||||
| -rw-r--r-- | src/invidious/search.cr | 9 |
4 files changed, 31 insertions, 6 deletions
diff --git a/assets/css/default.css b/assets/css/default.css index 2769fa4b..0dfce01a 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -185,3 +185,9 @@ div { .video-js .vjs-duration { display: block; } + +.video-js .vjs-time-divider { + min-width: 0px; + padding-left: 0px; + padding-right: 0px; +} diff --git a/src/invidious.cr b/src/invidious.cr index a9601256..30a27058 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1778,7 +1778,10 @@ get "/api/v1/comments/:id" do |env| content_text ||= node_comment["contentText"]["runs"].as_a.map { |comment| comment["text"] } .join("").rchop('\ufeff') - json.field "author", node_comment["authorText"]["simpleText"] + author = node_comment["authorText"]?.try &.["simpleText"] + author ||= "" + + json.field "author", author json.field "authorThumbnails" do json.array do node_comment["authorThumbnail"]["thumbnails"].as_a.each do |thumbnail| @@ -1790,8 +1793,15 @@ get "/api/v1/comments/:id" do |env| end end end - json.field "authorId", node_comment["authorEndpoint"]["browseEndpoint"]["browseId"] - json.field "authorUrl", node_comment["authorEndpoint"]["browseEndpoint"]["canonicalBaseUrl"] + + if node_comment["authorEndpoint"]? + json.field "authorId", node_comment["authorEndpoint"]["browseEndpoint"]["browseId"] + json.field "authorUrl", node_comment["authorEndpoint"]["browseEndpoint"]["canonicalBaseUrl"] + else + json.field "authorId", "" + json.field "authorUrl", "" + end + json.field "content", content_text json.field "published", node_comment["publishedTimeText"]["runs"][0]["text"] json.field "likeCount", node_comment["likeCount"] diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 3a9003da..db49bab0 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -73,6 +73,8 @@ def decode_date(string : String) delta = date[0].to_i case date[1] + when .includes? "second" + delta = delta.seconds when .includes? "minute" delta = delta.minutes when .includes? "hour" @@ -105,8 +107,10 @@ def recode_date(time : Time) span = {span.total_days, "day"} elsif span.total_minutes > 60.0 span = {span.total_hours, "hour"} + elsif span.total_seconds > 60.0 + span = {span.total_minutes, "minute"} else - span = {0, "units"} + span = {span.total_seconds, "second"} end span = {span[0].to_i, span[1]} diff --git a/src/invidious/search.cr b/src/invidious/search.cr index 3d7c4ba4..e66d76fd 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -57,8 +57,13 @@ def search(query, page = 1, search_params = build_search_params(content_type: "v next end - view_count = metadata[0].content.lchop("Streamed ").split(" ")[0].delete(",").to_i64 - published = Time.now + if metadata[0].content.starts_with? "Starts" + view_count = 0_i64 + published = Time.epoch(metadata[0].xpath_node(%q(.//span)).not_nil!["data-timestamp"].to_i64) + else + view_count = metadata[0].content.lchop("Streamed ").split(" ")[0].delete(",").to_i64 + published = Time.now + end else # Skip movies if metadata[0].content.includes? "ยท" |
