mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add support for channel redirects
This commit is contained in:
parent
86491da253
commit
68cf24d100
3 changed files with 54 additions and 11 deletions
|
@ -127,6 +127,13 @@ struct AboutChannel
|
|||
})
|
||||
end
|
||||
|
||||
class ChannelRedirect < Exception
|
||||
property channel_id : String
|
||||
|
||||
def initialize(@channel_id)
|
||||
end
|
||||
end
|
||||
|
||||
def get_batch_channels(channels, db, refresh = false, pull_all_videos = true, max_threads = 10)
|
||||
finished_channel = Channel(String | Nil).new
|
||||
|
||||
|
@ -927,6 +934,10 @@ def get_about_info(ucid, locale)
|
|||
about = client.get("/user/#{ucid}/about?disable_polymer=1&gl=US&hl=en")
|
||||
end
|
||||
|
||||
if md = about.headers["location"]?.try &.match(/\/channel\/(?<ucid>UC[a-zA-Z0-9_-]{22})/)
|
||||
raise ChannelRedirect.new(channel_id: md["ucid"])
|
||||
end
|
||||
|
||||
about = XML.parse_html(about.body)
|
||||
|
||||
if about.xpath_node(%q(//div[contains(@class, "channel-empty-message")]))
|
||||
|
|
|
@ -882,6 +882,10 @@ struct CaptionName
|
|||
end
|
||||
|
||||
class VideoRedirect < Exception
|
||||
property video_id : String
|
||||
|
||||
def initialize(@video_id)
|
||||
end
|
||||
end
|
||||
|
||||
def get_video(id, db, refresh = true, region = nil, force_refresh = false)
|
||||
|
@ -1149,7 +1153,7 @@ def fetch_video(id, region)
|
|||
response = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")
|
||||
|
||||
if md = response.headers["location"]?.try &.match(/v=(?<id>[a-zA-Z0-9_-]{11})/)
|
||||
raise VideoRedirect.new(md["id"])
|
||||
raise VideoRedirect.new(video_id: md["id"])
|
||||
end
|
||||
|
||||
html = XML.parse_html(response.body)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue