mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Add 'view as playlist' option to trending page
This commit is contained in:
parent
9c8f85741c
commit
f5dd135ed8
14 changed files with 55 additions and 7 deletions
|
@ -278,6 +278,7 @@
|
|||
"About": "حول",
|
||||
"Rating: ": "التقييم",
|
||||
"Language: ": "اللغة",
|
||||
"View as playlist": "",
|
||||
"Default": "الكل",
|
||||
"Music": "الاغانى",
|
||||
"Gaming": "الألعاب",
|
||||
|
|
|
@ -278,6 +278,7 @@
|
|||
"About": "Über",
|
||||
"Rating: ": "Bewertung: ",
|
||||
"Language: ": "Sprache: ",
|
||||
"View as playlist": "",
|
||||
"Default": "",
|
||||
"Music": "",
|
||||
"Gaming": "",
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
"Whitelisted regions: ": "Whitelisted regions: ",
|
||||
"Blacklisted regions: ": "Blacklisted regions: ",
|
||||
"Shared `x`": "Shared `x`",
|
||||
"`x` views": "",
|
||||
"`x` views": "`x` views",
|
||||
"Premieres in `x`": "Premieres in `x`",
|
||||
"Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.": "Hi! Looks like you have JavaScript disabled. Click here to view comments, keep in mind it may take a bit longer to load.",
|
||||
"View YouTube comments": "View YouTube comments",
|
||||
|
@ -276,6 +276,7 @@
|
|||
"About": "About",
|
||||
"Rating: ": "Rating: ",
|
||||
"Language: ": "Language: ",
|
||||
"View as playlist": "View as playlist",
|
||||
"Default": "Default",
|
||||
"Music": "Music",
|
||||
"Gaming": "Gaming",
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
"About": "Acerca de",
|
||||
"Rating: ": "Valoración: ",
|
||||
"Language: ": "Idioma: ",
|
||||
"View as playlist": "",
|
||||
"Default": "Por defecto",
|
||||
"Music": "Música",
|
||||
"Gaming": "Videojuegos",
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
"About": "",
|
||||
"Rating: ": "",
|
||||
"Language: ": "",
|
||||
"View as playlist": "",
|
||||
"Default": "",
|
||||
"Music": "",
|
||||
"Gaming": "",
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
"About": "A Propos",
|
||||
"Rating: ": "Évaluation : ",
|
||||
"Language: ": "Langue : ",
|
||||
"View as playlist": "",
|
||||
"Default": "Défaut",
|
||||
"Music": "Musique",
|
||||
"Gaming": "Jeux Vidéo",
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
"About": "A proposito",
|
||||
"Rating: ": "Punteggio: ",
|
||||
"Language: ": "Lingua: ",
|
||||
"View as playlist": "",
|
||||
"Default": "Predefinito",
|
||||
"Music": "Musica",
|
||||
"Gaming": "Videogiochi",
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
"About": "Om",
|
||||
"Rating: ": "Vurdering: ",
|
||||
"Language: ": "Språk: ",
|
||||
"View as playlist": "",
|
||||
"Default": "Forvalg",
|
||||
"Music": "Musikk",
|
||||
"Gaming": "Spill",
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
"About": "",
|
||||
"Rating: ": "",
|
||||
"Language: ": "",
|
||||
"View as playlist": "",
|
||||
"Default": "",
|
||||
"Music": "",
|
||||
"Gaming": "",
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
"About": "Informacje",
|
||||
"Rating: ": "Ocena: ",
|
||||
"Language: ": "Język: ",
|
||||
"View as playlist": "",
|
||||
"Default": "Domyślnie",
|
||||
"Music": "Muzyka",
|
||||
"Gaming": "Gry",
|
||||
|
|
|
@ -278,6 +278,7 @@
|
|||
"About": "О сайте",
|
||||
"Rating: ": "Рейтинг: ",
|
||||
"Language: ": "Язык: ",
|
||||
"View as playlist": "",
|
||||
"Default": "По-умолчанию",
|
||||
"Music": "Музыка",
|
||||
"Gaming": "Игры",
|
||||
|
|
|
@ -1955,7 +1955,7 @@ get "/feed/trending" do |env|
|
|||
region ||= "US"
|
||||
|
||||
begin
|
||||
trending = fetch_trending(trending_type, proxies, region, locale)
|
||||
trending, plid = fetch_trending(trending_type, proxies, region, locale)
|
||||
rescue ex
|
||||
error_message = "#{ex.message}"
|
||||
next templated "error"
|
||||
|
@ -3205,7 +3205,7 @@ get "/api/v1/trending" do |env|
|
|||
trending_type = env.params.query["type"]?
|
||||
|
||||
begin
|
||||
trending = fetch_trending(trending_type, proxies, region, locale)
|
||||
trending, plid = fetch_trending(trending_type, proxies, region, locale)
|
||||
rescue ex
|
||||
error_message = {"error" => ex.message}.to_json
|
||||
env.response.status_code = 500
|
||||
|
|
|
@ -7,6 +7,8 @@ def fetch_trending(trending_type, proxies, region, locale)
|
|||
region = region.upcase
|
||||
|
||||
trending = ""
|
||||
plid = nil
|
||||
|
||||
if trending_type && trending_type != "Default"
|
||||
trending_type = trending_type.downcase.capitalize
|
||||
|
||||
|
@ -23,9 +25,11 @@ def fetch_trending(trending_type, proxies, region, locale)
|
|||
url = tabs.select { |tab| tab["channelListSubMenuAvatarRenderer"]["title"]["simpleText"] == trending_type }[0]?
|
||||
|
||||
if url
|
||||
url["channelListSubMenuAvatarRenderer"]["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"]
|
||||
url = url["channelListSubMenuAvatarRenderer"]["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"].as_s
|
||||
url += "&disable_polymer=1&gl=#{region}&hl=en"
|
||||
trending = client.get(url).body
|
||||
plid = extract_plid(url)
|
||||
else
|
||||
trending = client.get("/feed/trending?gl=#{region}&hl=en&disable_polymer=1").body
|
||||
end
|
||||
|
@ -37,5 +41,37 @@ def fetch_trending(trending_type, proxies, region, locale)
|
|||
nodeset = trending.xpath_nodes(%q(//ul/li[@class="expanded-shelf-content-item-wrapper"]))
|
||||
trending = extract_videos(nodeset)
|
||||
|
||||
return trending
|
||||
return {trending, plid}
|
||||
end
|
||||
|
||||
def extract_plid(url)
|
||||
wrapper = HTTP::Params.parse(URI.parse(url).query.not_nil!)["bp"]
|
||||
|
||||
wrapper = URI.unescape(wrapper)
|
||||
wrapper = Base64.decode(wrapper)
|
||||
|
||||
# 0xe2 0x02 0x2e
|
||||
wrapper += 3
|
||||
|
||||
# 0x0a
|
||||
wrapper += 1
|
||||
|
||||
# Looks like "/m/[a-z0-9]{5}", not sure what it does here
|
||||
|
||||
item_size = wrapper[0]
|
||||
wrapper += 1
|
||||
item = wrapper[0, item_size]
|
||||
wrapper += item.size
|
||||
|
||||
# 0x12
|
||||
wrapper += 1
|
||||
|
||||
plid_size = wrapper[0]
|
||||
wrapper += 1
|
||||
plid = wrapper[0, plid_size]
|
||||
wrapper += plid.size
|
||||
|
||||
plid = String.new(plid)
|
||||
|
||||
return plid
|
||||
end
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
<%= rendered "components/feed_menu" %>
|
||||
|
||||
<div class="pure-g h-box">
|
||||
<div class="pure-u-2-3">
|
||||
<form class="pure-form pure-form-aligned" action="/feed/trending" method="get">
|
||||
</form>
|
||||
<div style="align-self:flex-end" class="pure-u-2-3">
|
||||
<% if plid %>
|
||||
<a href="/playlist?list=<%= plid %>"><%= translate(locale, "View as playlist") %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pure-u-1-3">
|
||||
<div class="pure-g" style="text-align:right;">
|
||||
|
|
Loading…
Reference in a new issue