diff options
| author | TheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com> | 2021-05-23 16:27:47 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-23 16:27:47 +0000 |
| commit | 993d731c92f6f07e4bee4a222c02e1e47d7f9d6e (patch) | |
| tree | e4efee34312ae38eb5b9dcb60c7fe21840d38747 /src | |
| parent | 8806c57c63b2d3cba9969a9c4f56eb1e43f96cb4 (diff) | |
| parent | f529948d8140ddb785ff6d6bf20c9ca5a0e204b8 (diff) | |
| download | invidious-993d731c92f6f07e4bee4a222c02e1e47d7f9d6e.tar.gz invidious-993d731c92f6f07e4bee4a222c02e1e47d7f9d6e.tar.bz2 invidious-993d731c92f6f07e4bee4a222c02e1e47d7f9d6e.zip | |
Merge pull request #2010 from syeopite/360videosupport
Add experimental support for 360° videos
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/helpers/helpers.cr | 1 | ||||
| -rw-r--r-- | src/invidious/routes/preferences.cr | 5 | ||||
| -rw-r--r-- | src/invidious/users.cr | 1 | ||||
| -rw-r--r-- | src/invidious/videos.cr | 10 | ||||
| -rw-r--r-- | src/invidious/views/components/player_sources.ecr | 7 | ||||
| -rw-r--r-- | src/invidious/views/licenses.ecr | 14 | ||||
| -rw-r--r-- | src/invidious/views/preferences.ecr | 4 | ||||
| -rw-r--r-- | src/invidious/views/watch.ecr | 3 |
8 files changed, 44 insertions, 1 deletions
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index e1d877b7..1f92c4ce 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -52,6 +52,7 @@ struct ConfigPreferences property video_loop : Bool = false property extend_desc : Bool = false property volume : Int32 = 100 + property vr_mode : Bool = true def to_tuple {% begin %} diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index 4901d22b..815c1c70 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -60,6 +60,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute volume = env.params.body["volume"]?.try &.as(String).to_i? volume ||= CONFIG.default_user_preferences.volume + vr_mode = env.params.body["vr_mode"]?.try &.as(String) + vr_mode ||= "off" + vr_mode = vr_mode == "on" + comments = [] of String 2.times do |i| comments << (env.params.body["comments[#{i}]"]?.try &.as(String) || CONFIG.default_user_preferences.comments[i]) @@ -140,6 +144,7 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute unseen_only: unseen_only, video_loop: video_loop, volume: volume, + vr_mode: vr_mode, }.to_json).to_json if user = env.get? "user" diff --git a/src/invidious/users.cr b/src/invidious/users.cr index e4ebb4d1..5dfd80bb 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -53,6 +53,7 @@ struct Preferences property latest_only : Bool = CONFIG.default_user_preferences.latest_only property listen : Bool = CONFIG.default_user_preferences.listen property local : Bool = CONFIG.default_user_preferences.local + property vr_mode : Bool = CONFIG.default_user_preferences.vr_mode @[JSON::Field(converter: Preferences::ProcessString)] property locale : String = CONFIG.default_user_preferences.locale diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index bf281507..116aafc7 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -245,6 +245,7 @@ struct VideoPreferences property extend_desc : Bool property video_start : Float64 | Int32 property volume : Int32 + property vr_mode : Bool end struct Video @@ -760,6 +761,10 @@ struct Video info["microformat"]?.try &.["playerMicroformatRenderer"]["isFamilySafe"]?.try &.as_bool || false end + def is_vr : Bool + info["streamingData"]?.try &.["adaptiveFormats"].as_a[0]?.try &.["projectionType"].as_s == "MESH" ? true : false || false + end + def wilson_score : Float64 ci_lower_bound(likes, likes + dislikes).round(4) end @@ -1053,6 +1058,7 @@ def process_video_params(query, preferences) 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? + vr_mode = query["vr_mode"]?.try { |q| (q == "true" || q == "1").to_unsafe } if preferences # region ||= preferences.region @@ -1072,6 +1078,7 @@ def process_video_params(query, preferences) video_loop ||= preferences.video_loop.to_unsafe extend_desc ||= preferences.extend_desc.to_unsafe volume ||= preferences.volume + vr_mode ||= preferences.vr_mode.to_unsafe end annotations ||= CONFIG.default_user_preferences.annotations.to_unsafe @@ -1090,6 +1097,7 @@ def process_video_params(query, preferences) 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 + vr_mode ||= CONFIG.default_user_preferences.vr_mode.to_unsafe annotations = annotations == 1 autoplay = autoplay == 1 @@ -1100,6 +1108,7 @@ def process_video_params(query, preferences) related_videos = related_videos == 1 video_loop = video_loop == 1 extend_desc = extend_desc == 1 + vr_mode = vr_mode == 1 if CONFIG.disabled?("dash") && quality == "dash" quality = "high" @@ -1149,6 +1158,7 @@ def process_video_params(query, preferences) extend_desc: extend_desc, video_start: video_start, volume: volume, + vr_mode: vr_mode, }) return params diff --git a/src/invidious/views/components/player_sources.ecr b/src/invidious/views/components/player_sources.ecr index a99fdbca..1490916a 100644 --- a/src/invidious/views/components/player_sources.ecr +++ b/src/invidious/views/components/player_sources.ecr @@ -5,6 +5,7 @@ <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> @@ -13,6 +14,7 @@ <script src="/js/videojs-share.min.js?v=<%= ASSET_COMMIT %>"></script> <script src="/js/videojs-vtt-thumbnails.min.js?v=<%= ASSET_COMMIT %>"></script> + <% if params.annotations %> <link rel="stylesheet" href="/css/videojs-youtube-annotations.min.css?v=<%= ASSET_COMMIT %>"> <script src="/js/videojs-youtube-annotations.min.js?v=<%= ASSET_COMMIT %>"></script> @@ -22,3 +24,8 @@ <link rel="stylesheet" href="/css/quality-selector.css?v=<%= ASSET_COMMIT %>"> <script src="/js/silvermine-videojs-quality-selector.min.js?v=<%= ASSET_COMMIT %>"></script> <% end %> + +<% if params.vr_mode %> + <link rel="stylesheet" href="/css/videojs-vr.css?v=<%= ASSET_COMMIT %>"> + <script src="/js/videojs-vr.js?v=<%= ASSET_COMMIT %>"></script> +<% end %> diff --git a/src/invidious/views/licenses.ecr b/src/invidious/views/licenses.ecr index c2ada992..9f5bcbdd 100644 --- a/src/invidious/views/licenses.ecr +++ b/src/invidious/views/licenses.ecr @@ -235,6 +235,20 @@ <tr> <td> + <a href="/js/videojs-vr.js?v=<%= ASSET_COMMIT %>">videojs-vr.js</a> + </td> + + <td> + <a href="https://choosealicense.com/licenses/mit">MIT</a> + </td> + + <td> + <a href="https://github.com/videojs/videojs-vr"><%= translate(locale, "source") %></a> + </td> + </tr> + + <tr> + <td> <a href="/js/video.min.js?v=<%= ASSET_COMMIT %>">video.min.js</a> </td> diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index 602340a4..1e1e8cae 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -111,6 +111,10 @@ <input name="extend_desc" id="extend_desc" type="checkbox" <% if preferences.extend_desc %>checked<% end %>> </div> + <div class="pure-control-group"> + <label for="vr_mode"><%= translate(locale, "Interactive 360 degree videos") %></label> + <input name="vr_mode" id="vr_mode" type="checkbox" <% if preferences.vr_mode %>checked<% end %>> + </div> <legend><%= translate(locale, "Visual preferences") %></legend> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 8b587eb3..baffa08b 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -57,7 +57,8 @@ we're going to need to do it here in order to allow for translations. "show_replies_text" => HTML.escape(translate(locale, "Show replies")), "params" => params, "preferences" => preferences, - "premiere_timestamp" => video.premiere_timestamp.try &.to_unix + "premiere_timestamp" => video.premiere_timestamp.try &.to_unix, + "vr" => video.is_vr }.to_pretty_json %> </script> |
