|
|
@ -32,7 +32,7 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="h-box">
|
|
|
|
<div class="h-box">
|
|
|
|
<h1>
|
|
|
|
<h1>
|
|
|
|
<%= HTML.escape(video.title) %>
|
|
|
|
<%= HTML.escape(video.title) %>
|
|
|
|
<% if params.listen %>
|
|
|
|
<% if params.listen %>
|
|
|
|
<a title="<%=translate(locale, "Video mode")%>" href="/watch?<%= env.params.query %>&listen=0">
|
|
|
|
<a title="<%=translate(locale, "Video mode")%>" href="/watch?<%= env.params.query %>&listen=0">
|
|
|
@ -43,19 +43,27 @@
|
|
|
|
<i class="icon ion-md-headset"></i>
|
|
|
|
<i class="icon ion-md-headset"></i>
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
</h1>
|
|
|
|
</h1>
|
|
|
|
<% if !video.is_listed %>
|
|
|
|
|
|
|
|
<h3><i class="icon ion-ios-lock"></i> <%= translate(locale, "Unlisted") %></h3>
|
|
|
|
<% if !video.is_listed %>
|
|
|
|
<% end %>
|
|
|
|
<h3>
|
|
|
|
<% if !reason.empty? %>
|
|
|
|
<i class="icon ion-ios-lock"></i> <%= translate(locale, "Unlisted") %>
|
|
|
|
<h3><%= reason %></h3>
|
|
|
|
</h3>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<% if !reason.empty? %>
|
|
|
|
|
|
|
|
<h3>
|
|
|
|
|
|
|
|
<%= reason %>
|
|
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="pure-g">
|
|
|
|
<div class="pure-g">
|
|
|
|
<div class="pure-u-1 pure-u-lg-1-5">
|
|
|
|
<div class="pure-u-1 pure-u-lg-1-5">
|
|
|
|
<div class="h-box">
|
|
|
|
<div class="h-box">
|
|
|
|
<p><a href="https://www.youtube.com/watch?v=<%= video.id %>"><%= translate(locale, "Watch on YouTube") %></a></p>
|
|
|
|
<p>
|
|
|
|
|
|
|
|
<a href="https://www.youtube.com/watch?v=<%= video.id %>"><%= translate(locale, "Watch on YouTube") %></a>
|
|
|
|
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<p>
|
|
|
|
<% if params.annotations %>
|
|
|
|
<% if params.annotations %>
|
|
|
|
<a href="/watch?<%= env.params.query %>&iv_load_policy=3">
|
|
|
|
<a href="/watch?<%= env.params.query %>&iv_load_policy=3">
|
|
|
@ -69,7 +77,7 @@
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<% if CONFIG.dmca_content.includes? video.id %>
|
|
|
|
<% if CONFIG.dmca_content.includes? video.id %>
|
|
|
|
<p>Download is disabled.</p>
|
|
|
|
<p><%= translate(locale, "Download is disabled.") %></p>
|
|
|
|
<% else %>
|
|
|
|
<% else %>
|
|
|
|
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
|
|
|
|
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
|
|
|
|
<div class="pure-control-group">
|
|
|
|
<div class="pure-control-group">
|
|
|
@ -107,7 +115,7 @@
|
|
|
|
<p><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p>
|
|
|
|
<p><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p>
|
|
|
|
<p><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p>
|
|
|
|
<p><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p>
|
|
|
|
<p><i class="icon ion-ios-thumbs-down"></i> <%= number_with_separator(video.dislikes) %></p>
|
|
|
|
<p><i class="icon ion-ios-thumbs-down"></i> <%= number_with_separator(video.dislikes) %></p>
|
|
|
|
<p id="Genre"><%= translate(locale, "Genre: ") %>
|
|
|
|
<p id="genre"><%= translate(locale, "Genre: ") %>
|
|
|
|
<% if video.genre_url.empty? %>
|
|
|
|
<% if video.genre_url.empty? %>
|
|
|
|
<%= video.genre %>
|
|
|
|
<%= video.genre %>
|
|
|
|
<% else %>
|
|
|
|
<% else %>
|
|
|
@ -115,14 +123,14 @@
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
<% if !video.license.empty? %>
|
|
|
|
<% if !video.license.empty? %>
|
|
|
|
<p id="License"><%= translate(locale, "License: ") %><%= video.license %></p>
|
|
|
|
<p id="license"><%= translate(locale, "License: ") %><%= video.license %></p>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<p id="FamilyFriendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p>
|
|
|
|
<p id="family_friendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p>
|
|
|
|
<p id="Wilson"><%= translate(locale, "Wilson score: ") %><%= video.wilson_score.round(4) %></p>
|
|
|
|
<p id="wilson"><%= translate(locale, "Wilson score: ") %><%= video.wilson_score.round(4) %></p>
|
|
|
|
<p id="Rating"><%= translate(locale, "Rating: ") %><%= rating.round(4) %> / 5</p>
|
|
|
|
<p id="rating"><%= translate(locale, "Rating: ") %><%= rating.round(4) %> / 5</p>
|
|
|
|
<p id="Engagement"><%= translate(locale, "Engagement: ") %><%= engagement.round(2) %>%</p>
|
|
|
|
<p id="engagement"><%= translate(locale, "Engagement: ") %><%= engagement.round(2) %>%</p>
|
|
|
|
<% if video.allowed_regions.size != REGIONS.size %>
|
|
|
|
<% if video.allowed_regions.size != REGIONS.size %>
|
|
|
|
<p id="AllowedRegions">
|
|
|
|
<p id="allowed_regions">
|
|
|
|
<% if video.allowed_regions.size < REGIONS.size / 2 %>
|
|
|
|
<% if video.allowed_regions.size < REGIONS.size / 2 %>
|
|
|
|
<%= translate(locale, "Whitelisted regions: ") %><%= video.allowed_regions.join(", ") %>
|
|
|
|
<%= translate(locale, "Whitelisted regions: ") %><%= video.allowed_regions.join(", ") %>
|
|
|
|
<% else %>
|
|
|
|
<% else %>
|
|
|
@ -140,17 +148,22 @@
|
|
|
|
<h3><%= video.author %></h3>
|
|
|
|
<h3><%= video.author %></h3>
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<% ucid = video.ucid %>
|
|
|
|
<% ucid = video.ucid %>
|
|
|
|
<% author = video.author %>
|
|
|
|
<% author = video.author %>
|
|
|
|
<% sub_count_text = video.sub_count_text %>
|
|
|
|
<% sub_count_text = video.sub_count_text %>
|
|
|
|
<%= rendered "components/subscribe_widget" %>
|
|
|
|
<%= rendered "components/subscribe_widget" %>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<p>
|
|
|
|
<b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b>
|
|
|
|
<b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b>
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<%= video.description %>
|
|
|
|
<%= video.description %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="comments">
|
|
|
|
<div id="comments">
|
|
|
|
<% if nojs %>
|
|
|
|
<% if nojs %>
|
|
|
|
<%= comment_html %>
|
|
|
|
<%= comment_html %>
|
|
|
@ -164,16 +177,15 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<% if params.related_videos || plid %>
|
|
|
|
<% if params.related_videos || plid %>
|
|
|
|
<div class="pure-u-1 pure-u-lg-1-5">
|
|
|
|
<div class="pure-u-1 pure-u-lg-1-5">
|
|
|
|
<% if plid %>
|
|
|
|
<% if plid %>
|
|
|
|
<div id="playlist" class="h-box">
|
|
|
|
<div id="playlist" class="h-box"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
|
|
<% if params.related_videos %>
|
|
|
|
<% if params.related_videos %>
|
|
|
|
<div class="h-box">
|
|
|
|
<div class="h-box">
|
|
|
|
|
|
|
|
|
|
|
|
<% if !rvs.empty? %>
|
|
|
|
<% if !rvs.empty? %>
|
|
|
|
<div <% if plid %>style="display:none"<% end %>>
|
|
|
|
<div <% if plid %>style="display:none"<% end %>>
|
|
|
|
<div class="pure-control-group">
|
|
|
|
<div class="pure-control-group">
|
|
|
@ -187,8 +199,7 @@
|
|
|
|
<% rvs.each do |rv| %>
|
|
|
|
<% rvs.each do |rv| %>
|
|
|
|
<% if rv["id"]? %>
|
|
|
|
<% if rv["id"]? %>
|
|
|
|
<a href="/watch?v=<%= rv["id"] %>">
|
|
|
|
<a href="/watch?v=<%= rv["id"] %>">
|
|
|
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
|
|
|
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
|
|
|
<% else %>
|
|
|
|
|
|
|
|
<div class="thumbnail">
|
|
|
|
<div class="thumbnail">
|
|
|
|
<img class="thumbnail" src="/vi/<%= rv["id"] %>/mqdefault.jpg">
|
|
|
|
<img class="thumbnail" src="/vi/<%= rv["id"] %>/mqdefault.jpg">
|
|
|
|
<p class="length"><%= recode_length_seconds(rv["length_seconds"]?.try &.to_i? || 0) %></p>
|
|
|
|
<p class="length"><%= recode_length_seconds(rv["length_seconds"]?.try &.to_i? || 0) %></p>
|
|
|
@ -218,18 +229,19 @@
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
<% if !rvs.empty? && !plid && params.continue %>
|
|
|
|
<% if !rvs.empty? && !plid && params.continue %>
|
|
|
|
player.on('ended', function() {
|
|
|
|
player.on('ended', function() {
|
|
|
|
location.assign("/watch?v="
|
|
|
|
location.assign('/watch?v=' +
|
|
|
|
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
|
|
|
|
'<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>' +
|
|
|
|
+ "&continue=1"
|
|
|
|
'&continue=1' +
|
|
|
|
<% if params.listen != preferences.listen %>
|
|
|
|
<% if params.listen != preferences.listen %>
|
|
|
|
+ "&listen=<%= params.listen %>"
|
|
|
|
'&listen=<%= params.listen %>' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% if params.autoplay || params.continue_autoplay %>
|
|
|
|
<% if params.autoplay || params.continue_autoplay %>
|
|
|
|
+ "&autoplay=1"
|
|
|
|
'&autoplay=1' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% if params.speed != preferences.speed %>
|
|
|
|
<% if params.speed != preferences.speed %>
|
|
|
|
+ "&speed=<%= params.speed %>"
|
|
|
|
'&speed=<%= params.speed %>' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
''
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
@ -237,18 +249,19 @@ player.on('ended', function() {
|
|
|
|
function continue_autoplay(target) {
|
|
|
|
function continue_autoplay(target) {
|
|
|
|
if (target.checked) {
|
|
|
|
if (target.checked) {
|
|
|
|
player.on('ended', function() {
|
|
|
|
player.on('ended', function() {
|
|
|
|
location.assign("/watch?v="
|
|
|
|
location.assign('/watch?v=' +
|
|
|
|
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
|
|
|
|
'<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>' +
|
|
|
|
+ "&continue=1"
|
|
|
|
'&continue=1' +
|
|
|
|
<% if params.listen != preferences.listen %>
|
|
|
|
<% if params.listen != preferences.listen %>
|
|
|
|
+ "&listen=<%= params.listen %>"
|
|
|
|
'&listen=<%= params.listen %>' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% if params.autoplay || params.continue_autoplay %>
|
|
|
|
<% if params.autoplay || params.continue_autoplay %>
|
|
|
|
+ "&autoplay=1"
|
|
|
|
'&autoplay=1' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% if params.speed != preferences.speed %>
|
|
|
|
<% if params.speed != preferences.speed %>
|
|
|
|
+ "&speed=<%= params.speed %>"
|
|
|
|
'&speed=<%= params.speed %>' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
''
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -269,12 +282,12 @@ function number_with_separator(val) {
|
|
|
|
<%= rendered "components/subscribe_widget_script" %>
|
|
|
|
<%= rendered "components/subscribe_widget_script" %>
|
|
|
|
|
|
|
|
|
|
|
|
<% if plid %>
|
|
|
|
<% if plid %>
|
|
|
|
function get_playlist(timeouts = 0) {
|
|
|
|
function get_playlist(plid, timeouts = 0) {
|
|
|
|
playlist = document.getElementById("playlist");
|
|
|
|
playlist = document.getElementById('playlist');
|
|
|
|
|
|
|
|
|
|
|
|
if (timeouts > 10) {
|
|
|
|
if (timeouts > 10) {
|
|
|
|
console.log("Failed to pull playlist");
|
|
|
|
console.log('Failed to pull playlist');
|
|
|
|
playlist.innerHTML = "";
|
|
|
|
playlist.innerHTML = '';
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -282,18 +295,20 @@ function get_playlist(timeouts = 0) {
|
|
|
|
<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3> \
|
|
|
|
<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3> \
|
|
|
|
<hr>'
|
|
|
|
<hr>'
|
|
|
|
|
|
|
|
|
|
|
|
var plid = "<%= plid %>"
|
|
|
|
if (plid.startsWith('RD')) {
|
|
|
|
|
|
|
|
var plid_url = '/api/v1/mixes/' + plid +
|
|
|
|
if (plid.startsWith("RD")) {
|
|
|
|
'?continuation=<%= video.id %>' +
|
|
|
|
var plid_url = "/api/v1/mixes/<%= plid %>?continuation=<%= video.id %>&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>";
|
|
|
|
'&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var plid_url = "/api/v1/playlists/<%= plid %>?continuation=<%= video.id %>&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>";
|
|
|
|
var plid_url = '/api/v1/playlists/' + plid +
|
|
|
|
|
|
|
|
'?continuation=<%= video.id %>' +
|
|
|
|
|
|
|
|
'&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.responseType = "json";
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open("GET", plid_url, true);
|
|
|
|
xhr.open('GET', plid_url, true);
|
|
|
|
xhr.send();
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
@ -303,47 +318,46 @@ function get_playlist(timeouts = 0) {
|
|
|
|
|
|
|
|
|
|
|
|
if (xhr.response.nextVideo) {
|
|
|
|
if (xhr.response.nextVideo) {
|
|
|
|
player.on('ended', function() {
|
|
|
|
player.on('ended', function() {
|
|
|
|
location.assign("/watch?v="
|
|
|
|
location.assign('/watch?v=' + xhr.response.nextVideo +
|
|
|
|
+ xhr.response.nextVideo
|
|
|
|
'&list=' + plid +
|
|
|
|
+ "&list=<%= plid %>"
|
|
|
|
|
|
|
|
<% if params.listen != preferences.listen %>
|
|
|
|
<% if params.listen != preferences.listen %>
|
|
|
|
+ "&listen=<%= params.listen %>"
|
|
|
|
'&listen=<%= params.listen %>' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% if params.autoplay || params.continue_autoplay %>
|
|
|
|
<% if params.autoplay || params.continue_autoplay %>
|
|
|
|
+ "&autoplay=1"
|
|
|
|
'&autoplay=1' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% if params.speed != preferences.speed %>
|
|
|
|
<% if params.speed != preferences.speed %>
|
|
|
|
+ "&speed=<%= params.speed %>"
|
|
|
|
'&speed=<%= params.speed %>' +
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
''
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
playlist.innerHTML = "";
|
|
|
|
playlist.innerHTML = '';
|
|
|
|
document.getElementById('continue').style.display = "";
|
|
|
|
document.getElementById('continue').style.display = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
console.log("Pulling playlist timed out.");
|
|
|
|
console.log('Pulling playlist timed out.');
|
|
|
|
|
|
|
|
playlist = document.getElementById('playlist');
|
|
|
|
playlist = document.getElementById("playlist");
|
|
|
|
|
|
|
|
playlist.innerHTML =
|
|
|
|
playlist.innerHTML =
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
|
|
|
|
get_playlist(timeouts + 1);
|
|
|
|
get_playlist(plid, timeouts + 1);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
get_playlist();
|
|
|
|
get_playlist('<%= plid %>');
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
|
|
function get_reddit_comments(timeouts = 0) {
|
|
|
|
function get_reddit_comments(timeouts = 0) {
|
|
|
|
comments = document.getElementById("comments");
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
|
|
|
|
|
|
|
|
if (timeouts > 10) {
|
|
|
|
if (timeouts > 10) {
|
|
|
|
console.log("Failed to pull comments");
|
|
|
|
console.log('Failed to pull comments');
|
|
|
|
comments.innerHTML = "";
|
|
|
|
comments.innerHTML = '';
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -351,11 +365,13 @@ function get_reddit_comments(timeouts = 0) {
|
|
|
|
comments.innerHTML =
|
|
|
|
comments.innerHTML =
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
|
|
|
|
|
|
|
|
var url = "/api/v1/comments/<%= video.id %>?source=reddit&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>";
|
|
|
|
var url = '/api/v1/comments/<%= video.id %>' +
|
|
|
|
|
|
|
|
'?source=reddit&format=html' +
|
|
|
|
|
|
|
|
'&hl=<%= env.get("preferences").as(Preferences).locale %>';
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.responseType = "json";
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open("GET", url, true);
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.send();
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
@ -395,18 +411,17 @@ function get_reddit_comments(timeouts = 0) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
console.log("Pulling comments timed out.");
|
|
|
|
console.log('Pulling comments timed out.');
|
|
|
|
|
|
|
|
|
|
|
|
get_reddit_comments(timeouts + 1);
|
|
|
|
get_reddit_comments(timeouts + 1);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_youtube_comments(timeouts = 0) {
|
|
|
|
function get_youtube_comments(timeouts = 0) {
|
|
|
|
comments = document.getElementById("comments");
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
|
|
|
|
|
|
|
|
if (timeouts > 10) {
|
|
|
|
if (timeouts > 10) {
|
|
|
|
console.log("Failed to pull comments");
|
|
|
|
console.log('Failed to pull comments');
|
|
|
|
comments.innerHTML = "";
|
|
|
|
comments.innerHTML = '';
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -414,11 +429,14 @@ function get_youtube_comments(timeouts = 0) {
|
|
|
|
comments.innerHTML =
|
|
|
|
comments.innerHTML =
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
|
|
|
|
|
|
|
|
var url = "/api/v1/comments/<%= video.id %>?format=html&hl=<%= env.get("preferences").as(Preferences).locale %>&thin_mode=<%= env.get("preferences").as(Preferences).thin_mode %>";
|
|
|
|
var url = '/api/v1/comments/<%= video.id %>' +
|
|
|
|
|
|
|
|
'?format=html' +
|
|
|
|
|
|
|
|
'&hl=<%= env.get("preferences").as(Preferences).locale %>' +
|
|
|
|
|
|
|
|
'&thin_mode=<%= env.get("preferences").as(Preferences).thin_mode %>';
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.responseType = "json";
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open("GET", url, true);
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.send();
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
@ -449,15 +467,14 @@ function get_youtube_comments(timeouts = 0) {
|
|
|
|
<% if preferences && preferences.comments[1] == "youtube" %>
|
|
|
|
<% if preferences && preferences.comments[1] == "youtube" %>
|
|
|
|
get_youtube_comments(timeouts + 1);
|
|
|
|
get_youtube_comments(timeouts + 1);
|
|
|
|
<% else %>
|
|
|
|
<% else %>
|
|
|
|
comments.innerHTML = "";
|
|
|
|
comments.innerHTML = '';
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
console.log("Pulling comments timed out.");
|
|
|
|
console.log('Pulling comments timed out.');
|
|
|
|
|
|
|
|
|
|
|
|
comments.innerHTML =
|
|
|
|
comments.innerHTML =
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
get_youtube_comments(timeouts + 1);
|
|
|
|
get_youtube_comments(timeouts + 1);
|
|
|
@ -472,8 +489,11 @@ function get_youtube_replies(target, load_more) {
|
|
|
|
body.innerHTML =
|
|
|
|
body.innerHTML =
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
|
|
|
|
|
|
|
|
var url = '/api/v1/comments/<%= video.id %>?format=html&hl=<%= env.get("preferences").as(Preferences).locale %>&thin_mode=<%= env.get("preferences").as(Preferences).thin_mode %>&continuation=' +
|
|
|
|
var url = '/api/v1/comments/<%= video.id %>' +
|
|
|
|
continuation;
|
|
|
|
'?format=html' +
|
|
|
|
|
|
|
|
'&hl=<%= env.get("preferences").as(Preferences).locale %>' +
|
|
|
|
|
|
|
|
'&thin_mode=<%= env.get("preferences").as(Preferences).thin_mode %>' +
|
|
|
|
|
|
|
|
'&continuation=' + continuation;
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
@ -504,7 +524,6 @@ function get_youtube_replies(target, load_more) {
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
console.log('Pulling comments timed out.');
|
|
|
|
console.log('Pulling comments timed out.');
|
|
|
|
|
|
|
|
|
|
|
|
body.innerHTML = fallback;
|
|
|
|
body.innerHTML = fallback;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -520,11 +539,11 @@ function get_youtube_replies(target, load_more) {
|
|
|
|
<% elsif preferences.comments[1] == "reddit" %>
|
|
|
|
<% elsif preferences.comments[1] == "reddit" %>
|
|
|
|
get_reddit_comments();
|
|
|
|
get_reddit_comments();
|
|
|
|
<% else %>
|
|
|
|
<% else %>
|
|
|
|
comments = document.getElementById("comments");
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
comments.innerHTML = "";
|
|
|
|
comments.innerHTML = '';
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% else %>
|
|
|
|
<% else %>
|
|
|
|
get_youtube_comments();
|
|
|
|
get_youtube_comments();
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|