diff options
| author | ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> | 2023-08-01 08:55:23 -0700 |
|---|---|---|
| committer | ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> | 2023-09-11 22:35:57 -0400 |
| commit | d7696574f4a281d7450176097c87bca08705734a (patch) | |
| tree | 2d711b5ee315ce071d9f1175b6206c44ffd57e43 /src | |
| parent | ac0c0609bb8b652e630c3603cd9dbb1c87fbdf44 (diff) | |
| download | invidious-d7696574f4a281d7450176097c87bca08705734a.tar.gz invidious-d7696574f4a281d7450176097c87bca08705734a.tar.bz2 invidious-d7696574f4a281d7450176097c87bca08705734a.zip | |
Playlist: Use subtitle when author is missing
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/playlists.cr | 5 | ||||
| -rw-r--r-- | src/invidious/views/playlist.ecr | 6 |
2 files changed, 10 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..3bc7596e 100644 --- a/src/invidious/views/playlist.ecr +++ b/src/invidious/views/playlist.ecr @@ -70,7 +70,11 @@ </b> <% else %> <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(locale, "Updated `x` ago", recode_date(playlist.updated, locale)) %> </b> |
