Fix channel RSS feed

This commit is contained in:
Omar Roth 2019-02-18 16:06:00 -06:00
parent 1ceb827a82
commit 92223dbee5

View File

@ -1929,9 +1929,39 @@ get "/feed/channel/:ucid" do |env|
halt env, status_code: 500, response: error_message halt env, status_code: 500, response: error_message
end end
page = 1 client = make_client(YT_URL)
videos, count = get_60_videos(ucid, page, auto_generated) rss = client.get("/feeds/videos.xml?channel_id=#{ucid}").body
videos.select! { |video| !video.paid } rss = XML.parse_html(rss)
videos = [] of SearchVideo
rss.xpath_nodes("//feed/entry").each do |entry|
video_id = entry.xpath_node("videoid").not_nil!.content
title = entry.xpath_node("title").not_nil!.content
published = Time.parse(entry.xpath_node("published").not_nil!.content, "%FT%X%z", Time::Location.local)
updated = Time.parse(entry.xpath_node("updated").not_nil!.content, "%FT%X%z", Time::Location.local)
author = entry.xpath_node("author/name").not_nil!.content
ucid = entry.xpath_node("channelid").not_nil!.content
description = entry.xpath_node("group/description").not_nil!.content
views = entry.xpath_node("group/community/statistics").not_nil!.["views"].to_i64
videos << SearchVideo.new(
title: title,
id: video_id,
author: author,
ucid: ucid,
published: published,
views: views,
description: description,
description_html: "",
length_seconds: 0,
live_now: false,
paid: false,
premium: false
)
end
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain) host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
path = env.request.path path = env.request.path