diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2023-09-18 23:34:30 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2023-09-18 23:34:30 +0200 |
| commit | bb14f794969f62582917a39c2dd57bf92fa146a7 (patch) | |
| tree | fff32854929d438a7fbc967eb40435d76eb46f25 /src | |
| parent | bf35200207d26659fde06f5647fe7c17bb4704c3 (diff) | |
| parent | afb04c3bdaa29f19db44f6560ce7954bc656d791 (diff) | |
| download | invidious-bb14f794969f62582917a39c2dd57bf92fa146a7.tar.gz invidious-bb14f794969f62582917a39c2dd57bf92fa146a7.tar.bz2 invidious-bb14f794969f62582917a39c2dd57bf92fa146a7.zip | |
Playlists: Use subtitle when author is missing (#4025)
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/playlists.cr | 5 | ||||
| -rw-r--r-- | src/invidious/views/playlist.ecr | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 013be268..955e0855 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -89,6 +89,7 @@ struct Playlist property views : Int64 property updated : Time property thumbnail : String? + property subtitle : String? def to_json(offset, json : JSON::Builder, video_id : String? = nil) json.object do @@ -100,6 +101,7 @@ struct Playlist json.field "author", self.author json.field "authorId", self.ucid json.field "authorUrl", "/channel/#{self.ucid}" + json.field "subtitle", self.subtitle json.field "authorThumbnails" do json.array do @@ -356,6 +358,8 @@ def fetch_playlist(plid : String) updated = Time.utc video_count = 0 + subtitle = extract_text(initial_data.dig?("header", "playlistHeaderRenderer", "subtitle")) + 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 next if !text @@ -397,6 +401,7 @@ def fetch_playlist(plid : String) views: views, updated: updated, thumbnail: thumbnail, + subtitle: subtitle, }) end diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr index ee9ba87b..24ba437d 100644 --- a/src/invidious/views/playlist.ecr +++ b/src/invidious/views/playlist.ecr @@ -70,7 +70,12 @@ </b> <% else %> <b> - <a href="/channel/<%= playlist.ucid %>"><%= author %></a> | + <% if !author.empty? %> + <a href="/channel/<%= playlist.ucid %>"><%= author %></a> | + <% elsif !playlist.subtitle.nil? %> + <% subtitle = playlist.subtitle || "" %> + <span><%= HTML.escape(subtitle[0..subtitle.rindex(" • ") || subtitle.size]) %></span> | + <% end %> <%= translate_count(locale, "generic_videos_count", playlist.video_count) %> | <%= translate(locale, "Updated `x` ago", recode_date(playlist.updated, locale)) %> </b> |
