|
|
@ -1382,24 +1382,40 @@ get "/feed/channel/:ucid" do |env|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
ucid = ucid.content
|
|
|
|
ucid = ucid.content
|
|
|
|
|
|
|
|
author = rss.xpath_node("//author/name").not_nil!.content
|
|
|
|
next env.redirect "/feed/channel/#{ucid}"
|
|
|
|
next env.redirect "/feed/channel/#{ucid}"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
rss = client.get("/feeds/videos.xml?channel_id=#{ucid}")
|
|
|
|
|
|
|
|
rss = XML.parse_html(rss.body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ucid = rss.xpath_node("//feed/channelid")
|
|
|
|
|
|
|
|
if !ucid
|
|
|
|
|
|
|
|
error_message = "User does not exist."
|
|
|
|
|
|
|
|
next templated "error"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ucid = ucid.content
|
|
|
|
|
|
|
|
author = rss.xpath_node("//author/name").not_nil!.content
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Auto-generated channels
|
|
|
|
|
|
|
|
# https://support.google.com/youtube/answer/2579942
|
|
|
|
|
|
|
|
if author.ends_with? " - Topic"
|
|
|
|
|
|
|
|
auto_generated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
url = produce_channel_videos_url(ucid)
|
|
|
|
url = produce_channel_videos_url(ucid, auto_generated: auto_generated)
|
|
|
|
response = client.get(url)
|
|
|
|
response = client.get(url)
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
|
|
|
|
|
|
|
|
if json["content_html"].as_s.empty?
|
|
|
|
if json["content_html"]? && !json["content_html"].as_s.empty?
|
|
|
|
if response.status_code == 500
|
|
|
|
document = XML.parse_html(json["content_html"].as_s)
|
|
|
|
error_message = "This channel does not exist."
|
|
|
|
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
|
|
|
halt env, status_code: 404, response: error_message
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
next ""
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
content_html = json["content_html"].as_s
|
|
|
|
videos = extract_videos(nodeset, ucid)
|
|
|
|
document = XML.parse_html(content_html)
|
|
|
|
else
|
|
|
|
|
|
|
|
videos = [] of SearchVideo
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
channel = get_channel(ucid, client, PG_DB, pull_all_videos: false)
|
|
|
|
channel = get_channel(ucid, client, PG_DB, pull_all_videos: false)
|
|
|
|
|
|
|
|
|
|
|
@ -1420,8 +1436,7 @@ get "/feed/channel/:ucid" do |env|
|
|
|
|
xml.element("uri") { xml.text "#{host_url}/channel/#{ucid}" }
|
|
|
|
xml.element("uri") { xml.text "#{host_url}/channel/#{ucid}" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
|
|
|
videos.each do |video|
|
|
|
|
extract_videos(nodeset, ucid).each do |video|
|
|
|
|
|
|
|
|
xml.element("entry") do
|
|
|
|
xml.element("entry") do
|
|
|
|
xml.element("id") { xml.text "yt:video:#{video.id}" }
|
|
|
|
xml.element("id") { xml.text "yt:video:#{video.id}" }
|
|
|
|
xml.element("yt:videoId") { xml.text video.id }
|
|
|
|
xml.element("yt:videoId") { xml.text video.id }
|
|
|
@ -1605,24 +1620,39 @@ get "/channel/:ucid" do |env|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
ucid = ucid.content
|
|
|
|
ucid = ucid.content
|
|
|
|
|
|
|
|
author = rss.xpath_node("//author/name").not_nil!.content
|
|
|
|
next env.redirect "/channel/#{ucid}"
|
|
|
|
next env.redirect "/channel/#{ucid}"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
rss = client.get("/feeds/videos.xml?channel_id=#{ucid}")
|
|
|
|
|
|
|
|
rss = XML.parse_html(rss.body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ucid = rss.xpath_node("//feed/channelid")
|
|
|
|
|
|
|
|
if !ucid
|
|
|
|
|
|
|
|
error_message = "User does not exist."
|
|
|
|
|
|
|
|
next templated "error"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ucid = ucid.content
|
|
|
|
|
|
|
|
author = rss.xpath_node("//author/name").not_nil!.content
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
rss = client.get("/feeds/videos.xml?channel_id=#{ucid}")
|
|
|
|
# Auto-generated channels
|
|
|
|
if rss.status_code == 404
|
|
|
|
# https://support.google.com/youtube/answer/2579942
|
|
|
|
error_message = "This channel does not exist."
|
|
|
|
if author.ends_with? " - Topic"
|
|
|
|
next templated "error"
|
|
|
|
auto_generated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
rss = XML.parse_html(rss.body)
|
|
|
|
url = produce_channel_videos_url(ucid, page, auto_generated: auto_generated)
|
|
|
|
author = rss.xpath_node("//feed/author/name").not_nil!.content
|
|
|
|
response = client.get(url)
|
|
|
|
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
if json["content_html"]? && !json["content_html"].as_s.empty?
|
|
|
|
videos = extract_playlist(ucid, page)
|
|
|
|
document = XML.parse_html(json["content_html"].as_s)
|
|
|
|
videos.each { |a| a.playlists.clear }
|
|
|
|
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
error_message = ex.message
|
|
|
|
videos = extract_videos(nodeset, ucid)
|
|
|
|
next templated "error"
|
|
|
|
else
|
|
|
|
|
|
|
|
videos = [] of SearchVideo
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
templated "channel"
|
|
|
|
templated "channel"
|
|
|
@ -2236,11 +2266,29 @@ get "/api/v1/channels/:ucid" do |env|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
ucid = ucid.content
|
|
|
|
ucid = ucid.content
|
|
|
|
url = "/api/v1/channels/#{ucid}"
|
|
|
|
author = rss.xpath_node("//author/name").not_nil!.content
|
|
|
|
next env.redirect url
|
|
|
|
next env.redirect "/api/v1/channels/#{ucid}"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
rss = client.get("/feeds/videos.xml?channel_id=#{ucid}")
|
|
|
|
|
|
|
|
rss = XML.parse_html(rss.body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ucid = rss.xpath_node("//feed/channelid")
|
|
|
|
|
|
|
|
if !ucid
|
|
|
|
|
|
|
|
error_message = "User does not exist."
|
|
|
|
|
|
|
|
next templated "error"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ucid = ucid.content
|
|
|
|
|
|
|
|
author = rss.xpath_node("//author/name").not_nil!.content
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Auto-generated channels
|
|
|
|
|
|
|
|
# https://support.google.com/youtube/answer/2579942
|
|
|
|
|
|
|
|
if author.ends_with? " - Topic"
|
|
|
|
|
|
|
|
auto_generated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
url = produce_channel_videos_url(ucid, 1)
|
|
|
|
url = produce_channel_videos_url(ucid, 1, auto_generated)
|
|
|
|
response = client.get(url)
|
|
|
|
response = client.get(url)
|
|
|
|
|
|
|
|
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|