mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 22:39:31 -05:00
Add support for /c/ URLs
This commit is contained in:
parent
0f2f273335
commit
98d71ca8e7
@ -1557,6 +1557,23 @@ end
|
|||||||
|
|
||||||
# Channels
|
# Channels
|
||||||
|
|
||||||
|
# YouTube appears to let users set a "brand" URL that
|
||||||
|
# is different from their username, so we convert that here
|
||||||
|
get "/c/:user" do |env|
|
||||||
|
client = make_client(YT_URL)
|
||||||
|
user = env.params.url["user"]
|
||||||
|
|
||||||
|
response = client.get("/c/#{user}")
|
||||||
|
document = XML.parse_html(response.body)
|
||||||
|
|
||||||
|
anchor = document.xpath_node(%q(//a[contains(@class,"branded-page-header-title-link")]))
|
||||||
|
if !anchor
|
||||||
|
next env.redirect "/"
|
||||||
|
end
|
||||||
|
|
||||||
|
env.redirect anchor["href"]
|
||||||
|
end
|
||||||
|
|
||||||
get "/user/:user" do |env|
|
get "/user/:user" do |env|
|
||||||
user = env.params.url["user"]
|
user = env.params.url["user"]
|
||||||
env.redirect "/channel/#{user}"
|
env.redirect "/channel/#{user}"
|
||||||
|
Loading…
Reference in New Issue
Block a user