invidious-mod/src/invidious/views/watch.ecr

446 行
15 KiB
Plaintext
Raw 通常表示 履歴

2018-01-08 02:40:03 +09:00
<% content_for "header" do %>
2018-03-08 07:48:26 +09:00
<meta name="thumbnail" content="<%= thumbnail %>">
2018-08-01 01:33:25 +09:00
<meta name="description" content="<%= description %>">
<meta name="keywords" content="<%= video.info["keywords"] %>">
2018-07-23 10:02:49 +09:00
<meta property="og:site_name" content="Invidious">
<meta property="og:url" content="<%= host_url %>/watch?v=<%= video.id %>">
<meta property="og:title" content="<%= HTML.escape(video.title) %>">
2018-09-15 11:24:28 +09:00
<meta property="og:image" content="/vi/<%= video.id %>/maxres.jpg">
2018-07-23 22:07:24 +09:00
<meta property="og:description" content="<%= description %>">
2018-07-23 10:02:49 +09:00
<meta property="og:type" content="video.other">
<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 10:02:49 +09: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-14 03:24:10 +09:00
<meta name="twitter:site" content="@omarroth1">
<meta name="twitter:url" content="<%= host_url %>/watch?v=<%= video.id %>">
<meta name="twitter:title" content="<%= HTML.escape(video.title) %>">
2018-07-23 22:07:24 +09:00
<meta name="twitter:description" content="<%= description %>">
<meta name="twitter:image" content="<%= thumbnail %>">
<meta name="twitter:player" content="<%= host_url %>/embed/<%= video.id %>">
2018-07-23 13:20:49 +09:00
<meta name="twitter:player:width" content="1280">
<meta name="twitter:player:height" content="720">
2018-10-07 12:20:40 +09:00
<script src="/js/watch.js"></script>
<%= rendered "components/player_sources" %>
<title><%= HTML.escape(video.title) %> - Invidious</title>
2018-01-08 02:40:03 +09:00
<% end %>
2018-01-15 12:16:09 +09:00
<div id="player-container" class="h-box">
<%= rendered "components/player" %>
2018-03-12 02:05:56 +09:00
</div>
2018-01-17 04:58:08 +09:00
2018-08-26 08:33:15 +09:00
<div class="h-box">
<h1>
<%= HTML.escape(video.title) %>
<% if params[:listen] %>
2018-10-30 23:41:23 +09:00
<a href="/watch?<%= env.params.query %>&listen=0">
2018-08-26 08:33:15 +09:00
<i class="icon ion-ios-videocam"></i>
</a>
<% else %>
<a href="/watch?<%= env.params.query %>&listen=1">
<i class="icon ion-ios-volume-high"></i>
</a>
<% end %>
</h1>
<% if !reason.empty? %>
<h3><%= reason %></h3>
<% end %>
</div>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-5">
<div class="h-box">
<p><a href="https://www.youtube.com/watch?v=<%= video.id %>">Watch video on YouTube</a></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-down"></i> <%= number_with_separator(video.dislikes) %></p>
2018-09-26 00:10:25 +09:00
<p id="Genre">Genre:
<% if video.genre_url.empty? %>
<%= video.genre %>
<% else %>
<a href="<%= video.genre_url %>"><%= video.genre %></a>
<% end %>
</p>
2018-09-10 04:47:26 +09:00
<% if !video.license.empty? %>
<p id="License">License: <%= video.license %></p>
<% end %>
2018-08-26 08:33:15 +09:00
<p id="FamilyFriendly">Family Friendly? <%= video.is_family_friendly %></p>
<p id="Wilson">Wilson Score: <%= video.wilson_score.round(4) %></p>
<p id="Rating">Rating: <%= rating.round(4) %> / 5</p>
<p id="Engagement">Engagement: <%= engagement.round(2) %>%</p>
<% if video.allowed_regions.size != REGIONS.size %>
<p id="AllowedRegions">
<% if video.allowed_regions.size < REGIONS.size / 2 %>
Whitelisted regions: <%= video.allowed_regions.join(", ") %>
<% else %>
Blacklisted regions: <%= (REGIONS.to_a - video.allowed_regions).join(", ") %>
<% end %>
</p>
<% end %>
</div>
</div>
<div class="pure-u-1 pure-u-md-3-5">
<div class="h-box">
<p>
<a href="/channel/<%= video.ucid %>">
<h3><%= video.author %></h3>
</a>
</p>
<% if user %>
<% if subscriptions.includes? video.ucid %>
<p>
<a id="subscribe" onclick="unsubscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_remove_subscriptions=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>">
2018-10-20 06:20:35 +09:00
<b>Unsubscribe | <%= video.sub_count_text %></b>
2018-08-26 08:33:15 +09:00
</a>
</p>
<% else %>
<p>
<a id="subscribe" onclick="subscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_create_subscription_to_channel=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>">
2018-10-20 06:20:35 +09:00
<b>Subscribe | <%= video.sub_count_text %></b>
2018-08-26 08:33:15 +09:00
</a>
</p>
<% end %>
<% else %>
<p>
<a id="subscribe" class="pure-button pure-button-primary"
href="/login?referer=<%= env.get("current_page") %>">
2018-08-26 08:33:15 +09:00
<b>Login to subscribe to <%= video.author %></b>
</a>
</p>
<% end %>
<p>
<b>Shared <%= video.published.to_s("%B %-d, %Y") %></b>
</p>
<div>
<%= video.description %>
</div>
<hr>
<div id="comments">
</div>
</div>
</div>
<div class="pure-u-1 pure-u-md-1-5">
2018-10-08 11:11:33 +09:00
<% if plid %>
<div id="playlist" class="h-box">
</div>
<% end %>
<% if !preferences || preferences && preferences.related_videos %>
2018-08-26 08:33:15 +09:00
<div class="h-box">
<% rvs.each do |rv| %>
<% if rv.has_key?("id") %>
<a href="/watch?v=<%= rv["id"] %>">
<% if preferences && preferences.thin_mode %>
<% else %>
<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-26 08:33:15 +09:00
<% end %>
<p style="width:100%"><%= rv["title"] %></p>
<p>
<b style="width: 100%"><%= rv["author"] %></b>
</p>
</a>
<% end %>
<% end %>
</div>
2018-08-31 06:49:38 +09:00
<% end %>
2018-08-26 08:33:15 +09:00
</div>
</div>
2018-01-17 04:58:08 +09:00
<script>
2018-10-21 03:52:06 +09:00
function number_with_separator(val) {
while (/(\d+)(\d{3})/.test(val.toString())) {
val = val.toString().replace(/(\d+)(\d{3})/, "$1" + "," + "$2");
}
return val;
}
2018-10-14 09:40:24 +09:00
subscribe_button = document.getElementById("subscribe");
if (subscribe_button.getAttribute('onclick')) {
subscribe_button["href"] = "javascript:void(0);";
}
function subscribe() {
var url = "/subscription_ajax?action_create_subscription_to_channel=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>";
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) {
subscribe_button = document.getElementById("subscribe");
subscribe_button.onclick = unsubscribe;
2018-10-20 06:20:35 +09:00
subscribe_button.innerHTML = '<b>Unsubscribe | <%= video.sub_count_text %></b>'
}
}
}
}
function unsubscribe() {
var url = "/subscription_ajax?action_remove_subscriptions=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>";
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) {
subscribe_button = document.getElementById("subscribe");
subscribe_button.onclick = subscribe;
2018-10-20 06:20:35 +09:00
subscribe_button.innerHTML = '<b>Subscribe | <%= video.sub_count_text %></b>'
}
}
}
}
2018-10-08 11:11:33 +09:00
<% if plid %>
function get_playlist() {
2018-10-16 01:15:23 +09:00
playlist = document.getElementById("playlist");
playlist.innerHTML = ' \
<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3> \
<hr>'
2018-10-08 11:11:33 +09:00
var plid = "<%= plid %>"
if (plid.startsWith("RD")) {
var plid_url = "/api/v1/mixes/<%= plid %>?continuation=<%= video.id %>&format=html";
} else {
var plid_url = "/api/v1/playlists/<%= plid %>?continuation=<%= video.id %>&format=html";
}
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;
if (xhr.response.nextVideo) {
player.on('ended', function() {
window.location.replace("/watch?v="
+ xhr.response.nextVideo
+ "&list=<%= plid %>"
<% if params[:listen] %>
+ "&listen=1"
<% end %>
<% if params[:autoplay] %>
+ "&autoplay=1"
<% end %>
2018-10-09 22:08:52 +09:00
<% if params[:speed] %>
+ "&speed=<%= params[:speed] %>"
2018-10-09 22:08:52 +09:00
<% end %>
2018-10-08 11:11:33 +09:00
);
});
}
} else {
playlist.innerHTML = "";
}
}
};
xhr.ontimeout = function() {
console.log("Pulling playlist timed out.");
comments = document.getElementById("playlist");
comments.innerHTML =
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3><hr>';
get_playlist();
};
}
get_playlist();
<% end %>
2018-07-28 23:49:58 +09:00
function get_reddit_comments() {
2018-10-16 01:15:23 +09:00
comments = document.getElementById("comments");
var fallback = comments.innerHTML;
comments.innerHTML =
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
2018-09-07 00:19:28 +09:00
var url = "/api/v1/comments/<%= video.id %>?source=reddit&format=html";
2018-08-05 04:39:41 +09:00
var xhr = new XMLHttpRequest();
2018-08-10 06:01:39 +09:00
xhr.responseType = "json";
2018-08-13 23:58:02 +09:00
xhr.timeout = 20000;
2018-08-05 04:39:41 +09:00
xhr.open("GET", url, true);
xhr.send();
2018-08-05 04:39:41 +09:00
xhr.onreadystatechange = function() {
2018-10-08 11:11:33 +09:00
if (xhr.readyState == 4) {
2018-08-10 06:01:39 +09:00
if (xhr.status == 200) {
2018-09-14 08:12:19 +09:00
comments.innerHTML = ' \
<div> \
<h3> \
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a> \
{title} \
</h3> \
<p> \
<b> \
<a href="javascript:void(0)" onclick="swap_comments(\'youtube\')"> \
View YouTube comments \
</a> \
</b> \
</p> \
2018-09-14 08:12:19 +09:00
<b> \
<a rel="noopener" target="_blank" href="https://reddit.com{permalink}">View more comments on Reddit</a> \
2018-09-14 08:12:19 +09:00
</b> \
</div> \
<div>{contentHtml}</div> \
<hr>'.supplant({
2018-08-05 04:39:41 +09:00
title: xhr.response.title,
permalink: xhr.response.permalink,
2018-08-17 23:25:47 +09:00
contentHtml: xhr.response.contentHtml
2018-08-10 06:07:11 +09:00
});
} else {
2018-08-26 08:33:15 +09:00
<% if preferences && preferences.comments[1] == "youtube" %>
2018-08-10 06:07:11 +09:00
get_youtube_comments();
2018-08-26 08:33:15 +09:00
<% else %>
2018-10-16 01:15:23 +09:00
comments.innerHTML = fallback;
2018-08-26 08:33:15 +09:00
<% end %>
2018-08-10 06:07:11 +09:00
}
2018-10-08 11:11:33 +09:00
}
2018-08-05 04:39:41 +09:00
};
xhr.ontimeout = function() {
2018-08-24 06:55:26 +09:00
console.log("Pulling comments timed out.");
2018-08-10 06:07:11 +09:00
get_reddit_comments();
2018-08-10 06:01:39 +09:00
};
2018-07-28 23:49:58 +09:00
}
function get_youtube_comments() {
2018-10-16 01:15:23 +09:00
comments = document.getElementById("comments");
var fallback = comments.innerHTML;
comments.innerHTML =
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
2018-08-10 06:01:39 +09:00
var url = "/api/v1/comments/<%= video.id %>?format=html";
2018-08-05 04:39:41 +09:00
var xhr = new XMLHttpRequest();
2018-08-10 06:01:39 +09:00
xhr.responseType = "json";
2018-08-13 23:58:02 +09:00
xhr.timeout = 20000;
2018-08-05 04:39:41 +09:00
xhr.open("GET", url, true);
xhr.send();
xhr.onreadystatechange = function() {
2018-10-08 11:11:33 +09:00
if (xhr.readyState == 4) {
2018-08-10 06:01:39 +09:00
if (xhr.status == 200) {
if (xhr.response.commentCount > 0) {
2018-09-14 08:12:19 +09:00
comments.innerHTML = ' \
<div> \
<h3> \
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a> \
View {commentCount} comments \
</h3> \
<b> \
<a href="javascript:void(0)" onclick="swap_comments(\'reddit\')"> \
View Reddit comments \
</a> \
</b> \
2018-09-14 08:12:19 +09:00
</div> \
<div>{contentHtml}</div> \
<hr>'.supplant({
contentHtml: xhr.response.contentHtml,
2018-10-21 03:52:06 +09:00
commentCount: number_with_separator(xhr.response.commentCount)
});
} else {
comments.innerHTML = "";
}
2018-08-05 04:39:41 +09:00
} else {
2018-08-26 08:33:15 +09:00
<% if preferences && preferences.comments[1] == "youtube" %>
get_youtube_comments();
<% else %>
2018-08-10 06:01:39 +09:00
comments.innerHTML = "";
2018-08-26 08:33:15 +09:00
<% end %>
2018-08-10 06:07:11 +09:00
}
2018-10-08 11:11:33 +09:00
}
2018-08-10 06:01:39 +09:00
};
2018-08-05 04:39:41 +09:00
2018-08-10 06:01:39 +09:00
xhr.ontimeout = function() {
2018-08-24 06:55:26 +09:00
console.log("Pulling comments timed out.");
2018-08-13 23:58:02 +09:00
comments.innerHTML =
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
2018-08-05 04:39:41 +09:00
get_youtube_comments();
2018-08-10 06:01:39 +09:00
};
2018-07-28 23:49:58 +09:00
}
2018-10-23 07:15:36 +09:00
function get_youtube_replies(target, load_more) {
2018-10-07 12:20:40 +09:00
var continuation = target.getAttribute('data-continuation');
var body = target.parentNode.parentNode;
var fallback = body.innerHTML;
body.innerHTML =
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
2018-10-07 12:20:40 +09:00
var url = '/api/v1/comments/<%= video.id %>?format=html&continuation=' +
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-23 07:15:36 +09: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)" \
onclick="hide_youtube_replies(this)">Hide replies \
</a></p> \
<div>{contentHtml}</div>'.supplant({
contentHtml: xhr.response.contentHtml,
});
}
2018-10-07 12:20:40 +09:00
} else {
body.innerHTML = fallback;
}
}
2018-10-07 12:20:40 +09:00
};
2018-10-07 12:20:40 +09:00
xhr.ontimeout = function() {
console.log('Pulling comments timed out.');
2018-08-17 23:25:47 +09:00
2018-10-07 12:20:40 +09:00
body.innerHTML = fallback;
};
}
2018-08-26 08:33:15 +09:00
<% if preferences %>
<% if preferences.comments[0] == "youtube" %>
get_youtube_comments();
<% elsif preferences.comments[0] == "reddit" %>
get_reddit_comments();
2018-01-17 04:58:08 +09:00
<% else %>
2018-08-26 08:33:15 +09: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-17 04:58:08 +09:00
<% end %>
2018-08-26 08:33:15 +09:00
<% else %>
get_youtube_comments();
<% end %>
2018-01-16 11:30:57 +09:00
2018-08-26 08:33:15 +09:00
</script>