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

340 lines
18 KiB
Plaintext
Raw Normal View History

<% ucid = video.ucid %>
<% title = HTML.escape(video.title) %>
<% author = HTML.escape(video.author) %>
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 %>">
<meta name="description" content="<%= HTML.escape(video.short_description) %>">
2018-11-02 18:39:28 +05:30
<meta name="keywords" content="<%= video.keywords.join(",") %>">
2018-07-23 06:32:49 +05:30
<meta property="og:site_name" content="Invidious">
2020-06-16 03:40:30 +05:30
<meta property="og:url" content="<%= HOST_URL %>/watch?v=<%= video.id %>">
<meta property="og:title" content="<%= title %>">
2018-09-15 07:54:28 +05:30
<meta property="og:image" content="/vi/<%= video.id %>/maxres.jpg">
2021-11-17 17:34:30 +05:30
<meta property="og:description" content="<%= HTML.escape(video.short_description) %>">
2018-07-23 06:32:49 +05:30
<meta property="og:type" content="video.other">
2020-06-16 03:40:30 +05:30
<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">
2020-06-16 03:40:30 +05:30
<meta name="twitter:url" content="<%= HOST_URL %>/watch?v=<%= video.id %>">
<meta name="twitter:title" content="<%= title %>">
2021-11-17 17:34:30 +05:30
<meta name="twitter:description" content="<%= HTML.escape(video.short_description) %>">
2020-06-16 03:40:30 +05:30
<meta name="twitter:image" content="<%= HOST_URL %>/vi/<%= video.id %>/maxres.jpg">
<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">
<link rel="alternate" href="https://www.youtube.com/watch?v=<%= video.id %>">
<%= rendered "components/player_sources" %>
<title><%= title %> - Invidious</title>
2021-04-02 13:33:26 +05:30
<!-- Description expansion also updates the 'Show more' button to 'Show less' so
2021-04-02 13:33:26 +05:30
we're going to need to do it here in order to allow for translations.
-->
<style>
#descexpansionbutton ~ label > a::after {
content: "<%= translate(locale, "Show more") %>"
2021-04-02 13:33:26 +05:30
}
#descexpansionbutton:checked ~ label > a::after {
content: "<%= translate(locale, "Show less") %>"
2021-04-02 13:33:26 +05:30
}
</style>
2018-01-07 23:10:03 +05:30
<% end %>
2018-01-15 08:46:09 +05:30
<script id="video_data" type="application/json">
2020-03-30 03:14:45 +05:30
<%=
{
2020-03-30 03:14:45 +05:30
"id" => video.id,
"index" => continuation,
"plid" => plid,
"length_seconds" => video.length_seconds.to_f,
2020-06-16 04:03:23 +05:30
"play_next" => !video.related_videos.empty? && !plid && params.continue,
"next_video" => video.related_videos.select { |rv| rv["id"]? }[0]?.try &.["id"],
2020-03-30 03:14:45 +05:30
"youtube_comments_text" => HTML.escape(translate(locale, "View YouTube comments")),
"reddit_comments_text" => HTML.escape(translate(locale, "View Reddit comments")),
"reddit_permalink_text" => HTML.escape(translate(locale, "View more comments on Reddit")),
"comments_text" => HTML.escape(translate(locale, "View `x` comments", "{commentCount}")),
"hide_replies_text" => HTML.escape(translate(locale, "Hide replies")),
"show_replies_text" => HTML.escape(translate(locale, "Show replies")),
"params" => params,
"preferences" => preferences,
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
"vr" => video.is_vr,
"projection_type" => video.projection_type
2020-03-30 03:14:45 +05:30
}.to_pretty_json
%>
2019-05-06 21:53:14 +05:30
</script>
<div id="player-container" class="h-box">
2019-05-02 06:33:39 +05:30
<%= rendered "components/player" %>
2018-03-11 22:35:56 +05:30
</div>
2018-01-17 01:28:08 +05:30
2018-08-26 05:03:15 +05:30
<div class="h-box">
2019-05-02 06:33:39 +05:30
<h1>
<%= title %>
2019-05-02 06:33:39 +05:30
<% if params.listen %>
<a title="<%=translate(locale, "Video mode")%>" href="/watch?<%= env.params.query %>&listen=0">
<i class="icon ion-ios-videocam"></i>
</a>
<% else %>
<a title="<%=translate(locale, "Audio mode")%>" href="/watch?<%= env.params.query %>&listen=1">
<i class="icon ion-md-headset"></i>
</a>
<% end %>
</h1>
<% if !video.is_listed %>
<h3>
2019-08-06 05:24:39 +05:30
<i class="icon ion-ios-unlock"></i> <%= translate(locale, "Unlisted") %>
2019-05-02 06:33:39 +05:30
</h3>
<% end %>
2020-06-16 04:03:23 +05:30
<% if video.reason %>
2019-05-02 06:33:39 +05:30
<h3>
2020-06-16 04:03:23 +05:30
<%= video.reason %>
2019-05-02 06:33:39 +05:30
</h3>
2020-06-16 04:03:23 +05:30
<% elsif video.premiere_timestamp.try &.> Time.utc %>
2019-06-08 20:48:45 +05:30
<h3>
2020-06-16 04:03:23 +05:30
<%= video.premiere_timestamp.try { |t| translate(locale, "Premieres in `x`", recode_date((t - Time.utc).ago, locale)) } %>
2019-06-08 20:48:45 +05:30
</h3>
2021-02-25 09:36:50 +05:30
<% elsif video.live_now %>
<h3>
<%= video.premiere_timestamp.try { |t| translate(locale, "videoinfo_started_streaming_x_ago", recode_date((Time.utc - t).ago, locale)) } %>
2021-02-25 09:36:50 +05:30
</h3>
2018-08-26 05:03:15 +05:30
<% end %>
</div>
<div class="pure-g">
2019-04-15 03:34:52 +05:30
<div class="pure-u-1 pure-u-lg-1-5">
2018-08-26 05:03:15 +05:30
<div class="h-box">
<span id="watch-on-youtube">
<a href="https://www.youtube.com/watch?v=<%= video.id %>"><%= translate(locale, "videoinfo_watch_on_youTube") %></a>
(<a href="https://www.youtube.com/embed/<%= video.id %>"><%= translate(locale, "videoinfo_youTube_embed_link") %></a>)
</span>
2021-03-27 07:13:56 +05:30
<p id="watch-on-another-invidious-instance">
<% if env.get("preferences").as(Preferences).automatic_instance_redirect%>
2021-03-29 11:35:54 +05:30
<a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Switch Invidious Instance") %></a>
<% else %>
<a href="https://redirect.invidious.io<%= env.request.resource %>"><%= translate(locale, "Switch Invidious Instance") %></a>
<% end %>
2021-03-27 07:13:56 +05:30
</p>
2020-12-08 06:58:44 +05:30
<p id="embed-link">
<a href="<%= embed_link %>"><%= translate(locale, "videoinfo_invidious_embed_link") %></a>
2020-12-08 06:58:44 +05:30
</p>
<p id="annotations">
2019-05-02 06:33:39 +05:30
<% if params.annotations %>
<a href="/watch?<%= env.params.query %>&iv_load_policy=3">
<%= translate(locale, "Hide annotations") %>
</a>
<% else %>
<a href="/watch?<%= env.params.query %>&iv_load_policy=1">
<%=translate(locale, "Show annotations")%>
</a>
<% end %>
2019-05-01 10:09:04 +05:30
</p>
<% if user %>
<% playlists = Invidious::Database::Playlists.select_user_created_playlists(user.email) %>
<% if !playlists.empty? %>
<form data-onsubmit="return_false" class="pure-form pure-form-stacked" action="/playlist_ajax" method="post" target="_blank">
<div class="pure-control-group">
<label for="playlist_id"><%= translate(locale, "Add to playlist: ") %></label>
<select style="width:100%" name="playlist_id" id="playlist_id">
<% playlists.each do |plid, playlist_title| %>
<option data-plid="<%= plid %>" value="<%= plid %>"><%= HTML.escape(playlist_title) %></option>
<% end %>
</select>
</div>
<input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>">
<input type="hidden" name="action_add_video" value="1">
<input type="hidden" name="video_id" value="<%= video.id %>">
<button data-onclick="add_playlist_video" data-id="<%= video.id %>" type="submit" class="pure-button pure-button-primary">
<b><%= translate(locale, "Add to playlist") %></b>
</button>
</form>
<script id="playlist_data" type="application/json">
<%=
{
"csrf_token" => URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "")
}.to_pretty_json
%>
</script>
<script src="/js/playlist_widget.js?v=<%= Time.utc.to_unix_ms %>"></script>
<% end %>
<% end %>
<% if CONFIG.dmca_content.includes?(video.id) || CONFIG.disabled?("downloads") %>
<p id="download"><%= translate(locale, "Download is disabled.") %></p>
<% else %>
2019-05-02 06:33:39 +05:30
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
<div class="pure-control-group">
<label for="download_widget"><%= translate(locale, "Download as: ") %></label>
<select style="width:100%" name="download_widget" id="download_widget">
<% fmt_stream.each do |option| %>
2020-06-16 04:03:23 +05:30
<option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= option["mimeType"].as_s.split(";")[0].split("/")[1] %>"}'>
<%= itag_to_metadata?(option["itag"]).try &.["height"]? || "~240" %>p - <%= option["mimeType"].as_s.split(";")[0] %>
2019-05-02 06:33:39 +05:30
</option>
<% end %>
<% video_streams.each do |option| %>
2020-06-16 04:03:23 +05:30
<option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= option["mimeType"].as_s.split(";")[0].split("/")[1] %>"}'>
<%= option["qualityLabel"] %> - <%= option["mimeType"].as_s.split(";")[0] %> @ <%= option["fps"] %>fps - video only
2019-05-02 06:33:39 +05:30
</option>
<% end %>
<% audio_streams.each do |option| %>
2020-06-16 04:03:23 +05:30
<option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= option["mimeType"].as_s.split(";")[0].split("/")[1] %>"}'>
<%= option["mimeType"].as_s.split(";")[0] %> @ <%= option["bitrate"]?.try &.as_i./ 1000 %>k - audio only
2019-05-02 06:33:39 +05:30
</option>
<% end %>
<% captions.each do |caption| %>
2021-09-25 07:45:23 +05:30
<option value='{"id":"<%= video.id %>","label":"<%= caption.name %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= caption.language_code %>.vtt"}'>
<%= translate(locale, "download_subtitles", translate(locale, caption.name)) %>
2019-05-02 06:33:39 +05:30
</option>
<% end %>
</select>
</div>
2019-01-24 06:35:24 +05:30
2019-05-02 06:33:39 +05:30
<button type="submit" class="pure-button pure-button-primary">
<b><%= translate(locale, "Download") %></b>
</button>
</form>
<% end %>
2019-01-24 06:35:24 +05:30
<p id="views"><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p>
<p id="likes"><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p>
<p id="dislikes"><i class="icon ion-ios-thumbs-down"></i> <%= number_with_separator(video.dislikes) %></p>
2019-05-02 06:33:39 +05:30
<p id="genre"><%= translate(locale, "Genre: ") %>
2020-06-16 04:03:23 +05:30
<% if !video.genre_url %>
2019-05-02 06:33:39 +05:30
<%= video.genre %>
<% else %>
<a href="<%= video.genre_url %>"><%= video.genre %></a>
<% end %>
2018-09-25 20:40:25 +05:30
</p>
2020-06-16 04:03:23 +05:30
<% if video.license %>
2019-05-02 06:33:39 +05:30
<p id="license"><%= translate(locale, "License: ") %><%= video.license %></p>
2018-09-10 01:17:26 +05:30
<% end %>
2019-05-02 06:33:39 +05:30
<p id="family_friendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p>
2020-06-16 04:03:23 +05:30
<p id="wilson"><%= translate(locale, "Wilson score: ") %><%= video.wilson_score %></p>
<p id="rating"><%= translate(locale, "Rating: ") %><%= video.average_rating %> / 5</p>
<p id="engagement"><%= translate(locale, "Engagement: ") %><%= video.engagement %>%</p>
2018-08-26 05:03:15 +05:30
<% if video.allowed_regions.size != REGIONS.size %>
2019-05-02 06:33:39 +05:30
<p id="allowed_regions">
2019-06-08 06:53:37 +05:30
<% if video.allowed_regions.size < REGIONS.size // 2 %>
2019-05-02 06:33:39 +05:30
<%= translate(locale, "Whitelisted regions: ") %><%= video.allowed_regions.join(", ") %>
<% else %>
<%= translate(locale, "Blacklisted regions: ") %><%= (REGIONS.to_a - video.allowed_regions).join(", ") %>
<% end %>
2018-08-26 05:03:15 +05:30
</p>
<% end %>
</div>
</div>
2019-05-01 10:09:04 +05:30
<div class="pure-u-1 <% if params.related_videos || plid %>pure-u-lg-3-5<% else %>pure-u-md-4-5<% end %>">
2018-08-26 05:03:15 +05:30
<div class="h-box">
2019-07-03 21:23:33 +05:30
<a href="/channel/<%= video.ucid %>" style="display:block;width:fit-content;width:-moz-fit-content">
<div class="channel-profile">
2020-06-16 04:03:23 +05:30
<% if !video.author_thumbnail.empty? %>
<img src="/ggpht<%= URI.parse(video.author_thumbnail).request_target %>">
2020-06-16 04:03:23 +05:30
<% end %>
<span id="channel-name"><%= author %></span>
</div>
</a>
2019-05-02 06:33:39 +05:30
<% sub_count_text = video.sub_count_text %>
<%= rendered "components/subscribe_widget" %>
2019-05-02 06:33:39 +05:30
<p id="published-date">
2020-06-16 04:03:23 +05:30
<% if video.premiere_timestamp.try &.> Time.utc %>
<b><%= video.premiere_timestamp.try { |t| translate(locale, "Premieres `x`", t.to_s("%B %-d, %R UTC")) } %></b>
2019-06-08 20:48:45 +05:30
<% else %>
<b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b>
<% end %>
2018-08-26 05:03:15 +05:30
</p>
2019-05-02 06:33:39 +05:30
2021-04-02 13:33:26 +05:30
<div id="description-box"> <!-- Description -->
<% if video.description.size < 200 || params.extend_desc %>
<div id="descriptionWrapper"><%= video.description_html %></div>
<% else %>
<input id="descexpansionbutton" type="checkbox"/>
<div id="descriptionWrapper"><%= video.description_html %></div>
<label for="descexpansionbutton">
<a></a>
</label>
<% end %>
2018-08-26 05:03:15 +05:30
</div>
2019-05-02 06:33:39 +05:30
2018-08-26 05:03:15 +05:30
<hr>
2019-05-02 06:33:39 +05:30
2018-08-26 05:03:15 +05:30
<div id="comments">
<% if nojs %>
<%= comment_html %>
<% else %>
2019-05-02 06:33:39 +05:30
<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 %>
2018-08-26 05:03:15 +05:30
</div>
</div>
</div>
2018-10-08 07:41:33 +05:30
2019-05-02 06:33:39 +05:30
<% if params.related_videos || plid %>
<div class="pure-u-1 pure-u-lg-1-5">
<% if plid %>
<div id="playlist" class="h-box"></div>
<% end %>
2018-11-11 23:15:05 +05:30
2019-05-02 06:33:39 +05:30
<% if params.related_videos %>
<div class="h-box">
2020-06-16 04:03:23 +05:30
<% if !video.related_videos.empty? %>
2019-05-02 06:33:39 +05:30
<div <% if plid %>style="display:none"<% end %>>
<div class="pure-control-group">
<label for="continue"><%= translate(locale, "preferences_continue_label") %></label>
2019-05-16 00:00:30 +05:30
<input name="continue" id="continue" type="checkbox" <% if params.continue %>checked<% end %>>
2019-05-02 06:33:39 +05:30
</div>
<hr>
</div>
<% end %>
2019-04-28 22:37:19 +05:30
2020-06-16 04:03:23 +05:30
<% video.related_videos.each do |rv| %>
2019-05-02 06:33:39 +05:30
<% if rv["id"]? %>
<a href="/watch?v=<%= rv["id"] %>">
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
2021-10-14 20:48:44 +05:30
<img loading="lazy" class="thumbnail" src="/vi/<%= rv["id"] %>/mqdefault.jpg">
2019-05-02 06:33:39 +05:30
<p class="length"><%= recode_length_seconds(rv["length_seconds"]?.try &.to_i? || 0) %></p>
</div>
<% end %>
<p style="width:100%"><%= rv["title"] %></p>
<h5 class="pure-g">
<div class="pure-u-14-24">
2019-08-27 18:30:04 +05:30
<% if rv["ucid"]? %>
2020-06-16 04:03:23 +05:30
<b style="width:100%"><a href="/channel/<%= rv["ucid"] %>"><%= rv["author"]? %></a></b>
2019-08-27 18:30:04 +05:30
<% else %>
2020-06-16 04:03:23 +05:30
<b style="width:100%"><%= rv["author"]? %></b>
2019-08-27 18:30:04 +05:30
<% end %>
2019-05-02 06:33:39 +05:30
</div>
<div class="pure-u-10-24" style="text-align:right">
<% if views = rv["short_view_count_text"]?.try &.delete(", views watching") %>
2020-06-16 04:03:23 +05:30
<% if !views.empty? %>
<b class="width:100%"><%= translate_count(locale, "generic_views_count", views.to_i? || 0) %></b>
2020-06-16 04:03:23 +05:30
<% end %>
2019-05-02 06:33:39 +05:30
<% end %>
</div>
</h5>
</a>
2019-04-28 22:37:19 +05:30
<% end %>
2019-05-02 06:33:39 +05:30
<% end %>
</div>
2018-08-26 05:03:15 +05:30
<% end %>
</div>
<% end %>
2018-08-26 05:03:15 +05:30
</div>
<script src="/js/watch.js?v=<%= ASSET_COMMIT %>"></script>