mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-25 15:07:22 +00:00
add song title for music tracks
This commit is contained in:
parent
6b01629c5d
commit
d8e23d34b6
@ -190,6 +190,7 @@
|
|||||||
"Blacklisted regions: ": "Blacklisted regions: ",
|
"Blacklisted regions: ": "Blacklisted regions: ",
|
||||||
"Music in this video": "Music in this video",
|
"Music in this video": "Music in this video",
|
||||||
"Artist: ": "Artist: ",
|
"Artist: ": "Artist: ",
|
||||||
|
"Song: ": "Song: ",
|
||||||
"Album: ": "Album: ",
|
"Album: ": "Album: ",
|
||||||
"Shared `x`": "Shared `x`",
|
"Shared `x`": "Shared `x`",
|
||||||
"Premieres in `x`": "Premieres in `x`",
|
"Premieres in `x`": "Premieres in `x`",
|
||||||
|
@ -197,6 +197,21 @@ module Invidious::JSONify::APIv1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !video.music.empty?
|
||||||
|
json.field "musicTracks" do
|
||||||
|
json.array do
|
||||||
|
video.music.each do |music|
|
||||||
|
json.object do
|
||||||
|
json.field "song", music.song
|
||||||
|
json.field "artist", music.artist
|
||||||
|
json.field "album", music.album
|
||||||
|
json.field "license", music.license
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
json.field "recommendedVideos" do
|
json.field "recommendedVideos" do
|
||||||
json.array do
|
json.array do
|
||||||
video.related_videos.each do |rv|
|
video.related_videos.each do |rv|
|
||||||
|
@ -249,7 +249,7 @@ struct Video
|
|||||||
|
|
||||||
def music : Array(VideoMusic)
|
def music : Array(VideoMusic)
|
||||||
info["music"].as_a.map { |music_json|
|
info["music"].as_a.map { |music_json|
|
||||||
VideoMusic.new(music_json["album"].as_s, music_json["artist"].as_s, music_json["license"].as_s)
|
VideoMusic.new(music_json["song"].as_s, music_json["album"].as_s, music_json["artist"].as_s, music_json["license"].as_s)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,10 +3,11 @@ require "json"
|
|||||||
struct VideoMusic
|
struct VideoMusic
|
||||||
include JSON::Serializable
|
include JSON::Serializable
|
||||||
|
|
||||||
|
property song : String
|
||||||
property album : String
|
property album : String
|
||||||
property artist : String
|
property artist : String
|
||||||
property license : String
|
property license : String
|
||||||
|
|
||||||
def initialize(@album : String, @artist : String, @license : String)
|
def initialize(@song : String, @album : String, @artist : String, @license : String)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -322,6 +322,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
|
|
||||||
music_desclist.try &.as_a.each do |music_desc|
|
music_desclist.try &.as_a.each do |music_desc|
|
||||||
artist = nil
|
artist = nil
|
||||||
|
song = nil
|
||||||
album = nil
|
album = nil
|
||||||
music_license = nil
|
music_license = nil
|
||||||
|
|
||||||
@ -329,13 +330,15 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
desc_title = extract_text(desc.dig?("infoRowRenderer", "title"))
|
desc_title = extract_text(desc.dig?("infoRowRenderer", "title"))
|
||||||
if desc_title == "ARTIST"
|
if desc_title == "ARTIST"
|
||||||
artist = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
artist = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
||||||
|
elsif desc_title == "SONG"
|
||||||
|
song = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
||||||
elsif desc_title == "ALBUM"
|
elsif desc_title == "ALBUM"
|
||||||
album = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
album = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
||||||
elsif desc_title == "LICENSES"
|
elsif desc_title == "LICENSES"
|
||||||
music_license = extract_text(desc.dig?("infoRowRenderer", "expandedMetadata"))
|
music_license = extract_text(desc.dig?("infoRowRenderer", "expandedMetadata"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
music_list << VideoMusic.new(album.to_s, artist.to_s, music_license.to_s)
|
music_list << VideoMusic.new(song.to_s, album.to_s, artist.to_s, music_license.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Author infos
|
# Author infos
|
||||||
|
@ -248,9 +248,10 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
<div id="music-description-box">
|
<div id="music-description-box">
|
||||||
<% video.music.each do |music| %>
|
<% video.music.each do |music| %>
|
||||||
<div class="music-item">
|
<div class="music-item">
|
||||||
<p id="music-artist"><%= translate(locale, "Artist: ") %><%= music.artist %></p>
|
<p class="music-song"><%= translate(locale, "Song: ") %><%= music.song %></p>
|
||||||
<p id="music-album"><%= translate(locale, "Album: ") %><%= music.album %></p>
|
<p class="music-artist"><%= translate(locale, "Artist: ") %><%= music.artist %></p>
|
||||||
<p id="music-license"><%= translate(locale, "License: ") %><%= music.license %></p>
|
<p class="music-album"><%= translate(locale, "Album: ") %><%= music.album %></p>
|
||||||
|
<p class="music-license"><%= translate(locale, "License: ") %><%= music.license %></p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user