mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Fix season playlists
This commit is contained in:
parent
f54fbd057e
commit
a19cdb5e72
4 changed files with 57 additions and 31 deletions
|
@ -3047,8 +3047,7 @@ get "/channel/:ucid" do |env|
|
||||||
item.author
|
item.author
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
items.select! { |item| item.responds_to?(:thumbnail_id) && item.thumbnail_id }
|
items = items.select { |item| item.is_a?(SearchPlaylist) }.map { |item| item.as(SearchPlaylist) }
|
||||||
items = items.map { |item| item.as(SearchPlaylist) }
|
|
||||||
items.each { |item| item.author = "" }
|
items.each { |item| item.author = "" }
|
||||||
else
|
else
|
||||||
sort_options = {"newest", "oldest", "popular"}
|
sort_options = {"newest", "oldest", "popular"}
|
||||||
|
@ -5086,6 +5085,43 @@ get "/sb/:id/:storyboard/:index" do |env|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/s_p/:id/:name" do |env|
|
||||||
|
id = env.params.url["id"]
|
||||||
|
name = env.params.url["name"]
|
||||||
|
|
||||||
|
host = "https://i9.ytimg.com"
|
||||||
|
client = make_client(URI.parse(host))
|
||||||
|
url = env.request.resource
|
||||||
|
|
||||||
|
headers = HTTP::Headers.new
|
||||||
|
REQUEST_HEADERS_WHITELIST.each do |header|
|
||||||
|
if env.request.headers[header]?
|
||||||
|
headers[header] = env.request.headers[header]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
client.get(url, headers) do |response|
|
||||||
|
env.response.status_code = response.status_code
|
||||||
|
response.headers.each do |key, value|
|
||||||
|
if !RESPONSE_HEADERS_BLACKLIST.includes? key
|
||||||
|
env.response.headers[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
|
if response.status_code >= 300 && response.status_code != 404
|
||||||
|
env.response.headers.delete("Transfer-Encoding")
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
proxy_file(response, env)
|
||||||
|
end
|
||||||
|
rescue ex
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
get "/vi/:id/:name" do |env|
|
get "/vi/:id/:name" do |env|
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
name = env.params.url["name"]
|
name = env.params.url["name"]
|
||||||
|
|
|
@ -312,8 +312,7 @@ end
|
||||||
|
|
||||||
def extract_videos(nodeset, ucid = nil, author_name = nil)
|
def extract_videos(nodeset, ucid = nil, author_name = nil)
|
||||||
videos = extract_items(nodeset, ucid, author_name)
|
videos = extract_items(nodeset, ucid, author_name)
|
||||||
videos.select! { |item| !item.is_a?(SearchChannel | SearchPlaylist) }
|
videos.select { |item| item.is_a?(SearchVideo) }.map { |video| video.as(SearchVideo) }
|
||||||
videos.map { |video| video.as(SearchVideo) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_items(nodeset, ucid = nil, author_name = nil)
|
def extract_items(nodeset, ucid = nil, author_name = nil)
|
||||||
|
@ -361,14 +360,14 @@ def extract_items(nodeset, ucid = nil, author_name = nil)
|
||||||
anchor = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li/a))
|
anchor = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li/a))
|
||||||
end
|
end
|
||||||
|
|
||||||
video_count = node.xpath_node(%q(.//span[@class="formatted-video-count-label"]/b))
|
video_count = node.xpath_node(%q(.//span[@class="formatted-video-count-label"]/b)) ||
|
||||||
|
node.xpath_node(%q(.//span[@class="formatted-video-count-label"]))
|
||||||
if video_count
|
if video_count
|
||||||
video_count = video_count.content
|
video_count = video_count.content
|
||||||
|
|
||||||
if video_count == "50+"
|
if video_count == "50+"
|
||||||
author = "YouTube"
|
author = "YouTube"
|
||||||
author_id = "UC-9-kyTW8ZkZNDHQJ6FgpwQ"
|
author_id = "UC-9-kyTW8ZkZNDHQJ6FgpwQ"
|
||||||
video_count = video_count.rchop("+")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
video_count = video_count.gsub(/\D/, "").to_i?
|
video_count = video_count.gsub(/\D/, "").to_i?
|
||||||
|
@ -400,11 +399,6 @@ def extract_items(nodeset, ucid = nil, author_name = nil)
|
||||||
|
|
||||||
playlist_thumbnail = node.xpath_node(%q(.//div/span/img)).try &.["data-thumb"]?
|
playlist_thumbnail = node.xpath_node(%q(.//div/span/img)).try &.["data-thumb"]?
|
||||||
playlist_thumbnail ||= node.xpath_node(%q(.//div/span/img)).try &.["src"]
|
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,
|
||||||
|
@ -413,7 +407,7 @@ def extract_items(nodeset, ucid = nil, author_name = nil)
|
||||||
author_id,
|
author_id,
|
||||||
video_count,
|
video_count,
|
||||||
videos,
|
videos,
|
||||||
thumbnail_id
|
playlist_thumbnail
|
||||||
)
|
)
|
||||||
when .includes? "yt-lockup-channel"
|
when .includes? "yt-lockup-channel"
|
||||||
author = title.strip
|
author = title.strip
|
||||||
|
@ -586,15 +580,11 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
|
||||||
|
|
||||||
playlist_thumbnail = child_node.xpath_node(%q(.//span/img)).try &.["data-thumb"]?
|
playlist_thumbnail = child_node.xpath_node(%q(.//span/img)).try &.["data-thumb"]?
|
||||||
playlist_thumbnail ||= child_node.xpath_node(%q(.//span/img)).try &.["src"]
|
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
|
|
||||||
|
|
||||||
video_count_label = child_node.xpath_node(%q(.//span[@class="formatted-video-count-label"]))
|
video_count = child_node.xpath_node(%q(.//span[@class="formatted-video-count-label"]/b)) ||
|
||||||
if video_count_label
|
child_node.xpath_node(%q(.//span[@class="formatted-video-count-label"]))
|
||||||
video_count = video_count_label.content.gsub(/\D/, "").to_i?
|
if video_count
|
||||||
|
video_count = video_count.content.gsub(/\D/, "").to_i?
|
||||||
end
|
end
|
||||||
video_count ||= 50
|
video_count ||= 50
|
||||||
|
|
||||||
|
@ -605,7 +595,7 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
|
||||||
ucid,
|
ucid,
|
||||||
video_count,
|
video_count,
|
||||||
Array(SearchPlaylistVideo).new,
|
Array(SearchPlaylistVideo).new,
|
||||||
thumbnail_id
|
playlist_thumbnail
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -620,7 +610,7 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
|
||||||
ucid,
|
ucid,
|
||||||
videos.size,
|
videos.size,
|
||||||
videos,
|
videos,
|
||||||
videos[0].try &.id
|
"/vi/#{videos[0].id}/mqdefault.jpg"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -158,7 +158,7 @@ struct SearchPlaylist
|
||||||
ucid: String,
|
ucid: String,
|
||||||
video_count: Int32,
|
video_count: Int32,
|
||||||
videos: Array(SearchPlaylistVideo),
|
videos: Array(SearchPlaylistVideo),
|
||||||
thumbnail_id: String?,
|
thumbnail: String?,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,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.thumbnail_id}" %>
|
<% url = "/mix?list=#{item.id}&continuation=#{URI.parse(item.thumbnail || "/vi/-----------").full_path.split("/")[2]}" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% url = "/playlist?list=#{item.id}" %>
|
<% url = "/playlist?list=#{item.id}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
<a style="width:100%" href="<%= url %>">
|
<a style="width:100%" href="<%= url %>">
|
||||||
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img class="thumbnail" src="/vi/<%= item.thumbnail_id %>/mqdefault.jpg"/>
|
<img class="thumbnail" src="<%= URI.parse(item.thumbnail || "/").full_path %>"/>
|
||||||
<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 a new issue