mirror of
https://github.com/iv-org/invidious.git
synced 2025-06-28 01:28:30 +00:00
Merge 1e2469edec
into df8839d1f0
This commit is contained in:
commit
c2ae17ca3b
@ -64,13 +64,34 @@ module Invidious::Routes::API::Manifest
|
|||||||
mime_streams = audio_streams.select { |stream| stream["mimeType"].as_s.starts_with? mime_type }
|
mime_streams = audio_streams.select { |stream| stream["mimeType"].as_s.starts_with? mime_type }
|
||||||
next if mime_streams.empty?
|
next if mime_streams.empty?
|
||||||
|
|
||||||
|
# First scan to check if any track has "original" in its name
|
||||||
|
original_track_found = false
|
||||||
|
mime_streams.each do |fmt|
|
||||||
|
audio_track = fmt["audioTrack"]?.try &.as_h? || {} of String => JSON::Any
|
||||||
|
displayname = audio_track["displayName"]?.try &.as_s || "Unknown"
|
||||||
|
if displayname.downcase.includes?("original")
|
||||||
|
original_track_found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
mime_streams.each do |fmt|
|
mime_streams.each do |fmt|
|
||||||
# OTF streams aren't supported yet (See https://github.com/TeamNewPipe/NewPipe/issues/2415)
|
# OTF streams aren't supported yet (See https://github.com/TeamNewPipe/NewPipe/issues/2415)
|
||||||
next if !(fmt.has_key?("indexRange") && fmt.has_key?("initRange"))
|
next if !(fmt.has_key?("indexRange") && fmt.has_key?("initRange"))
|
||||||
|
|
||||||
audio_track = fmt["audioTrack"]?.try &.as_h? || {} of String => JSON::Any
|
audio_track = fmt["audioTrack"]?.try &.as_h? || {} of String => JSON::Any
|
||||||
lang = audio_track["id"]?.try &.as_s.split('.')[0] || "und"
|
lang = audio_track["id"]?.try &.as_s.split('.')[0] || "und"
|
||||||
|
displayname = audio_track["displayName"]?.try &.as_s || "Unknown"
|
||||||
|
|
||||||
|
# Determine if this track should be default
|
||||||
|
if original_track_found
|
||||||
|
# If any track has "original", only those tracks should be default
|
||||||
|
is_default = displayname.downcase.includes?("original")
|
||||||
|
else
|
||||||
|
# Otherwise use the original logic
|
||||||
is_default = audio_track.has_key?("audioIsDefault") ? audio_track["audioIsDefault"].as_bool : i == 0
|
is_default = audio_track.has_key?("audioIsDefault") ? audio_track["audioIsDefault"].as_bool : i == 0
|
||||||
|
end
|
||||||
|
|
||||||
displayname = audio_track["displayName"]?.try &.as_s || "Unknown"
|
displayname = audio_track["displayName"]?.try &.as_s || "Unknown"
|
||||||
bitrate = fmt["bitrate"]
|
bitrate = fmt["bitrate"]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user