mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-02 08:53:13 +05:30
Add 'thumbnail_id' to playlists
This commit is contained in:
parent
405e98f429
commit
99aa214859
@ -232,13 +232,22 @@ def extract_items(nodeset, ucid = nil, author_name = nil)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
playlist_thumbnail = node.xpath_node(%q(.//div/span/img)).try &.["data-thumb"]?
|
||||||
|
playlist_thumbnail ||= node.xpath_node(%q(.//div/span/img)).try &.["src"]
|
||||||
|
if !playlist_thumbnail || playlist_thumbnail.empty?
|
||||||
|
thumbnail_id = videos[0]?.try &.id
|
||||||
|
else
|
||||||
|
thumbnail_id = playlist_thumbnail.match(/\/vi\/(?<video_id>[a-zA-Z0-9_-]{11})\/\w+\.jpg/).try &.["video_id"]
|
||||||
|
end
|
||||||
|
|
||||||
items << SearchPlaylist.new(
|
items << SearchPlaylist.new(
|
||||||
title,
|
title,
|
||||||
plid,
|
plid,
|
||||||
author,
|
author,
|
||||||
author_id,
|
author_id,
|
||||||
video_count,
|
video_count,
|
||||||
videos
|
videos,
|
||||||
|
thumbnail_id
|
||||||
)
|
)
|
||||||
when .includes? "yt-lockup-channel"
|
when .includes? "yt-lockup-channel"
|
||||||
author = title.strip
|
author = title.strip
|
||||||
@ -399,13 +408,22 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
|
|||||||
playlist_title ||= ""
|
playlist_title ||= ""
|
||||||
plid ||= ""
|
plid ||= ""
|
||||||
|
|
||||||
|
playlist_thumbnail = child_node.xpath_node(%q(.//span/img)).try &.["data-thumb"]?
|
||||||
|
playlist_thumbnail ||= child_node.xpath_node(%q(.//span/img)).try &.["src"]
|
||||||
|
if !playlist_thumbnail || playlist_thumbnail.empty?
|
||||||
|
thumbnail_id = videos[0]?.try &.id
|
||||||
|
else
|
||||||
|
thumbnail_id = playlist_thumbnail.match(/\/vi\/(?<video_id>[a-zA-Z0-9_-]{11})\/\w+\.jpg/).try &.["video_id"]
|
||||||
|
end
|
||||||
|
|
||||||
items << SearchPlaylist.new(
|
items << SearchPlaylist.new(
|
||||||
playlist_title,
|
playlist_title,
|
||||||
plid,
|
plid,
|
||||||
author_name,
|
author_name,
|
||||||
ucid,
|
ucid,
|
||||||
50,
|
50,
|
||||||
Array(SearchPlaylistVideo).new
|
Array(SearchPlaylistVideo).new,
|
||||||
|
thumbnail_id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -419,7 +437,8 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
|
|||||||
author_name,
|
author_name,
|
||||||
ucid,
|
ucid,
|
||||||
videos.size,
|
videos.size,
|
||||||
videos
|
videos,
|
||||||
|
videos[0].try &.id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -162,6 +162,23 @@ def number_with_separator(number)
|
|||||||
number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse
|
number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def short_text_to_number(short_text)
|
||||||
|
case short_text
|
||||||
|
when .ends_with? "M"
|
||||||
|
number = short_text.rstrip(" mM").to_f
|
||||||
|
number *= 1000000
|
||||||
|
when .ends_with? "K"
|
||||||
|
number = short_text.rstrip(" kK").to_f
|
||||||
|
number *= 1000
|
||||||
|
else
|
||||||
|
number = short_text.rstrip(" ")
|
||||||
|
end
|
||||||
|
|
||||||
|
number = number.to_i
|
||||||
|
|
||||||
|
return number
|
||||||
|
end
|
||||||
|
|
||||||
def number_to_short_text(number)
|
def number_to_short_text(number)
|
||||||
seperated = number_with_separator(number).gsub(",", ".").split("")
|
seperated = number_with_separator(number).gsub(",", ".").split("")
|
||||||
text = seperated.first(2).join
|
text = seperated.first(2).join
|
||||||
|
@ -25,12 +25,13 @@ end
|
|||||||
|
|
||||||
class SearchPlaylist
|
class SearchPlaylist
|
||||||
add_mapping({
|
add_mapping({
|
||||||
title: String,
|
title: String,
|
||||||
id: String,
|
id: String,
|
||||||
author: String,
|
author: String,
|
||||||
ucid: String,
|
ucid: String,
|
||||||
video_count: Int32,
|
video_count: Int32,
|
||||||
videos: Array(SearchPlaylistVideo),
|
videos: Array(SearchPlaylistVideo),
|
||||||
|
thumbnail_id: String?,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<h5><%= item.description_html %></h5>
|
<h5><%= item.description_html %></h5>
|
||||||
<% when SearchPlaylist %>
|
<% when SearchPlaylist %>
|
||||||
<% if item.id.starts_with? "RD" %>
|
<% if item.id.starts_with? "RD" %>
|
||||||
<% url = "/mix?list=#{item.id}&continuation=#{item.videos[0]?.try &.id}" %>
|
<% url = "/mix?list=#{item.id}&continuation=#{item.thumbnail_id}" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% url = "/playlist?list=#{item.id}" %>
|
<% url = "/playlist?list=#{item.id}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img class="thumbnail" src="/vi/<%= item.videos[0]?.try &.id %>/mqdefault.jpg"/>
|
<img class="thumbnail" src="/vi/<%= item.thumbnail_id %>/mqdefault.jpg"/>
|
||||||
<p class="length"><%= number_with_separator(item.video_count) %> videos</p>
|
<p class="length"><%= number_with_separator(item.video_count) %> videos</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
Loading…
Reference in New Issue
Block a user