mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-11 16:54:40 -05:00
Playlist: Use subtitle when author is missing
This commit is contained in:
parent
ac0c0609bb
commit
d7696574f4
@ -89,6 +89,7 @@ struct Playlist
|
|||||||
property views : Int64
|
property views : Int64
|
||||||
property updated : Time
|
property updated : Time
|
||||||
property thumbnail : String?
|
property thumbnail : String?
|
||||||
|
property subtitle : String?
|
||||||
|
|
||||||
def to_json(offset, json : JSON::Builder, video_id : String? = nil)
|
def to_json(offset, json : JSON::Builder, video_id : String? = nil)
|
||||||
json.object do
|
json.object do
|
||||||
@ -100,6 +101,7 @@ struct Playlist
|
|||||||
json.field "author", self.author
|
json.field "author", self.author
|
||||||
json.field "authorId", self.ucid
|
json.field "authorId", self.ucid
|
||||||
json.field "authorUrl", "/channel/#{self.ucid}"
|
json.field "authorUrl", "/channel/#{self.ucid}"
|
||||||
|
json.field "subtitle", self.subtitle
|
||||||
|
|
||||||
json.field "authorThumbnails" do
|
json.field "authorThumbnails" do
|
||||||
json.array do
|
json.array do
|
||||||
@ -356,6 +358,8 @@ def fetch_playlist(plid : String)
|
|||||||
updated = Time.utc
|
updated = Time.utc
|
||||||
video_count = 0
|
video_count = 0
|
||||||
|
|
||||||
|
subtitle = extract_text(initial_data.dig?("header", "playlistHeaderRenderer", "subtitle"))
|
||||||
|
|
||||||
playlist_info["stats"]?.try &.as_a.each do |stat|
|
playlist_info["stats"]?.try &.as_a.each do |stat|
|
||||||
text = stat["runs"]?.try &.as_a.map(&.["text"].as_s).join("") || stat["simpleText"]?.try &.as_s
|
text = stat["runs"]?.try &.as_a.map(&.["text"].as_s).join("") || stat["simpleText"]?.try &.as_s
|
||||||
next if !text
|
next if !text
|
||||||
@ -397,6 +401,7 @@ def fetch_playlist(plid : String)
|
|||||||
views: views,
|
views: views,
|
||||||
updated: updated,
|
updated: updated,
|
||||||
thumbnail: thumbnail,
|
thumbnail: thumbnail,
|
||||||
|
subtitle: subtitle,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,7 +70,11 @@
|
|||||||
</b>
|
</b>
|
||||||
<% else %>
|
<% else %>
|
||||||
<b>
|
<b>
|
||||||
<a href="/channel/<%= playlist.ucid %>"><%= author %></a> |
|
<% if !author.empty? %>
|
||||||
|
<a href="/channel/<%= playlist.ucid %>"><%= author %></a> |
|
||||||
|
<% elsif !playlist.subtitle.nil? %>
|
||||||
|
<span><%= playlist.subtitle.try &.split(" • ")[0] %></span> |
|
||||||
|
<% end %>
|
||||||
<%= translate_count(locale, "generic_videos_count", playlist.video_count) %> |
|
<%= translate_count(locale, "generic_videos_count", playlist.video_count) %> |
|
||||||
<%= translate(locale, "Updated `x` ago", recode_date(playlist.updated, locale)) %>
|
<%= translate(locale, "Updated `x` ago", recode_date(playlist.updated, locale)) %>
|
||||||
</b>
|
</b>
|
||||||
|
Loading…
Reference in New Issue
Block a user