mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-08 13:42:27 +05:30
Compare commits
3 Commits
fc5b6c10e4
...
7312c22621
Author | SHA1 | Date | |
---|---|---|---|
|
7312c22621 | ||
|
d8b893e9ad | ||
|
7d0d573cef |
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -38,10 +38,11 @@ jobs:
|
||||
matrix:
|
||||
stable: [true]
|
||||
crystal:
|
||||
- 1.9.2
|
||||
- 1.10.1
|
||||
- 1.11.2
|
||||
- 1.12.1
|
||||
- 1.13.2
|
||||
- 1.14.0
|
||||
include:
|
||||
- crystal: nightly
|
||||
stable: false
|
||||
|
@ -27,28 +27,21 @@ module Invidious::Routes::API::Manifest
|
||||
haltf env, status_code: response.status_code
|
||||
end
|
||||
|
||||
manifest = response.body
|
||||
|
||||
manifest = manifest.gsub(/<BaseURL>[^<]+<\/BaseURL>/) do |baseurl|
|
||||
url = baseurl.lchop("<BaseURL>")
|
||||
url = url.rchop("</BaseURL>")
|
||||
|
||||
if local
|
||||
uri = URI.parse(url)
|
||||
url = "#{HOST_URL}#{uri.request_target}host/#{uri.host}/"
|
||||
end
|
||||
|
||||
# Proxy URLs for video playback on invidious.
|
||||
# Other API clients can get the original URLs by omiting `local=true`.
|
||||
manifest = response.body.gsub(/<BaseURL>[^<]+<\/BaseURL>/) do |baseurl|
|
||||
url = baseurl.lchop("<BaseURL>").rchop("</BaseURL>")
|
||||
url = HttpServer::Utils.proxy_video_url(url, absolute: true) if local
|
||||
"<BaseURL>#{url}</BaseURL>"
|
||||
end
|
||||
|
||||
return manifest
|
||||
end
|
||||
|
||||
adaptive_fmts = video.adaptive_fmts
|
||||
|
||||
# Ditto, only proxify URLs if `local=true` is used
|
||||
if local
|
||||
adaptive_fmts.each do |fmt|
|
||||
fmt["url"] = JSON::Any.new("#{HOST_URL}#{URI.parse(fmt["url"].as_s).request_target}")
|
||||
video.adaptive_fmts.each do |fmt|
|
||||
fmt["url"] = JSON::Any.new(HttpServer::Utils.proxy_video_url(fmt["url"].as_s, absolute: true))
|
||||
end
|
||||
end
|
||||
|
||||
@ -178,7 +171,8 @@ module Invidious::Routes::API::Manifest
|
||||
|
||||
if local
|
||||
manifest = manifest.gsub(/^https:\/\/\w+---.{11}\.c\.youtube\.com[^\n]*/m) do |match|
|
||||
path = URI.parse(match).path
|
||||
uri = URI.parse(match)
|
||||
path = uri.path
|
||||
|
||||
path = path.lchop("/videoplayback/")
|
||||
path = path.rchop("/")
|
||||
@ -207,7 +201,7 @@ module Invidious::Routes::API::Manifest
|
||||
raw_params["fvip"] = fvip["fvip"]
|
||||
end
|
||||
|
||||
raw_params["local"] = "true"
|
||||
raw_params["host"] = uri.host.not_nil!
|
||||
|
||||
"#{HOST_URL}/videoplayback?#{raw_params}"
|
||||
end
|
||||
|
@ -157,10 +157,12 @@ module Invidious::Routes::Embed
|
||||
adaptive_fmts = video.adaptive_fmts
|
||||
|
||||
if params.local
|
||||
fmt_stream.each { |fmt| fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target) }
|
||||
adaptive_fmts.each { |fmt| fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target) }
|
||||
fmt_stream.each { |fmt| fmt["url"] = JSON::Any.new(HttpServer::Utils.proxy_video_url(fmt["url"].as_s)) }
|
||||
end
|
||||
|
||||
# Always proxy DASH streams, otherwise youtube CORS headers will prevent playback
|
||||
adaptive_fmts.each { |fmt| fmt["url"] = JSON::Any.new(HttpServer::Utils.proxy_video_url(fmt["url"].as_s)) }
|
||||
|
||||
video_streams = video.video_streams
|
||||
audio_streams = video.audio_streams
|
||||
|
||||
|
@ -121,10 +121,12 @@ module Invidious::Routes::Watch
|
||||
adaptive_fmts = video.adaptive_fmts
|
||||
|
||||
if params.local
|
||||
fmt_stream.each { |fmt| fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target) }
|
||||
adaptive_fmts.each { |fmt| fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target) }
|
||||
fmt_stream.each { |fmt| fmt["url"] = JSON::Any.new(HttpServer::Utils.proxy_video_url(fmt["url"].as_s)) }
|
||||
end
|
||||
|
||||
# Always proxy DASH streams, otherwise youtube CORS headers will prevent playback
|
||||
adaptive_fmts.each { |fmt| fmt["url"] = JSON::Any.new(HttpServer::Utils.proxy_video_url(fmt["url"].as_s)) }
|
||||
|
||||
video_streams = video.video_streams
|
||||
audio_streams = video.audio_streams
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user