diff --git a/patches/009-restrict-playback.patch b/patches/009-restrict-playback.patch index eb9f7a5..0c6ff8e 100644 --- a/patches/009-restrict-playback.patch +++ b/patches/009-restrict-playback.patch @@ -1,4 +1,4 @@ -From 6a52c472e4c15e0561fd66a0a9363c82bd5437ce Mon Sep 17 00:00:00 2001 +From fa9097ebf4caaae262adfe5548062752644bef0e Mon Sep 17 00:00:00 2001 From: Emilien Devos Date: Sat, 8 Oct 2022 13:34:52 +0200 Subject: [PATCH 1/1] enforce playback from main website @@ -7,12 +7,12 @@ Subject: [PATCH 1/1] enforce playback from main website assets/js/player.js | 4 ++-- assets/js/watch.js | 3 +++ src/invidious/routes/api/v1/videos.cr | 16 ++++++++++++++++ - src/invidious/views/components/player.ecr | 15 +++++++++------ + src/invidious/views/components/player.ecr | 19 +++++++++++-------- src/invidious/views/watch.ecr | 1 + - 5 files changed, 31 insertions(+), 8 deletions(-) + 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js -index ee678663..2c2bedcb 100644 +index bb53ac24..43bd902f 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -372,7 +372,7 @@ if (!video_data.params.listen && video_data.params.quality === 'dash') { @@ -34,7 +34,7 @@ index ee678663..2c2bedcb 100644 timeout: 60000 }, { diff --git a/assets/js/watch.js b/assets/js/watch.js -index cff84e4d..a60a7b2d 100644 +index 36506abd..babc66a0 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -167,6 +167,7 @@ function get_reddit_comments() { @@ -62,10 +62,10 @@ index cff84e4d..a60a7b2d 100644 if (load_replies) url += '&action=action_get_comment_replies'; diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr -index a6b2eb4e..e4f82fac 100644 +index af4fc806..f1bd2dd6 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr -@@ -24,6 +24,10 @@ module Invidious::Routes::API::V1::Videos +@@ -27,6 +27,10 @@ module Invidious::Routes::API::V1::Videos id = env.params.url["id"] region = env.params.query["region"]? || env.params.body["region"]? @@ -76,7 +76,7 @@ index a6b2eb4e..e4f82fac 100644 if id.nil? || id.size != 11 || !id.matches?(/^[\w-]+$/) return error_json(400, "Invalid video ID") end -@@ -160,6 +164,10 @@ module Invidious::Routes::API::V1::Videos +@@ -173,6 +177,10 @@ module Invidious::Routes::API::V1::Videos id = env.params.url["id"] region = env.params.query["region"]? @@ -87,7 +87,7 @@ index a6b2eb4e..e4f82fac 100644 begin video = get_video(id, region: region) rescue ex : NotFoundException -@@ -232,6 +240,10 @@ module Invidious::Routes::API::V1::Videos +@@ -245,6 +253,10 @@ module Invidious::Routes::API::V1::Videos source = env.params.query["source"]? source ||= "archive" @@ -98,7 +98,7 @@ index a6b2eb4e..e4f82fac 100644 if !id.match(/[a-zA-Z0-9_-]{11}/) haltf env, 400 end -@@ -301,6 +313,10 @@ module Invidious::Routes::API::V1::Videos +@@ -314,6 +326,10 @@ module Invidious::Routes::API::V1::Videos id = env.params.url["id"] @@ -110,7 +110,7 @@ index a6b2eb4e..e4f82fac 100644 source ||= "youtube" diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr -index c3c02df0..ff4dc000 100644 +index c3c02df0..0e673803 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -1,10 +1,11 @@ @@ -126,17 +126,20 @@ index c3c02df0..ff4dc000 100644 <% else %> <% if params.listen %> <% # default to 128k m4a stream -@@ -21,6 +22,7 @@ +@@ -20,6 +21,7 @@ + audio_streams.each_with_index do |fmt, i| src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}" ++ src_url += "&hmac_key=#{hmac_key}" src_url += "&local=true" if params.local -+ src_url += "&hmac_key=#{hmac_key}" if params.local bitrate = fmt["bitrate"] - mimetype = HTML.escape(fmt["mimeType"].as_s) -@@ -29,12 +31,12 @@ +@@ -27,14 +29,14 @@ + + selected = (i == best_m4a_stream_index) %> - +- ++ <% if !params.local && !CONFIG.disabled?("local") %> - + @@ -149,17 +152,20 @@ index c3c02df0..ff4dc000 100644 <% end %> <% -@@ -43,6 +45,7 @@ +@@ -42,6 +44,7 @@ + fmt_stream.sort_by! {|f| params.quality == f["quality"] ? 0 : 1 } fmt_stream.each_with_index do |fmt, i| src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}" ++ src_url += "&hmac_key=#{hmac_key}" src_url += "&local=true" if params.local -+ src_url += "&hmac_key=#{hmac_key}" if params.local quality = fmt["quality"] - mimetype = HTML.escape(fmt["mimeType"].as_s) -@@ -51,17 +54,17 @@ +@@ -49,19 +52,19 @@ + + selected = params.quality ? (params.quality == quality) : (i == 0) %> - +- ++ <% if !params.local && !CONFIG.disabled?("local") %> - + @@ -179,7 +185,7 @@ index c3c02df0..ff4dc000 100644 <% end %> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr -index a6f2e524..8c5b7f29 100644 +index 498d57a1..86a0dd41 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -64,6 +64,7 @@ we're going to need to do it here in order to allow for translations. @@ -191,4 +197,5 @@ index a6f2e524..8c5b7f29 100644 }.to_pretty_json %> -- -2.25.1 +2.41.0 +