forked from midou/invidious
Video page: add song title + remove song license on music videos (#3680)
This commit is contained in:
commit
6837e42928
@ -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,12 @@ 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
|
||||
|
@ -325,17 +325,25 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
||||
album = nil
|
||||
music_license = nil
|
||||
|
||||
# Used when the video has multiple songs
|
||||
if song_title = music_desc.dig?("carouselLockupRenderer", "videoLockup", "compactVideoRenderer", "title")
|
||||
# "simpleText" for plain text / "runs" when song has a link
|
||||
song = song_title["simpleText"]? || song_title.dig("runs", 0, "text")
|
||||
end
|
||||
|
||||
music_desc.dig?("carouselLockupRenderer", "infoRows").try &.as_a.each do |desc|
|
||||
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,9 @@ 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>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user