mirror of
https://github.com/iv-org/invidious.git
synced 2024-09-19 02:05:45 +05:30
Compare commits
42 Commits
b8fd37a78d
...
eceec72d3a
Author | SHA1 | Date | |
---|---|---|---|
|
eceec72d3a | ||
|
325561e755 | ||
|
09bf09befe | ||
|
7fdbda612f | ||
|
4f60feee17 | ||
|
733bd27a5c | ||
|
1ff0775f4b | ||
|
e62d4db752 | ||
|
8b1da2001e | ||
|
5a12005b48 | ||
|
911dad6935 | ||
|
3bac467a8c | ||
|
248df785d7 | ||
|
e82c965e89 | ||
|
04ca64691b | ||
|
5957523624 | ||
|
629599f940 | ||
|
31ad708206 | ||
|
3b773c4f77 | ||
|
57e606cb43 | ||
|
f57aac5815 | ||
|
71a821a7e6 | ||
|
e0d0dbde3c | ||
|
90fcf80a8d | ||
|
b90cf286fc | ||
|
499aed37dd | ||
|
bfbfec2b16 | ||
|
8427074964 | ||
|
249886ea42 | ||
|
9311724e69 | ||
|
41f82f189b | ||
|
3601d42716 | ||
|
9665b82fb5 | ||
|
7caa9da988 | ||
|
a455df4a6e | ||
|
83953d7fc2 | ||
|
b95d5604f8 | ||
|
561ce9e949 | ||
|
38063bbd23 | ||
|
2e590ee67c | ||
|
ab2e7a0600 | ||
|
c251c66748 |
@ -58,6 +58,11 @@ body {
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.simulated_a {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Channel page
|
* Channel page
|
||||||
@ -499,7 +504,9 @@ span > select {
|
|||||||
.light-theme a:active,
|
.light-theme a:active,
|
||||||
.light-theme summary:hover,
|
.light-theme summary:hover,
|
||||||
.light-theme a:focus,
|
.light-theme a:focus,
|
||||||
.light-theme summary:focus {
|
.light-theme summary:focus,
|
||||||
|
.light-theme .simulated_a:hover,
|
||||||
|
.light-theme .simulated_a:active {
|
||||||
color: #075A9E !important;
|
color: #075A9E !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +524,7 @@ span > select {
|
|||||||
background-color: #fff2;
|
background-color: #fff2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.light-theme a {
|
.light-theme a, .light-theme .simulated_a {
|
||||||
color: #335d7a;
|
color: #335d7a;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
@ -538,7 +545,9 @@ span > select {
|
|||||||
.no-theme a:active,
|
.no-theme a:active,
|
||||||
.no-theme summary:hover,
|
.no-theme summary:hover,
|
||||||
.no-theme a:focus,
|
.no-theme a:focus,
|
||||||
.no-theme summary:focus {
|
.no-theme summary:focus,
|
||||||
|
.no-theme .simulated_a:hover,
|
||||||
|
.no-theme .simulated_a:active {
|
||||||
color: #075A9E !important;
|
color: #075A9E !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +565,7 @@ span > select {
|
|||||||
background-color: #fff2;
|
background-color: #fff2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-theme a {
|
.no-theme a, .no-theme .simulated_a{
|
||||||
color: #335d7a;
|
color: #335d7a;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
@ -590,7 +599,9 @@ span > select {
|
|||||||
.dark-theme a:active,
|
.dark-theme a:active,
|
||||||
.dark-theme summary:hover,
|
.dark-theme summary:hover,
|
||||||
.dark-theme a:focus,
|
.dark-theme a:focus,
|
||||||
.dark-theme summary:focus {
|
.dark-theme summary:focus,
|
||||||
|
.dark-theme .simulated_a:hover,
|
||||||
|
.dark-theme .simulated_a:active {
|
||||||
color: rgb(0, 182, 240);
|
color: rgb(0, 182, 240);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +619,7 @@ span > select {
|
|||||||
color: #ddd;
|
color: #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-theme a {
|
.dark-theme a, .dark-theme .simulated_a {
|
||||||
color: #adadad;
|
color: #adadad;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
@ -644,7 +655,9 @@ body.dark-theme {
|
|||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
.no-theme a:hover,
|
.no-theme a:hover,
|
||||||
.no-theme a:active,
|
.no-theme a:active,
|
||||||
.no-theme a:focus {
|
.no-theme a:focus,
|
||||||
|
.no-theme .simulated_a:hover,
|
||||||
|
.no-theme .simulated_a:active {
|
||||||
color: rgb(0, 182, 240);
|
color: rgb(0, 182, 240);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,7 +675,7 @@ body.dark-theme {
|
|||||||
color: #ddd;
|
color: #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-theme a {
|
.no-theme a, .no-theme .simulated_a{
|
||||||
color: #adadad;
|
color: #adadad;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
@ -799,3 +812,7 @@ h1, h2, h3, h4, h5, p,
|
|||||||
#download_widget {
|
#download_widget {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#comments-turned-off-on-video-message > p, #comments-disabled-message > p {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
@ -68,7 +68,24 @@ function get_youtube_comments() {
|
|||||||
url += '&ucid=' + video_data.ucid
|
url += '&ucid=' + video_data.ucid
|
||||||
}
|
}
|
||||||
|
|
||||||
var onNon200 = function (xhr) { comments.innerHTML = fallback; };
|
var onNon200 = function (xhr) {
|
||||||
|
if (!video_data.comments_enabled) {
|
||||||
|
comments.innerHTML = `
|
||||||
|
<div id="comments-turned-off-on-video-message" class="h-box v-box">
|
||||||
|
<p><b>${video_data.comments_youtube_disabled_text}</b></p>
|
||||||
|
|
||||||
|
<p><b><button href="javascript:void(0)" data-comments="reddit" id="try-reddit-comments-link" class="simulated_a">
|
||||||
|
${video_data.comments_youtube_disabled_try_reddit}
|
||||||
|
</button></b></p>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
document.getElementById("try-reddit-comments-link").onclick = swap_comments;
|
||||||
|
} else {
|
||||||
|
comments.innerHTML = fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
if (video_data.params.comments[1] === 'youtube')
|
if (video_data.params.comments[1] === 'youtube')
|
||||||
onNon200 = function (xhr) {};
|
onNon200 = function (xhr) {};
|
||||||
|
|
||||||
|
@ -351,7 +351,12 @@ if (video_data.params.save_player_pos) {
|
|||||||
const rememberedTime = get_video_time();
|
const rememberedTime = get_video_time();
|
||||||
let lastUpdated = 0;
|
let lastUpdated = 0;
|
||||||
|
|
||||||
if(!hasTimeParam) set_seconds_after_start(rememberedTime);
|
if(!hasTimeParam) {
|
||||||
|
if (rememberedTime >= video_data.length_seconds - 20)
|
||||||
|
set_seconds_after_start(0);
|
||||||
|
else
|
||||||
|
set_seconds_after_start(rememberedTime);
|
||||||
|
}
|
||||||
|
|
||||||
player.on('timeupdate', function () {
|
player.on('timeupdate', function () {
|
||||||
const raw = player.currentTime();
|
const raw = player.currentTime();
|
||||||
|
@ -178,6 +178,10 @@ addEventListener('load', function (e) {
|
|||||||
if (video_data.plid)
|
if (video_data.plid)
|
||||||
get_playlist(video_data.plid);
|
get_playlist(video_data.plid);
|
||||||
|
|
||||||
|
if (!video_data.comments_enabled && video_data.params.comments.includes("youtube")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (video_data.params.comments[0] === 'youtube') {
|
if (video_data.params.comments[0] === 'youtube') {
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
} else if (video_data.params.comments[0] === 'reddit') {
|
} else if (video_data.params.comments[0] === 'reddit') {
|
||||||
@ -186,8 +190,7 @@ addEventListener('load', function (e) {
|
|||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
} else if (video_data.params.comments[1] === 'reddit') {
|
} else if (video_data.params.comments[1] === 'reddit') {
|
||||||
get_reddit_comments();
|
get_reddit_comments();
|
||||||
} else {
|
|
||||||
var comments = document.getElementById('comments');
|
|
||||||
comments.innerHTML = '';
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById("try-reddit-comments-link").onclick = swap_comments;
|
||||||
|
@ -218,6 +218,10 @@
|
|||||||
"View Reddit comments": "View Reddit comments",
|
"View Reddit comments": "View Reddit comments",
|
||||||
"Hide replies": "Hide replies",
|
"Hide replies": "Hide replies",
|
||||||
"Show replies": "Show replies",
|
"Show replies": "Show replies",
|
||||||
|
"comments_youtube_disabled_text": "Youtube comments are disabled on this video",
|
||||||
|
"comments_youtube_disabled_try_reddit": "Try reddit comments?",
|
||||||
|
"comments_invidious_disabled_text": "Comments are hidden as per user preferences",
|
||||||
|
"comments_youtube_disabled_try_reddit_no_js": "Hi! Looks like you have JavaScript turned off. Although the uploader has disabled YouTube comments you can still click here to try and view Reddit comments, keep in mind they may take a bit longer to load.",
|
||||||
"Incorrect password": "Incorrect password",
|
"Incorrect password": "Incorrect password",
|
||||||
"Wrong answer": "Wrong answer",
|
"Wrong answer": "Wrong answer",
|
||||||
"Erroneous CAPTCHA": "Erroneous CAPTCHA",
|
"Erroneous CAPTCHA": "Erroneous CAPTCHA",
|
||||||
|
@ -67,7 +67,7 @@ Spectator.describe "parse_video_info" do
|
|||||||
# Video metadata
|
# Video metadata
|
||||||
|
|
||||||
expect(info["genre"].as_s).to eq("Entertainment")
|
expect(info["genre"].as_s).to eq("Entertainment")
|
||||||
expect(info["genreUcid"].as_s).to be_empty
|
expect(info["genreUcid"].as_s?).to be_nil
|
||||||
expect(info["license"].as_s).to be_empty
|
expect(info["license"].as_s).to be_empty
|
||||||
|
|
||||||
# Author infos
|
# Author infos
|
||||||
@ -151,7 +151,7 @@ Spectator.describe "parse_video_info" do
|
|||||||
# Video metadata
|
# Video metadata
|
||||||
|
|
||||||
expect(info["genre"].as_s).to eq("Music")
|
expect(info["genre"].as_s).to eq("Music")
|
||||||
expect(info["genreUcid"].as_s).to be_empty
|
expect(info["genreUcid"].as_s?).to be_nil
|
||||||
expect(info["license"].as_s).to be_empty
|
expect(info["license"].as_s).to be_empty
|
||||||
|
|
||||||
# Author infos
|
# Author infos
|
||||||
|
@ -94,7 +94,7 @@ Spectator.describe "parse_video_info" do
|
|||||||
# Video metadata
|
# Video metadata
|
||||||
|
|
||||||
expect(info["genre"].as_s).to eq("Entertainment")
|
expect(info["genre"].as_s).to eq("Entertainment")
|
||||||
expect(info["genreUcid"].as_s).to be_empty
|
expect(info["genreUcid"].as_s?).to be_nil
|
||||||
expect(info["license"].as_s).to be_empty
|
expect(info["license"].as_s).to be_empty
|
||||||
|
|
||||||
# Author infos
|
# Author infos
|
||||||
|
@ -72,6 +72,7 @@ def get_about_info(ucid, locale) : AboutChannel
|
|||||||
|
|
||||||
# Raises a KeyError on failure.
|
# Raises a KeyError on failure.
|
||||||
banners = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
|
banners = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
|
||||||
|
banners ||= initdata.dig?("header", "pageHeaderRenderer", "content", "pageHeaderViewModel", "banner", "imageBannerViewModel", "image", "sources")
|
||||||
banner = banners.try &.[-1]?.try &.["url"].as_s?
|
banner = banners.try &.[-1]?.try &.["url"].as_s?
|
||||||
|
|
||||||
# if banner.includes? "channels/c4/default_banner"
|
# if banner.includes? "channels/c4/default_banner"
|
||||||
@ -147,9 +148,17 @@ def get_about_info(ucid, locale) : AboutChannel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sub_count = initdata
|
sub_count = 0
|
||||||
.dig?("header", "c4TabbedHeaderRenderer", "subscriberCountText", "simpleText").try &.as_s?
|
|
||||||
.try { |text| short_text_to_number(text.split(" ")[0]).to_i32 } || 0
|
if (metadata_rows = initdata.dig?("header", "pageHeaderRenderer", "content", "pageHeaderViewModel", "metadata", "contentMetadataViewModel", "metadataRows").try &.as_a)
|
||||||
|
metadata_rows.each do |row|
|
||||||
|
metadata_part = row.dig?("metadataParts").try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("subscribers") }
|
||||||
|
if !metadata_part.nil?
|
||||||
|
sub_count = short_text_to_number(metadata_part.dig("text", "content").as_s.split(" ")[0]).to_i32
|
||||||
|
end
|
||||||
|
break if sub_count != 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
AboutChannel.new(
|
AboutChannel.new(
|
||||||
ucid: ucid,
|
ucid: ucid,
|
||||||
|
@ -11,11 +11,12 @@ module Invidious::HttpServer
|
|||||||
params = url.query_params
|
params = url.query_params
|
||||||
params["host"] = url.host.not_nil! # Should never be nil, in theory
|
params["host"] = url.host.not_nil! # Should never be nil, in theory
|
||||||
params["region"] = region if !region.nil?
|
params["region"] = region if !region.nil?
|
||||||
|
url.query_params = params
|
||||||
|
|
||||||
if absolute
|
if absolute
|
||||||
return "#{HOST_URL}#{url.request_target}?#{params}"
|
return "#{HOST_URL}#{url.request_target}"
|
||||||
else
|
else
|
||||||
return "#{url.request_target}?#{params}"
|
return url.request_target
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,25 +114,31 @@ module Invidious::JSONify::APIv1
|
|||||||
|
|
||||||
json.field "projectionType", fmt["projectionType"]
|
json.field "projectionType", fmt["projectionType"]
|
||||||
|
|
||||||
if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"])
|
height = fmt["height"]?.try &.as_i
|
||||||
fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30
|
width = fmt["width"]?.try &.as_i
|
||||||
|
|
||||||
|
fps = fmt["fps"]?.try &.as_i
|
||||||
|
|
||||||
|
if fps
|
||||||
json.field "fps", fps
|
json.field "fps", fps
|
||||||
|
end
|
||||||
|
|
||||||
|
if height && width
|
||||||
|
json.field "size", "#{width}x#{height}"
|
||||||
|
json.field "resolution", "#{height}p"
|
||||||
|
|
||||||
|
quality_label = "#{width > height ? height : width}p"
|
||||||
|
|
||||||
|
if fps && fps > 30
|
||||||
|
quality_label += fps.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
json.field "qualityLabel", quality_label
|
||||||
|
end
|
||||||
|
|
||||||
|
if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"])
|
||||||
json.field "container", fmt_info["ext"]
|
json.field "container", fmt_info["ext"]
|
||||||
json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"]
|
json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"]
|
||||||
|
|
||||||
if fmt_info["height"]?
|
|
||||||
json.field "resolution", "#{fmt_info["height"]}p"
|
|
||||||
|
|
||||||
quality_label = "#{fmt_info["height"]}p"
|
|
||||||
if fps > 30
|
|
||||||
quality_label += "60"
|
|
||||||
end
|
|
||||||
json.field "qualityLabel", quality_label
|
|
||||||
|
|
||||||
if fmt_info["width"]?
|
|
||||||
json.field "size", "#{fmt_info["width"]}x#{fmt_info["height"]}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Livestream chunk infos
|
# Livestream chunk infos
|
||||||
@ -163,26 +169,31 @@ module Invidious::JSONify::APIv1
|
|||||||
|
|
||||||
json.field "bitrate", fmt["bitrate"].as_i.to_s if fmt["bitrate"]?
|
json.field "bitrate", fmt["bitrate"].as_i.to_s if fmt["bitrate"]?
|
||||||
|
|
||||||
fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"])
|
height = fmt["height"]?.try &.as_i
|
||||||
if fmt_info
|
width = fmt["width"]?.try &.as_i
|
||||||
fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30
|
|
||||||
|
fps = fmt["fps"]?.try &.as_i
|
||||||
|
|
||||||
|
if fps
|
||||||
json.field "fps", fps
|
json.field "fps", fps
|
||||||
|
end
|
||||||
|
|
||||||
|
if height && width
|
||||||
|
json.field "size", "#{width}x#{height}"
|
||||||
|
json.field "resolution", "#{height}p"
|
||||||
|
|
||||||
|
quality_label = "#{width > height ? height : width}p"
|
||||||
|
|
||||||
|
if fps && fps > 30
|
||||||
|
quality_label += fps.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
json.field "qualityLabel", quality_label
|
||||||
|
end
|
||||||
|
|
||||||
|
if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"])
|
||||||
json.field "container", fmt_info["ext"]
|
json.field "container", fmt_info["ext"]
|
||||||
json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"]
|
json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"]
|
||||||
|
|
||||||
if fmt_info["height"]?
|
|
||||||
json.field "resolution", "#{fmt_info["height"]}p"
|
|
||||||
|
|
||||||
quality_label = "#{fmt_info["height"]}p"
|
|
||||||
if fps > 30
|
|
||||||
quality_label += "60"
|
|
||||||
end
|
|
||||||
json.field "qualityLabel", quality_label
|
|
||||||
|
|
||||||
if fmt_info["width"]?
|
|
||||||
json.field "size", "#{fmt_info["width"]}x#{fmt_info["height"]}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -366,6 +366,8 @@ def fetch_playlist(plid : String)
|
|||||||
|
|
||||||
if text.includes? "video"
|
if text.includes? "video"
|
||||||
video_count = text.gsub(/\D/, "").to_i? || 0
|
video_count = text.gsub(/\D/, "").to_i? || 0
|
||||||
|
elsif text.includes? "episode"
|
||||||
|
video_count = text.gsub(/\D/, "").to_i? || 0
|
||||||
elsif text.includes? "view"
|
elsif text.includes? "view"
|
||||||
views = text.gsub(/\D/, "").to_i64? || 0_i64
|
views = text.gsub(/\D/, "").to_i64? || 0_i64
|
||||||
else
|
else
|
||||||
|
@ -74,7 +74,9 @@ module Invidious::Routes::API::V1::Misc
|
|||||||
response = playlist.to_json(offset, video_id: video_id)
|
response = playlist.to_json(offset, video_id: video_id)
|
||||||
json_response = JSON.parse(response)
|
json_response = JSON.parse(response)
|
||||||
|
|
||||||
if json_response["videos"].as_a[0]["index"] != offset
|
if json_response["videos"].as_a.empty?
|
||||||
|
json_response = JSON.parse(response)
|
||||||
|
elsif json_response["videos"].as_a[0]["index"] != offset
|
||||||
offset = json_response["videos"].as_a[0]["index"].as_i
|
offset = json_response["videos"].as_a[0]["index"].as_i
|
||||||
lookback = offset < 50 ? offset : 50
|
lookback = offset < 50 ? offset : 50
|
||||||
response = playlist.to_json(offset - lookback)
|
response = playlist.to_json(offset - lookback)
|
||||||
|
@ -141,7 +141,11 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
webvtt = YT_POOL.client &.get("#{url}&fmt=vtt").body
|
uri = URI.parse(url)
|
||||||
|
query_params = uri.query_params
|
||||||
|
query_params["fmt"] = "vtt"
|
||||||
|
uri.query_params = query_params
|
||||||
|
webvtt = YT_POOL.client &.get(uri.request_target).body
|
||||||
|
|
||||||
if webvtt.starts_with?("<?xml")
|
if webvtt.starts_with?("<?xml")
|
||||||
webvtt = caption.timedtext_to_vtt(webvtt)
|
webvtt = caption.timedtext_to_vtt(webvtt)
|
||||||
|
@ -214,7 +214,7 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
statistics_enabled ||= "off"
|
statistics_enabled ||= "off"
|
||||||
CONFIG.statistics_enabled = statistics_enabled == "on"
|
CONFIG.statistics_enabled = statistics_enabled == "on"
|
||||||
|
|
||||||
CONFIG.modified_source_code_url = env.params.body["modified_source_code_url"]?.try &.as(String)
|
CONFIG.modified_source_code_url = env.params.body["modified_source_code_url"]?.presence
|
||||||
|
|
||||||
File.write("config/config.yml", CONFIG.to_yaml)
|
File.write("config/config.yml", CONFIG.to_yaml)
|
||||||
end
|
end
|
||||||
|
@ -80,7 +80,8 @@ module Invidious::Routes::Watch
|
|||||||
|
|
||||||
if nojs
|
if nojs
|
||||||
if preferences
|
if preferences
|
||||||
source = preferences.comments[0]
|
source = video.comments? ? preferences.comments[0] : "reddit"
|
||||||
|
|
||||||
if source.empty?
|
if source.empty?
|
||||||
source = preferences.comments[1]
|
source = preferences.comments[1]
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@ struct Video
|
|||||||
# NOTE: don't forget to bump this number if any change is made to
|
# NOTE: don't forget to bump this number if any change is made to
|
||||||
# the `params` structure in videos/parser.cr!!!
|
# the `params` structure in videos/parser.cr!!!
|
||||||
#
|
#
|
||||||
SCHEMA_VERSION = 2
|
SCHEMA_VERSION = 3
|
||||||
|
|
||||||
property id : String
|
property id : String
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ struct Video
|
|||||||
end
|
end
|
||||||
|
|
||||||
def genre_url : String?
|
def genre_url : String?
|
||||||
info["genreUcid"]? ? "/channel/#{info["genreUcid"]}" : nil
|
info["genreUcid"].try &.as_s? ? "/channel/#{info["genreUcid"]}" : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_vr : Bool?
|
def is_vr : Bool?
|
||||||
@ -276,6 +276,11 @@ struct Video
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if comments are enabled on the video
|
||||||
|
def comments?
|
||||||
|
return info["commentsEnabled"].as_bool
|
||||||
|
end
|
||||||
|
|
||||||
# Macros defining getters/setters for various types of data
|
# Macros defining getters/setters for various types of data
|
||||||
|
|
||||||
private macro getset_string(name)
|
private macro getset_string(name)
|
||||||
|
@ -389,6 +389,18 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
.try &.as_s.split(" ", 2)[0]
|
.try &.as_s.split(" ", 2)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Comments enabled?
|
||||||
|
comments_enabled = false
|
||||||
|
|
||||||
|
# When comments are enabled there should be a comments-entry-point section in the primary results
|
||||||
|
if primary_results
|
||||||
|
section = primary_results.as_a.find(&.dig?("itemSectionRenderer", "sectionIdentifier").== "comments-entry-point")
|
||||||
|
|
||||||
|
if section
|
||||||
|
comments_enabled = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Return data
|
# Return data
|
||||||
|
|
||||||
if live_now
|
if live_now
|
||||||
@ -414,6 +426,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
"isFamilyFriendly" => JSON::Any.new(family_friendly || false),
|
"isFamilyFriendly" => JSON::Any.new(family_friendly || false),
|
||||||
"isListed" => JSON::Any.new(is_listed || false),
|
"isListed" => JSON::Any.new(is_listed || false),
|
||||||
"isUpcoming" => JSON::Any.new(is_upcoming || false),
|
"isUpcoming" => JSON::Any.new(is_upcoming || false),
|
||||||
|
"commentsEnabled" => JSON::Any.new(comments_enabled),
|
||||||
"keywords" => JSON::Any.new(keywords.map { |v| JSON::Any.new(v) }),
|
"keywords" => JSON::Any.new(keywords.map { |v| JSON::Any.new(v) }),
|
||||||
"isPostLiveDvr" => JSON::Any.new(post_live_dvr),
|
"isPostLiveDvr" => JSON::Any.new(post_live_dvr),
|
||||||
# Related videos
|
# Related videos
|
||||||
@ -424,7 +437,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
"shortDescription" => JSON::Any.new(short_description.try &.as_s || nil),
|
"shortDescription" => JSON::Any.new(short_description.try &.as_s || nil),
|
||||||
# Video metadata
|
# Video metadata
|
||||||
"genre" => JSON::Any.new(genre.try &.as_s || ""),
|
"genre" => JSON::Any.new(genre.try &.as_s || ""),
|
||||||
"genreUcid" => JSON::Any.new(genre_ucid.try &.as_s || ""),
|
"genreUcid" => JSON::Any.new(genre_ucid.try &.as_s?),
|
||||||
"license" => JSON::Any.new(license.try &.as_s || ""),
|
"license" => JSON::Any.new(license.try &.as_s || ""),
|
||||||
# Music section
|
# Music section
|
||||||
"music" => JSON.parse(music_list.to_json),
|
"music" => JSON.parse(music_list.to_json),
|
||||||
|
@ -310,7 +310,7 @@
|
|||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="modified_source_code_url"><%= translate(locale, "adminprefs_modified_source_code_url_label") %></label>
|
<label for="modified_source_code_url"><%= translate(locale, "adminprefs_modified_source_code_url_label") %></label>
|
||||||
<input name="modified_source_code_url" id="modified_source_code_url" type="input" <% if CONFIG.modified_source_code_url %>checked<% end %>>
|
<input name="modified_source_code_url" id="modified_source_code_url" type="url" value="<%= CONFIG.modified_source_code_url %>">
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
@ -42,6 +42,12 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
content: "<%= translate(locale, "Show less") %>"
|
content: "<%= translate(locale, "Show less") %>"
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<%
|
||||||
|
# Disable the try reddit link if javascript is disabled
|
||||||
|
%>
|
||||||
|
<noscript><style> #try-reddit-comments-link { display: none } </style></noscript>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<script id="video_data" type="application/json">
|
<script id="video_data" type="application/json">
|
||||||
@ -56,6 +62,8 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
"youtube_comments_text" => HTML.escape(translate(locale, "View YouTube comments")),
|
"youtube_comments_text" => HTML.escape(translate(locale, "View YouTube comments")),
|
||||||
"reddit_comments_text" => HTML.escape(translate(locale, "View Reddit comments")),
|
"reddit_comments_text" => HTML.escape(translate(locale, "View Reddit comments")),
|
||||||
"reddit_permalink_text" => HTML.escape(translate(locale, "View more comments on Reddit")),
|
"reddit_permalink_text" => HTML.escape(translate(locale, "View more comments on Reddit")),
|
||||||
|
"comments_youtube_disabled_text" => HTML.escape(translate(locale, "comments_youtube_disabled_text")),
|
||||||
|
"comments_youtube_disabled_try_reddit" => HTML.escape(translate(locale, "comments_youtube_disabled_try_reddit")),
|
||||||
"comments_text" => HTML.escape(translate(locale, "View `x` comments", "{commentCount}")),
|
"comments_text" => HTML.escape(translate(locale, "View `x` comments", "{commentCount}")),
|
||||||
"hide_replies_text" => HTML.escape(translate(locale, "Hide replies")),
|
"hide_replies_text" => HTML.escape(translate(locale, "Hide replies")),
|
||||||
"show_replies_text" => HTML.escape(translate(locale, "Show replies")),
|
"show_replies_text" => HTML.escape(translate(locale, "Show replies")),
|
||||||
@ -63,6 +71,7 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
"preferences" => preferences,
|
"preferences" => preferences,
|
||||||
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
|
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
|
||||||
"vr" => video.is_vr,
|
"vr" => video.is_vr,
|
||||||
|
"comments_enabled" => video.comments?,
|
||||||
"projection_type" => video.projection_type,
|
"projection_type" => video.projection_type,
|
||||||
"local_disabled" => CONFIG.disabled?("local"),
|
"local_disabled" => CONFIG.disabled?("local"),
|
||||||
"support_reddit" => true
|
"support_reddit" => true
|
||||||
@ -289,14 +298,41 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<div id="comments" class="comments">
|
<div id="comments" class="comments">
|
||||||
<% if nojs %>
|
<% if (params.comments <=> ["", ""]) == 0 %>
|
||||||
<%= comment_html %>
|
<div id="comments-disabled-message" class="h-box v-box">
|
||||||
|
<p><b><%=HTML.escape(translate(locale, "comments_invidious_disabled_text"))%></b></p>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<noscript>
|
<% if video.comments? %>
|
||||||
<a href="/watch?<%= env.params.query %>&nojs=1">
|
<% if nojs %>
|
||||||
<%= translate(locale, "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.") %>
|
<%= comment_html %>
|
||||||
</a>
|
<% else %>
|
||||||
</noscript>
|
<noscript>
|
||||||
|
<a href="/watch?<%= env.params.query %>&nojs=1">
|
||||||
|
<%= translate(locale, "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.") %>
|
||||||
|
</a>
|
||||||
|
</noscript>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% if !nojs %>
|
||||||
|
<div id="comments-turned-off-on-video-message" class="h-box v-box">
|
||||||
|
<p><b><%=HTML.escape(translate(locale, "comments_youtube_disabled_text"))%></b></p>
|
||||||
|
<p><b><button data-comments="reddit" id="try-reddit-comments-link" class="simulated_a">
|
||||||
|
<%=HTML.escape(translate(locale, "comments_youtube_disabled_try_reddit"))%>
|
||||||
|
</button></b></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<noscript>
|
||||||
|
<% if nojs %>
|
||||||
|
<%= comment_html %>
|
||||||
|
<% else %>
|
||||||
|
<a href="/watch?<%= env.params.query %>&nojs=1">
|
||||||
|
<%= translate(locale, "comments_youtube_disabled_try_reddit_no_js") %>
|
||||||
|
</a>
|
||||||
|
<% end %>
|
||||||
|
</noscript>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user