mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:25:56 -04:00
add song title for music tracks
This commit is contained in:
parent
6b01629c5d
commit
d8e23d34b6
@ -190,6 +190,7 @@
|
||||
"Blacklisted regions: ": "Blacklisted regions: ",
|
||||
"Music in this video": "Music in this video",
|
||||
"Artist: ": "Artist: ",
|
||||
"Song: ": "Song: ",
|
||||
"Album: ": "Album: ",
|
||||
"Shared `x`": "Shared `x`",
|
||||
"Premieres in `x`": "Premieres in `x`",
|
||||
|
@ -197,6 +197,21 @@ module Invidious::JSONify::APIv1
|
||||
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.array do
|
||||
video.related_videos.each do |rv|
|
||||
|
@ -249,7 +249,7 @@ struct Video
|
||||
|
||||
def music : Array(VideoMusic)
|
||||
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
|
||||
|
||||
|
@ -3,10 +3,11 @@ require "json"
|
||||
struct VideoMusic
|
||||
include JSON::Serializable
|
||||
|
||||
property song : String
|
||||
property album : String
|
||||
property artist : String
|
||||
property license : String
|
||||
|
||||
def initialize(@album : String, @artist : String, @license : String)
|
||||
def initialize(@song : String, @album : String, @artist : String, @license : String)
|
||||
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|
|
||||
artist = nil
|
||||
song = nil
|
||||
album = 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"))
|
||||
if desc_title == "ARTIST"
|
||||
artist = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
||||
elsif desc_title == "SONG"
|
||||
song = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
||||
elsif desc_title == "ALBUM"
|
||||
album = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
|
||||
elsif desc_title == "LICENSES"
|
||||
music_license = extract_text(desc.dig?("infoRowRenderer", "expandedMetadata"))
|
||||
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
|
||||
|
||||
# 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">
|
||||
<% video.music.each do |music| %>
|
||||
<div class="music-item">
|
||||
<p id="music-artist"><%= translate(locale, "Artist: ") %><%= music.artist %></p>
|
||||
<p id="music-album"><%= translate(locale, "Album: ") %><%= music.album %></p>
|
||||
<p id="music-license"><%= translate(locale, "License: ") %><%= music.license %></p>
|
||||
<p class="music-song"><%= translate(locale, "Song: ") %><%= music.song %></p>
|
||||
<p class="music-artist"><%= translate(locale, "Artist: ") %><%= music.artist %></p>
|
||||
<p class="music-album"><%= translate(locale, "Album: ") %><%= music.album %></p>
|
||||
<p class="music-license"><%= translate(locale, "License: ") %><%= music.license %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user