mirror of
				https://github.com/iv-org/invidious.git
				synced 2025-11-04 06:31:57 +00:00 
			
		
		
		
	Merge pull request #1881 from SamantazFox/fix-descriptions
Fix video/playlist descriptions
This commit is contained in:
		@@ -488,8 +488,12 @@ def replace_links(html)
 | 
			
		||||
        length_seconds = decode_time(anchor.content)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      anchor["href"] = "javascript:void(0)"
 | 
			
		||||
      anchor["onclick"] = "player.currentTime(#{length_seconds})"
 | 
			
		||||
      if length_seconds > 0
 | 
			
		||||
        anchor["href"] = "javascript:void(0)"
 | 
			
		||||
        anchor["onclick"] = "player.currentTime(#{length_seconds})"
 | 
			
		||||
      else
 | 
			
		||||
        anchor["href"] = url.request_target
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -528,11 +532,7 @@ end
 | 
			
		||||
 | 
			
		||||
def content_to_comment_html(content)
 | 
			
		||||
  comment_html = content.map do |run|
 | 
			
		||||
    text = HTML.escape(run["text"].as_s)
 | 
			
		||||
 | 
			
		||||
    if run["text"] == "\n"
 | 
			
		||||
      text = "<br>"
 | 
			
		||||
    end
 | 
			
		||||
    text = HTML.escape(run["text"].as_s).gsub("\n", "<br>")
 | 
			
		||||
 | 
			
		||||
    if run["bold"]?
 | 
			
		||||
      text = "<b>#{text}</b>"
 | 
			
		||||
@@ -559,7 +559,7 @@ def content_to_comment_html(content)
 | 
			
		||||
        length_seconds = watch_endpoint["startTimeSeconds"]?
 | 
			
		||||
        video_id = watch_endpoint["videoId"].as_s
 | 
			
		||||
 | 
			
		||||
        if length_seconds
 | 
			
		||||
        if length_seconds && length_seconds.as_i > 0
 | 
			
		||||
          text = %(<a href="javascript:void(0)" data-onclick="jump_to_time" data-jump-time="#{length_seconds}">#{text}</a>)
 | 
			
		||||
        else
 | 
			
		||||
          text = %(<a href="/watch?v=#{video_id}">#{text}</a>)
 | 
			
		||||
 
 | 
			
		||||
@@ -101,6 +101,7 @@ struct Playlist
 | 
			
		||||
  property author_thumbnail : String
 | 
			
		||||
  property ucid : String
 | 
			
		||||
  property description : String
 | 
			
		||||
  property description_html : String
 | 
			
		||||
  property video_count : Int32
 | 
			
		||||
  property views : Int64
 | 
			
		||||
  property updated : Time
 | 
			
		||||
@@ -163,10 +164,6 @@ struct Playlist
 | 
			
		||||
  def privacy
 | 
			
		||||
    PlaylistPrivacy::Public
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def description_html
 | 
			
		||||
    HTML.escape(self.description).gsub("\n", "<br>")
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
enum PlaylistPrivacy
 | 
			
		||||
@@ -375,7 +372,12 @@ def fetch_playlist(plid, locale)
 | 
			
		||||
  title = playlist_info["title"]?.try &.["runs"][0]?.try &.["text"]?.try &.as_s || ""
 | 
			
		||||
 | 
			
		||||
  desc_item = playlist_info["description"]?
 | 
			
		||||
  description = desc_item.try &.["runs"]?.try &.as_a.map(&.["text"].as_s).join("") || desc_item.try &.["simpleText"]?.try &.as_s || ""
 | 
			
		||||
 | 
			
		||||
  description_txt = desc_item.try &.["runs"]?.try &.as_a
 | 
			
		||||
    .map(&.["text"].as_s).join("") || desc_item.try &.["simpleText"]?.try &.as_s || ""
 | 
			
		||||
 | 
			
		||||
  description_html = desc_item.try &.["runs"]?.try &.as_a
 | 
			
		||||
    .try { |run| content_to_comment_html(run).try &.to_s } || "<p></p>"
 | 
			
		||||
 | 
			
		||||
  thumbnail = playlist_info["thumbnailRenderer"]?.try &.["playlistVideoThumbnailRenderer"]?
 | 
			
		||||
    .try &.["thumbnail"]["thumbnails"][0]["url"]?.try &.as_s
 | 
			
		||||
@@ -415,7 +417,8 @@ def fetch_playlist(plid, locale)
 | 
			
		||||
    author:           author,
 | 
			
		||||
    author_thumbnail: author_thumbnail,
 | 
			
		||||
    ucid:             ucid,
 | 
			
		||||
    description:      description,
 | 
			
		||||
    description:      description_txt,
 | 
			
		||||
    description_html: description_html,
 | 
			
		||||
    video_count:      video_count,
 | 
			
		||||
    views:            views,
 | 
			
		||||
    updated:          updated,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user