mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Video page: add song title + remove song license on music videos (#3680)
This commit is contained in:
commit
6837e42928
6 changed files with 36 additions and 6 deletions
|
@ -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,12 @@ 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
|
||||||
|
|
|
@ -325,17 +325,25 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
||||||
album = nil
|
album = nil
|
||||||
music_license = 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|
|
music_desc.dig?("carouselLockupRenderer", "infoRows").try &.as_a.each do |desc|
|
||||||
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,9 @@ 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>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue