Feat: Add resolution limit
All checks were successful
Invidious CI / build (push) Successful in 10m2s
All checks were successful
Invidious CI / build (push) Successful in 10m2s
This commit is contained in:
parent
cae8cbdda8
commit
8f46bd5751
3 changed files with 25 additions and 0 deletions
|
@ -164,6 +164,9 @@ class Config
|
||||||
# Playlist length limit
|
# Playlist length limit
|
||||||
property playlist_length_limit : Int32 = 500
|
property playlist_length_limit : Int32 = 500
|
||||||
|
|
||||||
|
# The max resolution the Instance can offer
|
||||||
|
property max_dash_resolution : Int32?
|
||||||
|
|
||||||
# Materialious redirects
|
# Materialious redirects
|
||||||
property materialious_domain : String?
|
property materialious_domain : String?
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,14 @@ module Invidious::Routes::API::Manifest
|
||||||
audio_streams = video.audio_streams.sort_by { |stream| {stream["bitrate"].as_i} }.reverse!
|
audio_streams = video.audio_streams.sort_by { |stream| {stream["bitrate"].as_i} }.reverse!
|
||||||
video_streams = video.video_streams.sort_by { |stream| {stream["width"].as_i, stream["fps"].as_i} }.reverse!
|
video_streams = video.video_streams.sort_by { |stream| {stream["width"].as_i, stream["fps"].as_i} }.reverse!
|
||||||
|
|
||||||
|
# Removes all the resolutions with a height higher than CONFIG.max_dash_resolution
|
||||||
|
if CONFIG.max_dash_resolution
|
||||||
|
video_streams.reject! do |z|
|
||||||
|
(z["height"].as_i > CONFIG.max_dash_resolution.not_nil!) if z["height"]?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
||||||
xml.element("MPD", "xmlns": "urn:mpeg:dash:schema:mpd:2011",
|
xml.element("MPD", "xmlns": "urn:mpeg:dash:schema:mpd:2011",
|
||||||
"profiles": "urn:mpeg:dash:profile:full:2011", minBufferTime: "PT1.5S", type: "static",
|
"profiles": "urn:mpeg:dash:profile:full:2011", minBufferTime: "PT1.5S", type: "static",
|
||||||
|
|
|
@ -120,6 +120,13 @@ module Invidious::Routes::Watch
|
||||||
fmt_stream = video.fmt_stream
|
fmt_stream = video.fmt_stream
|
||||||
adaptive_fmts = video.adaptive_fmts
|
adaptive_fmts = video.adaptive_fmts
|
||||||
|
|
||||||
|
# Removes all the resolutions with a height higher than CONFIG.max_dash_resolution
|
||||||
|
if CONFIG.max_dash_resolution
|
||||||
|
adaptive_fmts.reject! do |z|
|
||||||
|
(z["height"].as_i > CONFIG.max_dash_resolution.not_nil!) if z["height"]?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if params.local
|
if params.local
|
||||||
fmt_stream.each { |fmt| fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target) }
|
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) }
|
adaptive_fmts.each { |fmt| fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target) }
|
||||||
|
@ -128,6 +135,13 @@ module Invidious::Routes::Watch
|
||||||
video_streams = video.video_streams
|
video_streams = video.video_streams
|
||||||
audio_streams = video.audio_streams
|
audio_streams = video.audio_streams
|
||||||
|
|
||||||
|
# Removes all the resolutions with a height higher than CONFIG.max_dash_resolution
|
||||||
|
if CONFIG.max_dash_resolution
|
||||||
|
video_streams.reject! do |z|
|
||||||
|
(z["height"].as_i > CONFIG.max_dash_resolution.not_nil!) if z["height"]?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Older videos may not have audio sources available.
|
# Older videos may not have audio sources available.
|
||||||
# We redirect here so they're not unplayable
|
# We redirect here so they're not unplayable
|
||||||
if audio_streams.empty? && !video.live_now
|
if audio_streams.empty? && !video.live_now
|
||||||
|
|
Loading…
Reference in a new issue