Invidious is an alternative front-end to YouTube
Update channel feed
Omar Rothd51b23bc167b
diff --git a/src/invidious.cr b/src/invidious.crindex a8b9e6d1..6c1cc5cd 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -1257,9 +1257,6 @@ get "/feed/channel/:ucid" do |env|endcontent_html = json["content_html"].as_s- if content_html.empty?- halt env, status_code: 403- enddocument = XML.parse_html(content_html)host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"])@@ -1280,35 +1277,52 @@ get "/feed/channel/:ucid" do |env|enddocument.xpath_nodes(%q(//li[contains(@class, "feed-item-container")])).each do |node|- anchor = node.xpath_node(%q(.//h3[contains(@class,"yt-lockup-title")]/a)).not_nil!+ anchor = node.xpath_node(%q(.//h3[contains(@class,"yt-lockup-title")]/a))+ if !anchor+ next+ end++ if anchor["href"].starts_with? "https://www.googleadservices.com"+ next+ end+title = anchor.content.stripvideo_id = anchor["href"].lchop("/watch?v=")- view_count = node.xpath_node(%q(.//div[@class="yt-lockup-meta"]/ul/li[2])).not_nil!- view_count = view_count.content.rchop(" views")- if view_count == "No"- view_count = 0+ metadata = node.xpath_nodes(%q(.//div[contains(@class,"yt-lockup-meta")]/ul/li))+ if metadata.size == 0+ next+ elsif metadata.size == 1+ view_count = metadata[0].content.split(" ")[0].delete(",").to_i64+ published = Time.nowelse- view_count = view_count.delete(",").to_i64+ published = decode_date(metadata[0].content)++ view_count = metadata[1].content.split(" ")[0]+ if view_count == "No"+ view_count = 0_i64+ else+ view_count = view_count.delete(",").to_i64+ endend- descriptionHtml = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-description")]))- if !descriptionHtml+ description_html = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-description")]))+ if !description_htmldescription = ""- descriptionHtml = ""+ description_html = ""else- descriptionHtml = descriptionHtml.to_s- description = descriptionHtml.gsub("<br>", "\n")+ description_html = description_html.to_s+ description = description_html.gsub("<br>", "\n")description = description.gsub("<br/>", "\n")description = XML.parse_html(description).content.strip("\n ")end- published = node.xpath_node(%q(.//div[@class="yt-lockup-meta"]/ul/li[1]))- if !published- next+ length_seconds = node.xpath_node(%q(.//span[@class="video-time"]))+ if length_seconds+ length_seconds = decode_length_seconds(length_seconds.content)+ else+ length_seconds = -1end- published = published.content- published = decode_date(published)xml.element("entry") doxml.element("id") { xml.text "yt:video:#{video_id}" }diff --git a/src/invidious/search.cr b/src/invidious/search.crindex 08c8d100..6b6d3f57 100644--- a/src/invidious/search.cr+++ b/src/invidious/search.cr@@ -33,7 +33,7 @@ def search(query, page = 1, search_params = build_search_params(content_type: "vendtitle = anchor.content.strip- id = anchor["href"].lchop("/watch?v=")+ video_id = anchor["href"].lchop("/watch?v=")anchor = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-byline")]/a)).not_nil!author = anchor.content@@ -77,7 +77,7 @@ def search(query, page = 1, search_params = build_search_params(content_type: "vvideo = SearchVideo.new(title,- id,+ video_id,author,ucid,published,