2018-01-07 17:40:03 +00:00
|
|
|
<% content_for "header" do %>
|
2018-03-07 22:48:26 +00:00
|
|
|
<meta name="thumbnail" content="<%= thumbnail %>">
|
2018-07-31 16:33:25 +00:00
|
|
|
<meta name="description" content="<%= description %>">
|
2018-11-02 13:09:28 +00:00
|
|
|
<meta name="keywords" content="<%= video.keywords.join(",") %>">
|
2018-07-23 01:02:49 +00:00
|
|
|
<meta property="og:site_name" content="Invidious">
|
2018-08-01 15:45:45 +00:00
|
|
|
<meta property="og:url" content="<%= host_url %>/watch?v=<%= video.id %>">
|
2018-08-01 21:07:47 +00:00
|
|
|
<meta property="og:title" content="<%= HTML.escape(video.title) %>">
|
2018-09-15 02:24:28 +00:00
|
|
|
<meta property="og:image" content="/vi/<%= video.id %>/maxres.jpg">
|
2018-07-23 13:07:24 +00:00
|
|
|
<meta property="og:description" content="<%= description %>">
|
2018-07-23 01:02:49 +00:00
|
|
|
<meta property="og:type" content="video.other">
|
2018-08-01 15:45:45 +00:00
|
|
|
<meta property="og:video:url" content="<%= host_url %>/embed/<%= video.id %>">
|
|
|
|
<meta property="og:video:secure_url" content="<%= host_url %>/embed/<%= video.id %>">
|
2018-07-23 01:02:49 +00:00
|
|
|
<meta property="og:video:type" content="text/html">
|
|
|
|
<meta property="og:video:width" content="1280">
|
|
|
|
<meta property="og:video:height" content="720">
|
|
|
|
<meta name="twitter:card" content="player">
|
2018-08-13 18:24:10 +00:00
|
|
|
<meta name="twitter:site" content="@omarroth1">
|
2018-08-01 15:45:45 +00:00
|
|
|
<meta name="twitter:url" content="<%= host_url %>/watch?v=<%= video.id %>">
|
2018-08-01 21:07:47 +00:00
|
|
|
<meta name="twitter:title" content="<%= HTML.escape(video.title) %>">
|
2018-07-23 13:07:24 +00:00
|
|
|
<meta name="twitter:description" content="<%= description %>">
|
2019-03-23 19:05:13 +00:00
|
|
|
<meta name="twitter:image" content="<%= host_url %>/vi/<%= video.id %>/maxres.jpg">
|
2018-08-01 15:45:45 +00:00
|
|
|
<meta name="twitter:player" content="<%= host_url %>/embed/<%= video.id %>">
|
2018-07-23 04:20:49 +00:00
|
|
|
<meta name="twitter:player:width" content="1280">
|
|
|
|
<meta name="twitter:player:height" content="720">
|
2018-10-07 03:20:40 +00:00
|
|
|
<script src="/js/watch.js"></script>
|
2018-08-11 15:52:13 +00:00
|
|
|
<%= rendered "components/player_sources" %>
|
2018-08-01 21:07:47 +00:00
|
|
|
<title><%= HTML.escape(video.title) %> - Invidious</title>
|
2018-01-07 17:40:03 +00:00
|
|
|
<% end %>
|
2018-01-15 03:16:09 +00:00
|
|
|
|
2018-09-15 17:15:39 +00:00
|
|
|
<div id="player-container" class="h-box">
|
2018-08-11 15:52:13 +00:00
|
|
|
<%= rendered "components/player" %>
|
2018-03-11 17:05:56 +00:00
|
|
|
</div>
|
2018-01-16 19:58:08 +00:00
|
|
|
|
2018-08-25 23:33:15 +00:00
|
|
|
<div class="h-box">
|
|
|
|
<h1>
|
2019-03-23 19:05:13 +00:00
|
|
|
<%= HTML.escape(video.title) %>
|
2018-08-26 01:05:51 +00:00
|
|
|
<% if params[:listen] %>
|
2019-02-16 23:46:04 +00:00
|
|
|
<a title="<%=translate(locale, "Video mode")%>" href="/watch?<%= env.params.query %>&listen=0">
|
2018-08-25 23:33:15 +00:00
|
|
|
<i class="icon ion-ios-videocam"></i>
|
|
|
|
</a>
|
|
|
|
<% else %>
|
2019-02-16 23:46:04 +00:00
|
|
|
<a title="<%=translate(locale, "Audio mode")%>" href="/watch?<%= env.params.query %>&listen=1">
|
2019-04-14 23:24:25 +00:00
|
|
|
<i class="icon ion-md-headset"></i>
|
2018-08-25 23:33:15 +00:00
|
|
|
</a>
|
|
|
|
<% end %>
|
|
|
|
</h1>
|
2019-03-26 18:01:23 +00:00
|
|
|
<% if !video.is_listed %>
|
|
|
|
<h3><i class="icon ion-ios-lock"></i> <%= translate(locale, "Unlisted") %></h3>
|
|
|
|
<% end %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% if !reason.empty? %>
|
|
|
|
<h3><%= reason %></h3>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="pure-g">
|
2019-04-14 22:04:52 +00:00
|
|
|
<div class="pure-u-1 pure-u-lg-1-5">
|
2018-08-25 23:33:15 +00:00
|
|
|
<div class="h-box">
|
2018-12-20 21:32:09 +00:00
|
|
|
<p><a href="https://www.youtube.com/watch?v=<%= video.id %>"><%= translate(locale, "Watch video on Youtube") %></a></p>
|
2019-03-23 19:05:13 +00:00
|
|
|
|
2019-04-03 19:53:28 +00:00
|
|
|
<% if CONFIG.dmca_content.includes? video.id %>
|
|
|
|
<p>Download is disabled.</p>
|
|
|
|
<% else %>
|
2019-02-24 17:04:46 +00:00
|
|
|
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
|
2019-01-24 01:05:24 +00:00
|
|
|
<div class="pure-control-group">
|
|
|
|
<label for="download_widget"><%= translate(locale, "Download as: ") %></label>
|
|
|
|
<select style="width:100%" name="download_widget" id="download_widget">
|
|
|
|
<% video_streams.each do |option| %>
|
2019-03-25 21:32:11 +00:00
|
|
|
<option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'>
|
2019-02-24 17:04:46 +00:00
|
|
|
<%= option["quality_label"] %> - <%= option["type"].split(";")[0] %> @ <%= option["fps"] %>fps - video only
|
|
|
|
</option>
|
2019-01-24 01:05:24 +00:00
|
|
|
<% end %>
|
|
|
|
<% audio_streams.each do |option| %>
|
2019-03-25 21:32:11 +00:00
|
|
|
<option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'>
|
2019-02-24 17:04:46 +00:00
|
|
|
<%= option["type"].split(";")[0] %> @ <%= option["bitrate"] %>k - audio only
|
|
|
|
</option>
|
2019-01-24 01:05:24 +00:00
|
|
|
<% end %>
|
|
|
|
<% fmt_stream.each do |option| %>
|
2019-03-25 21:32:11 +00:00
|
|
|
<option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'>
|
2019-02-24 17:04:46 +00:00
|
|
|
<%= itag_to_metadata?(option["itag"]).try &.["height"]? || "~240" %>p - <%= option["type"].split(";")[0] %>
|
|
|
|
</option>
|
2019-01-24 01:05:24 +00:00
|
|
|
<% end %>
|
2019-04-11 17:08:43 +00:00
|
|
|
<% captions.each do |caption| %>
|
|
|
|
<option value='{"id":"<%= video.id %>","label":"<%= caption.name.simpleText %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= caption.languageCode %>.vtt"}'>
|
|
|
|
<%= translate(locale, "Subtitles - `x` (.vtt)", caption.name.simpleText) %>
|
|
|
|
</option>
|
|
|
|
<% end %>
|
2019-01-24 01:05:24 +00:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
2019-02-24 17:04:46 +00:00
|
|
|
<button type="submit" class="pure-button pure-button-primary">
|
2019-01-28 03:20:52 +00:00
|
|
|
<b><%= translate(locale, "Download") %></b>
|
2019-01-24 01:05:24 +00:00
|
|
|
</button>
|
|
|
|
</form>
|
2019-04-03 19:53:28 +00:00
|
|
|
<% end %>
|
2019-01-24 01:05:24 +00:00
|
|
|
|
2018-08-25 23:33:15 +00:00
|
|
|
<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-down"></i> <%= number_with_separator(video.dislikes) %></p>
|
2018-12-20 21:32:09 +00:00
|
|
|
<p id="Genre"><%= translate(locale, "Genre: ") %>
|
2018-09-25 15:10:25 +00:00
|
|
|
<% if video.genre_url.empty? %>
|
|
|
|
<%= video.genre %>
|
|
|
|
<% else %>
|
|
|
|
<a href="<%= video.genre_url %>"><%= video.genre %></a>
|
|
|
|
<% end %>
|
|
|
|
</p>
|
2018-09-09 19:47:26 +00:00
|
|
|
<% if !video.license.empty? %>
|
2018-12-20 21:32:09 +00:00
|
|
|
<p id="License"><%= translate(locale, "License: ") %><%= video.license %></p>
|
2018-09-09 19:47:26 +00:00
|
|
|
<% end %>
|
2018-12-20 21:32:09 +00:00
|
|
|
<p id="FamilyFriendly"><%= translate(locale, "Family friendly? ") %><%= video.is_family_friendly %></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="Engagement"><%= translate(locale, "Engagement: ") %><%= engagement.round(2) %>%</p>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% if video.allowed_regions.size != REGIONS.size %>
|
|
|
|
<p id="AllowedRegions">
|
|
|
|
<% if video.allowed_regions.size < REGIONS.size / 2 %>
|
2018-12-20 21:32:09 +00:00
|
|
|
<%= translate(locale, "Whitelisted regions: ") %><%= video.allowed_regions.join(", ") %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% else %>
|
2018-12-20 21:32:09 +00:00
|
|
|
<%= translate(locale, "Blacklisted regions: ") %><%= (REGIONS.to_a - video.allowed_regions).join(", ") %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% end %>
|
|
|
|
</p>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2019-04-14 22:04:52 +00:00
|
|
|
<div class="pure-u-1 <% if params[:related_videos] || plid %>pure-u-lg-3-5<% else %>pure-u-md-4-5<% end %>">
|
2018-08-25 23:33:15 +00:00
|
|
|
<div class="h-box">
|
|
|
|
<p>
|
|
|
|
<a href="/channel/<%= video.ucid %>">
|
|
|
|
<h3><%= video.author %></h3>
|
|
|
|
</a>
|
|
|
|
</p>
|
2019-01-28 03:06:28 +00:00
|
|
|
<% ucid = video.ucid %>
|
|
|
|
<% author = video.author %>
|
|
|
|
<% sub_count_text = video.sub_count_text %>
|
|
|
|
<%= rendered "components/subscribe_widget" %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<p>
|
2018-12-20 21:32:09 +00:00
|
|
|
<b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b>
|
2018-08-25 23:33:15 +00:00
|
|
|
</p>
|
|
|
|
<div>
|
|
|
|
<%= video.description %>
|
|
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<div id="comments">
|
2018-10-31 21:47:53 +00:00
|
|
|
<% if nojs %>
|
|
|
|
<%= comment_html %>
|
|
|
|
<% else %>
|
|
|
|
<noscript>
|
2018-12-20 21:32:09 +00:00
|
|
|
<a href="/watch?<%= env.params.query %>&nojs=1">
|
|
|
|
<%= translate(locale, "Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.") %>
|
|
|
|
</a>
|
2018-10-31 21:47:53 +00:00
|
|
|
</noscript>
|
|
|
|
<% end %>
|
2018-08-25 23:33:15 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-02-04 21:28:51 +00:00
|
|
|
<% if params[:related_videos] || plid %>
|
2019-04-14 22:04:52 +00:00
|
|
|
<div class="pure-u-1 pure-u-lg-1-5">
|
2018-10-08 02:11:33 +00:00
|
|
|
<% if plid %>
|
|
|
|
<div id="playlist" class="h-box">
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
|
2019-02-04 21:28:51 +00:00
|
|
|
<% if params[:related_videos] %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<div class="h-box">
|
2019-03-23 19:05:13 +00:00
|
|
|
|
2018-11-16 00:05:10 +00:00
|
|
|
<% if !rvs.empty? %>
|
|
|
|
<div id="continue" <% if plid %>style="display:none"<% end %>>
|
|
|
|
<div class="pure-control-group">
|
2018-12-20 21:32:09 +00:00
|
|
|
<label for="continue"><%= translate(locale, "Autoplay next video: ") %></label>
|
2018-11-16 00:05:10 +00:00
|
|
|
<input name="continue" onclick="continue_autoplay(this)" id="continue" type="checkbox" <% if params[:continue] %>checked<% end %>>
|
|
|
|
</div>
|
|
|
|
<hr>
|
2018-11-11 17:45:05 +00:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
|
2018-08-25 23:33:15 +00:00
|
|
|
<% rvs.each do |rv| %>
|
2018-11-18 23:28:22 +00:00
|
|
|
<% if rv["id"]? %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<a href="/watch?v=<%= rv["id"] %>">
|
2019-03-27 16:31:05 +00:00
|
|
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% else %>
|
2018-10-21 01:37:55 +00:00
|
|
|
<div class="thumbnail">
|
|
|
|
<img class="thumbnail" src="/vi/<%= rv["id"] %>/mqdefault.jpg">
|
|
|
|
<p class="length"><%= recode_length_seconds(rv["length_seconds"]?.try &.to_i? || 0) %></p>
|
|
|
|
</div>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% end %>
|
|
|
|
<p style="width:100%"><%= rv["title"] %></p>
|
|
|
|
<p>
|
|
|
|
<b style="width: 100%"><%= rv["author"] %></b>
|
|
|
|
</p>
|
|
|
|
</a>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2018-08-30 21:49:38 +00:00
|
|
|
<% end %>
|
2018-08-25 23:33:15 +00:00
|
|
|
</div>
|
2018-11-19 23:23:01 +00:00
|
|
|
<% end %>
|
2018-08-25 23:33:15 +00:00
|
|
|
</div>
|
|
|
|
|
2018-01-16 19:58:08 +00:00
|
|
|
<script>
|
2018-11-11 17:45:05 +00:00
|
|
|
<% if !rvs.empty? && !plid && params[:continue] %>
|
|
|
|
player.on('ended', function() {
|
2019-03-23 19:05:13 +00:00
|
|
|
location.assign("/watch?v="
|
2018-11-18 23:47:40 +00:00
|
|
|
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
|
2018-11-11 17:45:05 +00:00
|
|
|
+ "&continue=1"
|
|
|
|
<% if params[:listen] %>
|
|
|
|
+ "&listen=1"
|
|
|
|
<% end %>
|
|
|
|
<% if params[:autoplay] %>
|
|
|
|
+ "&autoplay=1"
|
|
|
|
<% end %>
|
|
|
|
<% if params[:speed] %>
|
|
|
|
+ "&speed=<%= params[:speed] %>"
|
|
|
|
<% end %>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
function continue_autoplay(target) {
|
|
|
|
if (target.checked) {
|
|
|
|
player.on('ended', function() {
|
2019-03-23 19:05:13 +00:00
|
|
|
location.assign("/watch?v="
|
2018-11-18 23:47:40 +00:00
|
|
|
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
|
2018-11-11 17:45:05 +00:00
|
|
|
+ "&continue=1"
|
|
|
|
<% if params[:listen] %>
|
|
|
|
+ "&listen=1"
|
|
|
|
<% end %>
|
|
|
|
<% if params[:autoplay] %>
|
|
|
|
+ "&autoplay=1"
|
|
|
|
<% end %>
|
|
|
|
<% if params[:speed] %>
|
|
|
|
+ "&speed=<%= params[:speed] %>"
|
|
|
|
<% end %>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
player.off('ended');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-20 18:52:06 +00:00
|
|
|
function number_with_separator(val) {
|
|
|
|
while (/(\d+)(\d{3})/.test(val.toString())) {
|
|
|
|
val = val.toString().replace(/(\d+)(\d{3})/, "$1" + "," + "$2");
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2019-01-28 03:06:28 +00:00
|
|
|
<% ucid = video.ucid %>
|
|
|
|
<% author = video.author %>
|
|
|
|
<% sub_count_text = video.sub_count_text %>
|
|
|
|
<%= rendered "components/subscribe_widget_script" %>
|
2018-10-13 02:17:37 +00:00
|
|
|
|
2018-10-08 02:11:33 +00:00
|
|
|
<% if plid %>
|
2019-01-24 00:23:31 +00:00
|
|
|
function get_playlist(timeouts = 0) {
|
2018-10-15 16:15:23 +00:00
|
|
|
playlist = document.getElementById("playlist");
|
2019-01-24 00:23:31 +00:00
|
|
|
|
|
|
|
if (timeouts > 10) {
|
|
|
|
console.log("Failed to pull playlist");
|
|
|
|
playlist.innerHTML = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-15 16:15:23 +00:00
|
|
|
playlist.innerHTML = ' \
|
2019-03-20 14:20:31 +00:00
|
|
|
<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3> \
|
2018-10-15 16:15:23 +00:00
|
|
|
<hr>'
|
|
|
|
|
2018-10-08 02:11:33 +00:00
|
|
|
var plid = "<%= plid %>"
|
|
|
|
|
|
|
|
if (plid.startsWith("RD")) {
|
2019-03-11 17:44:25 +00:00
|
|
|
var plid_url = "/api/v1/mixes/<%= plid %>?continuation=<%= video.id %>&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>";
|
2018-10-08 02:11:33 +00:00
|
|
|
} else {
|
2019-03-11 17:44:25 +00:00
|
|
|
var plid_url = "/api/v1/playlists/<%= plid %>?continuation=<%= video.id %>&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>";
|
2018-10-08 02:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.responseType = "json";
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open("GET", plid_url, true);
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
playlist.innerHTML = xhr.response.playlistHtml;
|
2019-03-23 19:05:13 +00:00
|
|
|
|
2018-10-08 02:11:33 +00:00
|
|
|
if (xhr.response.nextVideo) {
|
|
|
|
player.on('ended', function() {
|
2019-03-23 19:05:13 +00:00
|
|
|
location.assign("/watch?v="
|
2018-10-08 02:11:33 +00:00
|
|
|
+ xhr.response.nextVideo
|
|
|
|
+ "&list=<%= plid %>"
|
|
|
|
<% if params[:listen] %>
|
|
|
|
+ "&listen=1"
|
|
|
|
<% end %>
|
|
|
|
<% if params[:autoplay] %>
|
|
|
|
+ "&autoplay=1"
|
|
|
|
<% end %>
|
2018-10-09 13:08:52 +00:00
|
|
|
<% if params[:speed] %>
|
2018-10-11 00:55:28 +00:00
|
|
|
+ "&speed=<%= params[:speed] %>"
|
2018-10-09 13:08:52 +00:00
|
|
|
<% end %>
|
2018-10-08 02:11:33 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
playlist.innerHTML = "";
|
2018-11-16 00:05:10 +00:00
|
|
|
document.getElementById('continue').style.display = "";
|
2018-10-08 02:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
xhr.ontimeout = function() {
|
|
|
|
console.log("Pulling playlist timed out.");
|
|
|
|
|
2019-04-13 19:26:32 +00:00
|
|
|
playlist = document.getElementById("playlist");
|
|
|
|
playlist.innerHTML =
|
2019-03-20 14:20:31 +00:00
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
|
2019-01-24 00:23:31 +00:00
|
|
|
get_playlist(timeouts + 1);
|
2018-10-08 02:11:33 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
get_playlist();
|
|
|
|
<% end %>
|
|
|
|
|
2019-01-24 00:23:31 +00:00
|
|
|
function get_reddit_comments(timeouts = 0) {
|
2018-10-15 16:15:23 +00:00
|
|
|
comments = document.getElementById("comments");
|
2019-01-24 00:23:31 +00:00
|
|
|
|
|
|
|
if (timeouts > 10) {
|
|
|
|
console.log("Failed to pull comments");
|
|
|
|
comments.innerHTML = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-15 16:15:23 +00:00
|
|
|
var fallback = comments.innerHTML;
|
|
|
|
comments.innerHTML =
|
2019-03-20 14:20:31 +00:00
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
2018-10-15 16:15:23 +00:00
|
|
|
|
2019-03-11 17:44:25 +00:00
|
|
|
var url = "/api/v1/comments/<%= video.id %>?source=reddit&format=html&hl=<%= env.get("preferences").as(Preferences).locale %>";
|
2018-08-04 19:39:41 +00:00
|
|
|
var xhr = new XMLHttpRequest();
|
2018-08-09 21:01:39 +00:00
|
|
|
xhr.responseType = "json";
|
2018-08-13 14:58:02 +00:00
|
|
|
xhr.timeout = 20000;
|
2018-08-04 19:39:41 +00:00
|
|
|
xhr.open("GET", url, true);
|
|
|
|
xhr.send();
|
2018-07-20 19:36:23 +00:00
|
|
|
|
2018-08-04 19:39:41 +00:00
|
|
|
xhr.onreadystatechange = function() {
|
2018-10-08 02:11:33 +00:00
|
|
|
if (xhr.readyState == 4) {
|
2018-08-09 21:01:39 +00:00
|
|
|
if (xhr.status == 200) {
|
2018-09-13 23:12:19 +00:00
|
|
|
comments.innerHTML = ' \
|
|
|
|
<div> \
|
|
|
|
<h3> \
|
|
|
|
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a> \
|
|
|
|
{title} \
|
|
|
|
</h3> \
|
2018-10-06 23:54:05 +00:00
|
|
|
<p> \
|
|
|
|
<b> \
|
|
|
|
<a href="javascript:void(0)" onclick="swap_comments(\'youtube\')"> \
|
2018-12-20 21:32:09 +00:00
|
|
|
<%= translate(locale, "View YouTube comments") %> \
|
2018-10-06 23:54:05 +00:00
|
|
|
</a> \
|
|
|
|
</b> \
|
|
|
|
</p> \
|
2018-09-13 23:12:19 +00:00
|
|
|
<b> \
|
2018-12-20 21:32:09 +00:00
|
|
|
<a rel="noopener" target="_blank" href="https://reddit.com{permalink}"><%= translate(locale, "View more comments on Reddit") %></a> \
|
2018-09-13 23:12:19 +00:00
|
|
|
</b> \
|
|
|
|
</div> \
|
|
|
|
<div>{contentHtml}</div> \
|
|
|
|
<hr>'.supplant({
|
2018-08-04 19:39:41 +00:00
|
|
|
title: xhr.response.title,
|
|
|
|
permalink: xhr.response.permalink,
|
2018-08-17 14:25:47 +00:00
|
|
|
contentHtml: xhr.response.contentHtml
|
2018-08-09 21:07:11 +00:00
|
|
|
});
|
|
|
|
} else {
|
2019-03-23 19:05:13 +00:00
|
|
|
<% if preferences && preferences.comments[1] == "youtube" %>
|
2018-08-09 21:07:11 +00:00
|
|
|
get_youtube_comments();
|
2018-08-25 23:33:15 +00:00
|
|
|
<% else %>
|
2018-10-15 16:15:23 +00:00
|
|
|
comments.innerHTML = fallback;
|
2018-08-25 23:33:15 +00:00
|
|
|
<% end %>
|
2018-08-09 21:07:11 +00:00
|
|
|
}
|
2018-10-08 02:11:33 +00:00
|
|
|
}
|
2018-08-04 19:39:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
xhr.ontimeout = function() {
|
2018-08-23 21:55:26 +00:00
|
|
|
console.log("Pulling comments timed out.");
|
|
|
|
|
2019-01-24 00:23:31 +00:00
|
|
|
get_reddit_comments(timeouts + 1);
|
2018-08-09 21:01:39 +00:00
|
|
|
};
|
2018-07-28 14:49:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 00:23:31 +00:00
|
|
|
function get_youtube_comments(timeouts = 0) {
|
2018-10-15 16:15:23 +00:00
|
|
|
comments = document.getElementById("comments");
|
2019-01-24 00:23:31 +00:00
|
|
|
|
|
|
|
if (timeouts > 10) {
|
|
|
|
console.log("Failed to pull comments");
|
|
|
|
comments.innerHTML = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-15 16:15:23 +00:00
|
|
|
var fallback = comments.innerHTML;
|
|
|
|
comments.innerHTML =
|
2019-03-20 14:20:31 +00:00
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
2018-10-15 16:15:23 +00:00
|
|
|
|
2019-03-27 16:31:05 +00:00
|
|
|
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 %>";
|
2018-08-04 19:39:41 +00:00
|
|
|
var xhr = new XMLHttpRequest();
|
2018-08-09 21:01:39 +00:00
|
|
|
xhr.responseType = "json";
|
2018-08-13 14:58:02 +00:00
|
|
|
xhr.timeout = 20000;
|
2018-08-04 19:39:41 +00:00
|
|
|
xhr.open("GET", url, true);
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
2018-10-08 02:11:33 +00:00
|
|
|
if (xhr.readyState == 4) {
|
2018-08-09 21:01:39 +00:00
|
|
|
if (xhr.status == 200) {
|
2018-09-04 13:52:39 +00:00
|
|
|
if (xhr.response.commentCount > 0) {
|
2018-09-13 23:12:19 +00:00
|
|
|
comments.innerHTML = ' \
|
|
|
|
<div> \
|
|
|
|
<h3> \
|
|
|
|
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a> \
|
2018-12-20 21:32:09 +00:00
|
|
|
<%= translate(locale, "View `x` comments", "{commentCount}") %> \
|
2018-09-13 23:12:19 +00:00
|
|
|
</h3> \
|
2018-10-06 23:54:05 +00:00
|
|
|
<b> \
|
|
|
|
<a href="javascript:void(0)" onclick="swap_comments(\'reddit\')"> \
|
2018-12-20 21:32:09 +00:00
|
|
|
<%= translate(locale, "View Reddit comments") %> \
|
2018-10-06 23:54:05 +00:00
|
|
|
</a> \
|
|
|
|
</b> \
|
2018-09-13 23:12:19 +00:00
|
|
|
</div> \
|
|
|
|
<div>{contentHtml}</div> \
|
|
|
|
<hr>'.supplant({
|
2018-09-04 13:52:39 +00:00
|
|
|
contentHtml: xhr.response.contentHtml,
|
2018-10-20 18:52:06 +00:00
|
|
|
commentCount: number_with_separator(xhr.response.commentCount)
|
2018-09-04 13:52:39 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
comments.innerHTML = "";
|
|
|
|
}
|
2018-08-04 19:39:41 +00:00
|
|
|
} else {
|
2019-03-23 19:05:13 +00:00
|
|
|
<% if preferences && preferences.comments[1] == "youtube" %>
|
2018-08-25 23:33:15 +00:00
|
|
|
get_youtube_comments();
|
|
|
|
<% else %>
|
2018-08-09 21:01:39 +00:00
|
|
|
comments.innerHTML = "";
|
2018-08-25 23:33:15 +00:00
|
|
|
<% end %>
|
2018-08-09 21:07:11 +00:00
|
|
|
}
|
2018-10-08 02:11:33 +00:00
|
|
|
}
|
2018-08-09 21:01:39 +00:00
|
|
|
};
|
2018-08-04 19:39:41 +00:00
|
|
|
|
2018-08-09 21:01:39 +00:00
|
|
|
xhr.ontimeout = function() {
|
2018-08-23 21:55:26 +00:00
|
|
|
console.log("Pulling comments timed out.");
|
|
|
|
|
2018-08-13 14:58:02 +00:00
|
|
|
comments.innerHTML =
|
2019-03-20 14:20:31 +00:00
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
2019-01-24 00:23:31 +00:00
|
|
|
get_youtube_comments(timeouts + 1);
|
2018-08-09 21:01:39 +00:00
|
|
|
};
|
2018-07-28 14:49:58 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 22:15:36 +00:00
|
|
|
function get_youtube_replies(target, load_more) {
|
2018-10-07 03:20:40 +00:00
|
|
|
var continuation = target.getAttribute('data-continuation');
|
|
|
|
|
|
|
|
var body = target.parentNode.parentNode;
|
|
|
|
var fallback = body.innerHTML;
|
|
|
|
body.innerHTML =
|
2019-03-20 14:20:31 +00:00
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
2018-10-06 23:54:05 +00:00
|
|
|
|
2019-03-27 16:31:05 +00:00
|
|
|
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=' +
|
2018-10-07 03:20:40 +00:00
|
|
|
continuation;
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.status == 200) {
|
2018-10-22 22:15:36 +00:00
|
|
|
if (load_more) {
|
|
|
|
body = body.parentNode.parentNode;
|
|
|
|
body.removeChild(body.lastElementChild);
|
|
|
|
body.innerHTML += xhr.response.contentHtml;
|
|
|
|
} else {
|
|
|
|
body.innerHTML = ' \
|
|
|
|
<p><a href="javascript:void(0)" \
|
2019-02-16 20:24:15 +00:00
|
|
|
onclick="hide_youtube_replies(this, \'<%= translate(locale, "Hide replies") %>\', \'<%= translate(locale, "Show replies") %>\')"><%= translate(locale, "Hide replies") %> \
|
2018-10-22 22:15:36 +00:00
|
|
|
</a></p> \
|
|
|
|
<div>{contentHtml}</div>'.supplant({
|
|
|
|
contentHtml: xhr.response.contentHtml,
|
|
|
|
});
|
|
|
|
}
|
2018-10-07 03:20:40 +00:00
|
|
|
} else {
|
|
|
|
body.innerHTML = fallback;
|
|
|
|
}
|
2018-10-06 23:54:05 +00:00
|
|
|
}
|
2018-10-07 03:20:40 +00:00
|
|
|
};
|
2018-10-06 23:54:05 +00:00
|
|
|
|
2018-10-07 03:20:40 +00:00
|
|
|
xhr.ontimeout = function() {
|
|
|
|
console.log('Pulling comments timed out.');
|
2018-08-17 14:25:47 +00:00
|
|
|
|
2018-10-07 03:20:40 +00:00
|
|
|
body.innerHTML = fallback;
|
|
|
|
};
|
|
|
|
}
|
2018-07-20 19:36:23 +00:00
|
|
|
|
2018-08-25 23:33:15 +00:00
|
|
|
<% if preferences %>
|
|
|
|
<% if preferences.comments[0] == "youtube" %>
|
|
|
|
get_youtube_comments();
|
|
|
|
<% elsif preferences.comments[0] == "reddit" %>
|
|
|
|
get_reddit_comments();
|
2018-01-16 19:58:08 +00:00
|
|
|
<% else %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% if preferences.comments[1] == "youtube" %>
|
|
|
|
get_youtube_comments();
|
|
|
|
<% elsif preferences.comments[1] == "reddit" %>
|
|
|
|
get_reddit_comments();
|
|
|
|
<% else %>
|
|
|
|
comments = document.getElementById("comments");
|
|
|
|
comments.innerHTML = "";
|
|
|
|
<% end %>
|
2018-01-16 19:58:08 +00:00
|
|
|
<% end %>
|
2018-08-25 23:33:15 +00:00
|
|
|
<% else %>
|
|
|
|
get_youtube_comments();
|
2018-08-18 16:47:16 +00:00
|
|
|
<% end %>
|
2018-11-02 13:09:28 +00:00
|
|
|
</script>
|