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

328 行
16 KiB
Plaintext
Raw 通常表示 履歴

<% ucid = video.ucid %>
<% title = HTML.escape(video.title) %>
<% author = HTML.escape(video.author) %>
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 %>">
<meta name="description" content="<%= HTML.escape(video.short_description) %>">
2018-11-02 22:09:28 +09:00
<meta name="keywords" content="<%= video.keywords.join(",") %>">
<meta property="og:site_name" content="<%= author %> | Invidious">
2020-06-16 07:10:30 +09:00
<meta property="og:url" content="<%= HOST_URL %>/watch?v=<%= video.id %>">
<meta property="og:title" content="<%= title %>">
2018-09-15 11:24:28 +09:00
<meta property="og:image" content="/vi/<%= video.id %>/maxres.jpg">
2021-11-17 21:04:30 +09:00
<meta property="og:description" content="<%= HTML.escape(video.short_description) %>">
2018-07-23 10:02:49 +09:00
<meta property="og:type" content="video.other">
2020-06-16 07:10:30 +09: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 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">
2020-06-16 07:10:30 +09:00
<meta name="twitter:url" content="<%= HOST_URL %>/watch?v=<%= video.id %>">
<meta name="twitter:title" content="<%= title %>">
2021-11-17 21:04:30 +09:00
<meta name="twitter:description" content="<%= HTML.escape(video.short_description) %>">
2020-06-16 07:10:30 +09:00
<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 13:20:49 +09:00
<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 17:03:26 +09:00
<!-- Description expansion also updates the 'Show more' button to 'Show less' so
2021-04-02 17:03:26 +09:00
we're going to need to do it here in order to allow for translations.
-->
<style>
2023-01-22 08:12:04 +09:00
#descexpansionbutton ~ label > a::after {
content: "<%= translate(locale, "Show more") %>"
2021-04-02 17:03:26 +09:00
}
2023-01-22 08:12:04 +09:00
#descexpansionbutton:checked ~ label > a::after {
content: "<%= translate(locale, "Show less") %>"
2021-04-02 17:03:26 +09:00
}
</style>
2018-01-08 02:40:03 +09:00
<% end %>
2018-01-15 12:16:09 +09:00
<script id="video_data" type="application/json">
2020-03-30 06:44:45 +09:00
<%=
{
2020-03-30 06:44:45 +09:00
"id" => video.id,
"index" => continuation,
"plid" => plid,
"length_seconds" => video.length_seconds.to_f,
2020-06-16 07:33:23 +09:00
"play_next" => !video.related_videos.empty? && !plid && params.continue,
"next_video" => video.related_videos.select { |rv| rv["id"]? }[0]?.try &.["id"],
2020-03-30 06:44:45 +09:00
"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,
2022-04-23 05:37:45 +09:00
"projection_type" => video.projection_type,
"local_disabled" => CONFIG.disabled?("local")
2020-03-30 06:44:45 +09:00
}.to_pretty_json
%>
2019-05-07 01:23:14 +09:00
</script>
<div id="player-container" class="h-box">
2019-05-02 10:03:39 +09:00
<%= 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">
2019-05-02 10:03:39 +09:00
<h1>
<%= title %>
2019-05-02 10:03:39 +09:00
<% 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 08:54:39 +09:00
<i class="icon ion-ios-unlock"></i> <%= translate(locale, "Unlisted") %>
2019-05-02 10:03:39 +09:00
</h3>
<% end %>
2020-06-16 07:33:23 +09:00
<% if video.reason %>
2019-05-02 10:03:39 +09:00
<h3>
2020-06-16 07:33:23 +09:00
<%= video.reason %>
2019-05-02 10:03:39 +09:00
</h3>
2020-06-16 07:33:23 +09:00
<% elsif video.premiere_timestamp.try &.> Time.utc %>
2019-06-09 00:18:45 +09:00
<h3>
2020-06-16 07:33:23 +09:00
<%= video.premiere_timestamp.try { |t| translate(locale, "Premieres in `x`", recode_date((t - Time.utc).ago, locale)) } %>
2019-06-09 00:18:45 +09:00
</h3>
2021-02-25 13:06:50 +09:00
<% 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 13:06:50 +09:00
</h3>
2018-08-26 08:33:15 +09:00
<% end %>
</div>
<div class="pure-g">
2019-04-15 07:04:52 +09:00
<div class="pure-u-1 pure-u-lg-1-5">
2018-08-26 08:33:15 +09:00
<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 10:43:56 +09:00
<p id="watch-on-another-invidious-instance">
<% if env.get("preferences").as(Preferences).automatic_instance_redirect%>
2021-03-29 15:05:54 +09:00
<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 10:43:56 +09:00
</p>
2020-12-08 10:28:44 +09:00
<p id="embed-link">
<a href="<%= embed_link %>"><%= translate(locale, "videoinfo_invidious_embed_link") %></a>
2020-12-08 10:28:44 +09:00
</p>
<p id="annotations">
2019-05-02 10:03:39 +09:00
<% 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 13:39:04 +09:00
</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 %>
<%= Invidious::Frontend::WatchPage.download_widget(locale, video, video_assets) %>
2019-01-24 10:05:24 +09:00
<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" style="display: none; visibility: hidden;"></p>
2019-05-02 10:03:39 +09:00
<p id="genre"><%= translate(locale, "Genre: ") %>
2020-06-16 07:33:23 +09:00
<% if !video.genre_url %>
2019-05-02 10:03:39 +09:00
<%= video.genre %>
<% else %>
<a href="<%= video.genre_url %>"><%= video.genre %></a>
<% end %>
2018-09-26 00:10:25 +09:00
</p>
2020-06-16 07:33:23 +09:00
<% if video.license %>
2019-05-02 10:03:39 +09:00
<p id="license"><%= translate(locale, "License: ") %><%= video.license %></p>
2018-09-10 04:47:26 +09:00
<% end %>
2019-05-02 10:03:39 +09:00
<p id="family_friendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p>
<p id="wilson" style="display: none; visibility: hidden;"></p>
<p id="rating" style="display: none; visibility: hidden;"></p>
<p id="engagement" style="display: none; visibility: hidden;"></p>
2018-08-26 08:33:15 +09:00
<% if video.allowed_regions.size != REGIONS.size %>
2019-05-02 10:03:39 +09:00
<p id="allowed_regions">
2019-06-08 10:23:37 +09:00
<% if video.allowed_regions.size < REGIONS.size // 2 %>
2019-05-02 10:03:39 +09:00
<%= translate(locale, "Whitelisted regions: ") %><%= video.allowed_regions.join(", ") %>
<% else %>
<%= translate(locale, "Blacklisted regions: ") %><%= (REGIONS.to_a - video.allowed_regions).join(", ") %>
<% end %>
2018-08-26 08:33:15 +09:00
</p>
<% end %>
</div>
</div>
2019-05-01 13:39:04 +09: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-26 08:33:15 +09:00
<div class="h-box">
2019-07-04 00:53:33 +09:00
<a href="/channel/<%= video.ucid %>" style="display:block;width:fit-content;width:-moz-fit-content">
<div class="channel-profile">
2020-06-16 07:33:23 +09:00
<% if !video.author_thumbnail.empty? %>
<img src="/ggpht<%= URI.parse(video.author_thumbnail).request_target %>">
2020-06-16 07:33:23 +09:00
<% end %>
2022-05-02 04:10:43 +09:00
<span id="channel-name"><%= author %><% if !video.author_verified.nil? && video.author_verified %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></span>
</div>
</a>
2019-05-02 10:03:39 +09:00
<% sub_count_text = video.sub_count_text %>
<%= rendered "components/subscribe_widget" %>
2019-05-02 10:03:39 +09:00
<p id="published-date">
2020-06-16 07:33:23 +09:00
<% 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-09 00:18:45 +09:00
<% else %>
<b><%= translate(locale, "Shared `x`", video.published.to_s("%B %-d, %Y")) %></b>
<% end %>
2018-08-26 08:33:15 +09:00
</p>
2019-05-02 10:03:39 +09:00
2021-04-02 17:03:26 +09:00
<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 08:33:15 +09:00
</div>
2019-05-02 10:03:39 +09:00
2018-08-26 08:33:15 +09:00
<hr>
2019-05-02 10:03:39 +09:00
2023-01-16 21:58:05 +09:00
<% if !video.music.empty? %>
2023-01-22 08:12:04 +09:00
<input id="music-desc-expansion" type="checkbox"/>
<label for="music-desc-expansion">
<h3 id="music-description-title">
<%= translate(locale, "Music in this video") %>
<span class="icon ion-ios-arrow-up"></span>
<span class="icon ion-ios-arrow-down"></span>
</h3>
</label>
2023-01-16 21:58:05 +09:00
<div id="music-description-box">
2023-01-22 08:12:04 +09:00
<% video.music.each do |music| %>
<div class="music-item">
2023-03-08 01:38:09 +09:00
<p class="music-song"><%= translate(locale, "Song: ") %><%= music.song %></p>
<p class="music-artist"><%= translate(locale, "Artist: ") %><%= music.artist %></p>
<p class="music-album"><%= translate(locale, "Album: ") %><%= music.album %></p>
2023-01-16 21:58:05 +09:00
</div>
<% end %>
</div>
<hr>
<% end %>
2018-08-26 08:33:15 +09:00
<div id="comments">
<% if nojs %>
<%= comment_html %>
<% else %>
2019-05-02 10:03:39 +09:00
<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 08:33:15 +09:00
</div>
</div>
</div>
2018-10-08 11:11:33 +09:00
2019-05-02 10:03:39 +09:00
<% 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-12 02:45:05 +09:00
2019-05-02 10:03:39 +09:00
<% if params.related_videos %>
<div class="h-box">
2020-06-16 07:33:23 +09:00
<% if !video.related_videos.empty? %>
2019-05-02 10:03:39 +09:00
<div <% if plid %>style="display:none"<% end %>>
<div class="pure-control-group">
<label for="continue"><%= translate(locale, "preferences_continue_label") %></label>
2019-05-16 03:30:30 +09:00
<input name="continue" id="continue" type="checkbox" <% if params.continue %>checked<% end %>>
2019-05-02 10:03:39 +09:00
</div>
<hr>
</div>
<% end %>
2019-04-29 02:07:19 +09:00
2020-06-16 07:33:23 +09:00
<% video.related_videos.each do |rv| %>
2019-05-02 10:03:39 +09:00
<% if rv["id"]? %>
<a href="/watch?v=<%= rv["id"] %>&listen=<%= params.listen %>">
2019-05-02 10:03:39 +09:00
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
2021-10-15 00:18:44 +09:00
<img loading="lazy" class="thumbnail" src="/vi/<%= rv["id"] %>/mqdefault.jpg">
2019-05-02 10:03:39 +09:00
<p class="length"><%= recode_length_seconds(rv["length_seconds"]?.try &.to_i? || 0) %></p>
</div>
<% end %>
<p style="width:100%"><%= rv["title"] %></p>
</a>
<h5 class="pure-g">
<div class="pure-u-14-24">
<% if rv["ucid"]? %>
<b style="width:100%"><a href="/channel/<%= rv["ucid"] %>"><%= rv["author"]? %><% if rv["author_verified"]? == "true" %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></a></b>
<% else %>
<b style="width:100%"><%= rv["author"]? %><% if rv["author_verified"]? == "true" %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></b>
<% end %>
</div>
<div class="pure-u-10-24" style="text-align:right">
<b class="width:100%"><%=
views = rv["view_count"]?.try &.to_i?
views ||= rv["view_count_short"]?.try { |x| short_text_to_number(x) }
translate_count(locale, "generic_views_count", views || 0, NumberFormatting::Short)
%></b>
</div>
</h5>
2019-04-29 02:07:19 +09:00
<% end %>
2019-05-02 10:03:39 +09:00
<% end %>
</div>
2018-08-26 08:33:15 +09:00
<% end %>
</div>
<% end %>
2018-08-26 08:33:15 +09:00
</div>
<script src="/js/watch.js?v=<%= ASSET_COMMIT %>"></script>