forked from midou/invidious
Add support for channel redirects
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user