summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com>2021-05-22 14:10:09 +0200
committerGitHub <noreply@github.com>2021-05-22 14:10:09 +0200
commitf66cfa129953e43d44b8435e00e019a2efbd5fc1 (patch)
tree72516b5a1e63b3000fe5dba83db091e7ed8eb300 /src
parentb38fab97387f9b67c971ec5031369e3a8071762f (diff)
parent9e84a4dbab07ca2c6f334369b453816ce2d5ee09 (diff)
downloadinvidious-f66cfa129953e43d44b8435e00e019a2efbd5fc1.tar.gz
invidious-f66cfa129953e43d44b8435e00e019a2efbd5fc1.tar.bz2
invidious-f66cfa129953e43d44b8435e00e019a2efbd5fc1.zip
Merge branch 'master' into patch-2
Diffstat (limited to 'src')
-rw-r--r--src/invidious/comments.cr8
-rw-r--r--src/invidious/helpers/helpers.cr3
-rw-r--r--src/invidious/users.cr1
-rw-r--r--src/invidious/videos.cr8
-rw-r--r--src/invidious/views/components/player_sources.ecr3
-rw-r--r--src/invidious/views/licenses.ecr14
-rw-r--r--src/invidious/views/preferences.ecr6
-rw-r--r--src/invidious/views/search_homepage.ecr2
-rw-r--r--src/invidious/views/watch.ecr27
9 files changed, 64 insertions, 8 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 5d72503e..81d6ac2b 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -185,12 +185,14 @@ def fetch_youtube_comments(id, db, cursor, format, locale, thin_mode, region, so
json.field "published", published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
- json.field "likeCount", node_comment["likeCount"]
+ comment_action_buttons_renderer = node_comment["actionButtons"]["commentActionButtonsRenderer"]
+
+ json.field "likeCount", comment_action_buttons_renderer["likeButton"]["toggleButtonRenderer"]["accessibilityData"]["accessibilityData"]["label"].as_s.scan(/\d/).map(&.[0]).join.to_i
json.field "commentId", node_comment["commentId"]
json.field "authorIsChannelOwner", node_comment["authorIsChannelOwner"]
- if node_comment["actionButtons"]["commentActionButtonsRenderer"]["creatorHeart"]?
- hearth_data = node_comment["actionButtons"]["commentActionButtonsRenderer"]["creatorHeart"]["creatorHeartRenderer"]["creatorThumbnail"]
+ if comment_action_buttons_renderer["creatorHeart"]?
+ hearth_data = comment_action_buttons_renderer["creatorHeart"]["creatorHeartRenderer"]["creatorThumbnail"]
json.field "creatorHeart" do
json.object do
json.field "creatorThumbnail", hearth_data["thumbnails"][-1]["url"]
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 3767cb50..e1d877b7 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -50,6 +50,7 @@ struct ConfigPreferences
property thin_mode : Bool = false
property unseen_only : Bool = false
property video_loop : Bool = false
+ property extend_desc : Bool = false
property volume : Int32 = 100
def to_tuple
@@ -679,7 +680,7 @@ def create_notification_stream(env, topics, connection_channel)
end
def extract_initial_data(body) : Hash(String, JSON::Any)
- return JSON.parse(body.match(/(window\["ytInitialData"\]|var\s*ytInitialData)\s*=\s*(?<info>\{.*?\});/mx).try &.["info"] || "{}").as_h
+ return JSON.parse(body.match(/(window\["ytInitialData"\]|var\s*ytInitialData)\s*=\s*(?<info>{.*?});<\/script>/mx).try &.["info"] || "{}").as_h
end
def proxy_file(response, env)
diff --git a/src/invidious/users.cr b/src/invidious/users.cr
index 8fef64a0..e4ebb4d1 100644
--- a/src/invidious/users.cr
+++ b/src/invidious/users.cr
@@ -78,6 +78,7 @@ struct Preferences
property thin_mode : Bool = CONFIG.default_user_preferences.thin_mode
property unseen_only : Bool = CONFIG.default_user_preferences.unseen_only
property video_loop : Bool = CONFIG.default_user_preferences.video_loop
+ property extend_desc : Bool = CONFIG.default_user_preferences.extend_desc
property volume : Int32 = CONFIG.default_user_preferences.volume
module BoolToString
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 38646311..bf281507 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -242,6 +242,7 @@ struct VideoPreferences
property speed : Float32 | Float64
property video_end : Float64 | Int32
property video_loop : Bool
+ property extend_desc : Bool
property video_start : Float64 | Int32
property volume : Int32
end
@@ -818,7 +819,7 @@ end
def extract_polymer_config(body)
params = {} of String => JSON::Any
- player_response = body.match(/(window\["ytInitialPlayerResponse"\]|var\sytInitialPlayerResponse)\s*=\s*(?<info>{.*?});/m)
+ player_response = body.match(/(window\["ytInitialPlayerResponse"\]|var\sytInitialPlayerResponse)\s*=\s*(?<info>{.*?});\s*var\s*meta/m)
.try { |r| JSON.parse(r["info"]).as_h }
if body.includes?("To continue with your YouTube experience, please fill out the form below.") ||
@@ -1050,6 +1051,7 @@ def process_video_params(query, preferences)
related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe }
speed = query["speed"]?.try &.rchop("x").to_f?
video_loop = query["loop"]?.try { |q| (q == "true" || q == "1").to_unsafe }
+ extend_desc = query["extend_desc"]?.try { |q| (q == "true" || q == "1").to_unsafe }
volume = query["volume"]?.try &.to_i?
if preferences
@@ -1068,6 +1070,7 @@ def process_video_params(query, preferences)
related_videos ||= preferences.related_videos.to_unsafe
speed ||= preferences.speed
video_loop ||= preferences.video_loop.to_unsafe
+ extend_desc ||= preferences.extend_desc.to_unsafe
volume ||= preferences.volume
end
@@ -1085,6 +1088,7 @@ def process_video_params(query, preferences)
related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe
speed ||= CONFIG.default_user_preferences.speed
video_loop ||= CONFIG.default_user_preferences.video_loop.to_unsafe
+ extend_desc ||= CONFIG.default_user_preferences.extend_desc.to_unsafe
volume ||= CONFIG.default_user_preferences.volume
annotations = annotations == 1
@@ -1095,6 +1099,7 @@ def process_video_params(query, preferences)
local = local == 1
related_videos = related_videos == 1
video_loop = video_loop == 1
+ extend_desc = extend_desc == 1
if CONFIG.disabled?("dash") && quality == "dash"
quality = "high"
@@ -1141,6 +1146,7 @@ def process_video_params(query, preferences)
speed: speed,
video_end: video_end,
video_loop: video_loop,
+ extend_desc: extend_desc,
video_start: video_start,
volume: volume,
})
diff --git a/src/invidious/views/components/player_sources.ecr b/src/invidious/views/components/player_sources.ecr
index d950e0da..a99fdbca 100644
--- a/src/invidious/views/components/player_sources.ecr
+++ b/src/invidious/views/components/player_sources.ecr
@@ -3,7 +3,10 @@
<link rel="stylesheet" href="/css/videojs.markers.min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-share.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-vtt-thumbnails.css?v=<%= ASSET_COMMIT %>">
+<link rel="stylesheet" href="/css/videojs-mobile-ui.css?v=<%= ASSET_COMMIT %>">
+<link rel="stylesheet" href="/css/player.css?v=<%= ASSET_COMMIT %>">
<script src="/js/video.min.js?v=<%= ASSET_COMMIT %>"></script>
+<script src="/js/videojs-mobile-ui.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-contrib-quality-levels.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-http-source-selector.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-markers.min.js?v=<%= ASSET_COMMIT %>"></script>
diff --git a/src/invidious/views/licenses.ecr b/src/invidious/views/licenses.ecr
index aae8bb19..c2ada992 100644
--- a/src/invidious/views/licenses.ecr
+++ b/src/invidious/views/licenses.ecr
@@ -151,6 +151,20 @@
<tr>
<td>
+ <a href="/js/videojs-mobile-ui.min.js?v=<%= ASSET_COMMIT %>">videojs-mobile-ui.min.js</a>
+ </td>
+
+ <td>
+ <a href="https://choosealicense.com/licenses/mit/">MIT</a>
+ </td>
+
+ <td>
+ <a href="https://github.com/mister-ben/videojs-mobile-ui"><%= translate(locale, "source") %></a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
<a href="/js/videojs-markers.min.js?v=<%= ASSET_COMMIT %>">videojs-markers.min.js</a>
</td>
diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr
index c1f10818..602340a4 100644
--- a/src/invidious/views/preferences.ecr
+++ b/src/invidious/views/preferences.ecr
@@ -106,6 +106,12 @@
<input name="annotations" id="annotations" type="checkbox" <% if preferences.annotations %>checked<% end %>>
</div>
+ <div class="pure-control-group">
+ <label for="extend_desc"><%= translate(locale, "Automatically extend video description: ") %></label>
+ <input name="extend_desc" id="extend_desc" type="checkbox" <% if preferences.extend_desc %>checked<% end %>>
+ </div>
+
+
<legend><%= translate(locale, "Visual preferences") %></legend>
<div class="pure-control-group">
diff --git a/src/invidious/views/search_homepage.ecr b/src/invidious/views/search_homepage.ecr
index b36500e9..8927c3f1 100644
--- a/src/invidious/views/search_homepage.ecr
+++ b/src/invidious/views/search_homepage.ecr
@@ -16,7 +16,7 @@
<div class="pure-u-1 pure-u-md-12-24 searchbar">
<form class="pure-form" action="/search" method="get">
<fieldset>
- <input type="search" style="width:100%" name="q" placeholder="<%= translate(locale, "search") %>" value="<%= env.get?("search").try {|x| HTML.escape(x.as(String)) } %>">
+ <input autofocus type="search" style="width:100%" name="q" placeholder="<%= translate(locale, "search") %>" value="<%= env.get?("search").try {|x| HTML.escape(x.as(String)) } %>">
</fieldset>
</form>
</div>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index a86e23b2..8b587eb3 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -25,6 +25,19 @@
<link rel="alternate" href="https://www.youtube.com/watch?v=<%= video.id %>">
<%= rendered "components/player_sources" %>
<title><%= HTML.escape(video.title) %> - Invidious</title>
+
+<!-- Description expansion also updates the 'Show more' button to 'Show less' so
+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") %>"
+}
+
+#descexpansionbutton:checked + label > a::after {
+ content: "<%= translate(locale, "Show less") %>"
+}
+</style>
<% end %>
<script id="video_data" type="application/json">
@@ -227,8 +240,18 @@
<% end %>
</p>
- <div>
- <%= video.description_html %>
+ <div id="description-box"> <!-- Description -->
+ <% if video.description.size < 200 || params.extend_desc %>
+ <%= video.description_html %>
+ <% else %>
+ <input id="descexpansionbutton" type="checkbox"/>
+ <label for="descexpansionbutton" style="order: 1;">
+ <a></a>
+ </label>
+ <div id="descriptionWrapper">
+ <%= video.description_html %>
+ </div>
+ <% end %>
</div>
<hr>