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

293 lines
9.5 KiB
Plaintext
Raw Normal View History

2018-01-07 23:10:03 +05:30
<% content_for "header" do %>
2018-03-08 04:18:26 +05:30
<meta name="thumbnail" content="<%= thumbnail %>">
2018-07-31 22:03:25 +05:30
<meta name="description" content="<%= description %>">
<meta name="keywords" content="<%= video.info["keywords"] %>">
2018-07-23 06:32:49 +05:30
<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-07-25 03:35:02 +05:30
<meta property="og:image" content="https://i.ytimg.com/vi/<%= video.id %>/hqdefault.jpg">
2018-07-23 18:37:24 +05:30
<meta property="og:description" content="<%= description %>">
2018-07-23 06:32:49 +05:30
<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 06:32:49 +05:30
<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 23:54:10 +05:30
<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 18:37:24 +05:30
<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 09:50:49 +05:30
<meta name="twitter:player:width" content="1280">
<meta name="twitter:player:height" content="720">
<%= rendered "components/player_sources" %>
<title><%= HTML.escape(video.title) %> - Invidious</title>
2018-01-07 23:10:03 +05:30
<% end %>
2018-01-15 08:46:09 +05:30
2018-03-13 05:07:01 +05:30
<div class="h-box">
<%= rendered "components/player" %>
2018-03-11 22:35:56 +05:30
</div>
2018-01-17 01:28:08 +05:30
<script>
2018-07-28 20:19:58 +05:30
function toggle(target) {
body = target.parentNode.parentNode.children[1];
2018-08-10 02:31:39 +05:30
if (body.style.display === null || body.style.display === "") {
target.innerHTML = "[ + ]";
body.style.display = "none";
2018-07-28 20:19:58 +05:30
} else {
2018-08-10 02:31:39 +05:30
target.innerHTML = "[ - ]";
body.style.display = "";
2018-07-28 20:19:58 +05:30
}
}
function toggle_comments(target) {
body = target.parentNode.parentNode.parentNode.children[1];
2018-08-10 02:31:39 +05:30
if (body.style.display === null || body.style.display === "") {
target.innerHTML = "[ + ]";
body.style.display = "none";
2018-07-28 20:19:58 +05:30
} else {
2018-08-10 02:31:39 +05:30
target.innerHTML = "[ - ]";
body.style.display = "";
2018-07-28 20:19:58 +05:30
}
}
2018-08-24 03:25:26 +05:30
function get_youtube_replies(target) {
2018-08-10 02:31:39 +05:30
var continuation = target.getAttribute("data-continuation");
2018-07-28 20:19:58 +05:30
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-07-28 20:19:58 +05:30
2018-08-10 02:31:39 +05:30
var url =
"/api/v1/comments/<%= video.id %>?format=html&continuation=" + continuation;
2018-08-05 01:09:41 +05:30
var xhr = new XMLHttpRequest();
2018-08-10 02:31:39 +05:30
xhr.responseType = "json";
2018-08-13 20:28:02 +05:30
xhr.timeout = 20000;
2018-08-05 01:09:41 +05:30
xhr.open("GET", url, true);
xhr.send();
xhr.onreadystatechange = function() {
2018-08-10 02:31:39 +05:30
if (xhr.readyState == 4) {
2018-08-11 20:06:39 +05:30
if (xhr.status == 200) {
2018-08-17 19:55:47 +05:30
body.innerHTML = xhr.response.contentHtml;
2018-08-10 02:37:11 +05:30
} else {
body.innerHTML = fallback;
}
2018-08-05 01:09:41 +05:30
}
2018-08-10 02:31:39 +05:30
};
2018-08-05 01:09:41 +05:30
xhr.ontimeout = function() {
2018-08-24 03:25:26 +05:30
console.log("Pulling comments timed out.");
2018-08-10 02:37:11 +05:30
body.innerHTML = fallback;
2018-08-10 02:31:39 +05:30
};
2018-07-28 20:19:58 +05:30
}
function get_reddit_comments() {
2018-08-10 02:31:39 +05:30
var url = "/api/v1/comments/<%= video.id %>?source=reddit";
2018-08-05 01:09:41 +05:30
var xhr = new XMLHttpRequest();
2018-08-10 02:31:39 +05:30
xhr.responseType = "json";
2018-08-13 20:28:02 +05:30
xhr.timeout = 20000;
2018-08-05 01:09:41 +05:30
xhr.open("GET", url, true);
xhr.send();
2018-08-05 01:09:41 +05:30
xhr.onreadystatechange = function() {
2018-08-10 02:31:39 +05:30
if (xhr.readyState == 4)
if (xhr.status == 200) {
comments = document.getElementById("comments");
2018-08-10 02:37:11 +05:30
comments.innerHTML = `
<div>
<h3>
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a>
{title}
</h3>
<b>
<a target="_blank" href="https://reddit.com{permalink}">View more comments on Reddit</a>
</b>
</div>
2018-08-17 19:55:47 +05:30
<div>{contentHtml}</div>
2018-08-10 02:37:11 +05:30
<hr>`.supplant({
2018-08-05 01:09:41 +05:30
title: xhr.response.title,
permalink: xhr.response.permalink,
2018-08-17 19:55:47 +05:30
contentHtml: xhr.response.contentHtml
2018-08-10 02:37:11 +05:30
});
} else {
get_youtube_comments();
}
2018-08-05 01:09:41 +05:30
};
xhr.ontimeout = function() {
2018-08-24 03:25:26 +05:30
console.log("Pulling comments timed out.");
2018-08-10 02:37:11 +05:30
get_reddit_comments();
2018-08-10 02:31:39 +05:30
};
2018-07-28 20:19:58 +05:30
}
function get_youtube_comments() {
2018-08-10 02:31:39 +05:30
var url = "/api/v1/comments/<%= video.id %>?format=html";
2018-08-05 01:09:41 +05:30
var xhr = new XMLHttpRequest();
2018-08-10 02:31:39 +05:30
xhr.responseType = "json";
2018-08-13 20:28:02 +05:30
xhr.timeout = 20000;
2018-08-05 01:09:41 +05:30
xhr.open("GET", url, true);
xhr.send();
xhr.onreadystatechange = function() {
2018-08-10 02:31:39 +05:30
if (xhr.readyState == 4)
if (xhr.status == 200) {
comments = document.getElementById("comments");
2018-07-28 20:19:58 +05:30
comments.innerHTML = `
2018-08-10 02:37:11 +05:30
<div>
<h3>
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a>
2018-08-17 19:55:47 +05:30
View {commentCount} comments
2018-08-10 02:37:11 +05:30
</h3>
</div>
2018-08-17 19:55:47 +05:30
<div>{contentHtml}</div>
2018-08-10 02:37:11 +05:30
<hr>`.supplant({
2018-08-17 19:55:47 +05:30
contentHtml: xhr.response.contentHtml,
commentCount: commaSeparateNumber(xhr.response.commentCount)
2018-07-28 20:19:58 +05:30
});
2018-08-05 01:09:41 +05:30
} else {
2018-08-10 02:31:39 +05:30
comments = document.getElementById("comments");
comments.innerHTML = "";
2018-08-10 02:37:11 +05:30
}
2018-08-10 02:31:39 +05:30
};
2018-08-05 01:09:41 +05:30
2018-08-10 02:31:39 +05:30
xhr.ontimeout = function() {
2018-08-24 03:25:26 +05:30
console.log("Pulling comments timed out.");
2018-08-13 20:28:02 +05:30
comments = document.getElementById("comments");
comments.innerHTML =
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
2018-08-05 01:09:41 +05:30
get_youtube_comments();
2018-08-10 02:31:39 +05:30
};
2018-07-28 20:19:58 +05:30
}
2018-08-17 19:55:47 +05:30
function commaSeparateNumber(val){
while (/(\d+)(\d{3})/.test(val.toString())){
val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
}
return val;
}
2018-07-28 20:19:58 +05:30
String.prototype.supplant = function(o) {
return this.replace(/{([^{}]*)}/g, function(a, b) {
var r = o[b];
2018-08-10 02:31:39 +05:30
return typeof r === "string" || typeof r === "number" ? r : a;
2018-07-28 20:19:58 +05:30
});
};
2018-07-28 20:19:58 +05:30
<% if preferences && preferences.comments == "reddit" %>
get_reddit_comments();
<% else %>
get_youtube_comments();
<% end %>
2018-01-17 01:28:08 +05:30
</script>
2018-01-16 08:00:57 +05:30
2018-03-13 05:07:01 +05:30
<div class="h-box">
2018-01-17 01:28:08 +05:30
<h1>
<%= HTML.escape(video.title) %>
2018-02-12 04:31:32 +05:30
<% if listen %>
<a href="/watch?<%= env.params.query %>">
2018-08-04 00:53:48 +05:30
<i class="icon ion-ios-videocam"></i>
2018-01-17 01:28:08 +05:30
</a>
<% else %>
2018-08-05 06:57:53 +05:30
<a href="/watch?<%= env.params.query %>&listen=1">
2018-08-04 00:53:48 +05:30
<i class="icon ion-ios-volume-high"></i>
2018-01-17 01:28:08 +05:30
</a>
<% end %>
</h1>
<% if !reason.empty? %>
<h3><%= reason %></h3>
<% end %>
2018-03-11 22:35:56 +05:30
</div>
2018-01-16 08:00:57 +05:30
2018-01-17 01:28:08 +05:30
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-5">
2018-04-18 02:23:12 +05:30
<div class="h-box">
2018-08-04 20:22:10 +05:30
<p><a href="https://www.youtube.com/watch?v=<%= video.id %>">Watch video on YouTube</a></p>
2018-08-04 00:53:48 +05:30
<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-08-13 20:30:13 +05:30
<p id="Genre">Genre: <%= video.genre %></p>
<p id="FamilyFriendly">Family Friendly? <%= video.is_family_friendly %></p>
2018-08-13 20:30:13 +05:30
<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>
2018-08-13 19:47:28 +05:30
<% 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>
2018-03-11 22:35:56 +05:30
</div>
2018-01-16 08:00:57 +05:30
2018-01-17 01:28:08 +05:30
<div class="pure-u-1 pure-u-md-3-5">
2018-04-18 02:23:12 +05:30
<div class="h-box">
<p>
2018-06-03 08:45:15 +05:30
<a href="/channel/<%= video.ucid %>">
<h3><%= video.author %></h3>
</a>
</p>
2018-07-16 21:54:24 +05:30
<% if user %>
2018-06-03 08:45:15 +05:30
<% if subscriptions.includes? video.ucid %>
2018-03-31 20:21:14 +05:30
<p>
2018-08-17 20:49:20 +05:30
<a href="/subscription_ajax?action_remove_subscriptions=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>">
2018-06-03 08:45:15 +05:30
<b>Unsubscribe from <%= video.author %></b>
2018-03-31 20:21:14 +05:30
</a>
</p>
<% else %>
<p>
2018-08-17 20:49:20 +05:30
<a href="/subscription_ajax?action_create_subscription_to_channel=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>">
2018-06-03 08:45:15 +05:30
<b>Subscribe to <%= video.author %></b>
2018-03-31 20:21:14 +05:30
</a>
</p>
<% end %>
2018-05-04 07:06:27 +05:30
<% else %>
<p>
2018-08-17 20:49:20 +05:30
<a href="/login?referer=<%= env.get("current_page") %>">
2018-06-03 08:45:15 +05:30
<b>Login to subscribe to <%= video.author %></b>
2018-05-04 07:06:27 +05:30
</a>
</p>
2018-03-31 20:21:14 +05:30
<% end %>
<p>
<b>Shared <%= video.published.to_s("%B %-d, %Y") %></b>
</p>
2018-04-18 02:23:12 +05:30
<div>
<%= video.description %>
</div>
2018-08-06 04:33:38 +05:30
<hr>
<div id="comments">
<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>
2018-03-13 05:06:08 +05:30
</div>
2018-03-14 05:07:56 +05:30
</div>
2018-03-11 22:35:56 +05:30
</div>
2018-01-17 01:28:08 +05:30
<div class="pure-u-1 pure-u-md-1-5">
2018-04-18 02:23:12 +05:30
<div class="h-box">
<% rvs.each do |rv| %>
<% if rv.has_key?("id") %>
<a href="/watch?v=<%= rv["id"] %>">
2018-07-26 22:39:29 +05:30
<% if preferences && preferences.thin_mode %>
<% else %>
<img style="width:100%;" src="<%= rv["iurlmq"] %>">
<% end %>
<p style="width:100%"><%= rv["title"] %></p>
<p>
<b style="width: 100%"><%= rv["author"] %></b>
</p>
</a>
<% end %>
2018-01-15 08:46:09 +05:30
<% end %>
</div>
2018-01-07 23:20:04 +05:30
</div>
2018-01-17 01:28:08 +05:30
</div>