Compare commits

...

6 Commits

Author SHA1 Message Date
ChunkyProgrammer
55327924a3
Merge 90918bad42 into 53e8a5d62d 2024-10-01 02:02:39 +00:00
ChunkyProgrammer
90918bad42 remove icon element from channel rss feed 2024-09-30 22:02:32 -04:00
ChunkyProgrammer
950672ae74 do a sanity check on the provided ucid
Co-Authored-By: absidue <48293849+absidue@users.noreply.github.com>
Co-Authored-By: Samantaz Fox <coding@samantaz.fr>
2024-09-30 22:02:32 -04:00
ChunkyProgrammer
6606eabb32 Channel RSS: deprecate author thumbnail, make less requests to youtube 2024-09-30 22:02:32 -04:00
ChunkyProgrammer
2192652e72 RSS: return 404 if youtube playlist doesnt exist 2024-09-30 22:02:32 -04:00
TheFrenchGhosty
53e8a5d62d
Remove myself from CODEOWNERS on the config file (#4942) 2024-09-28 23:54:52 +02:00
2 changed files with 24 additions and 28 deletions

2
.github/CODEOWNERS vendored
View File

@ -6,7 +6,7 @@ docker/ @unixfox
kubernetes/ @unixfox kubernetes/ @unixfox
README.md @thefrenchghosty README.md @thefrenchghosty
config/config.example.yml @thefrenchghosty @SamantazFox @unixfox config/config.example.yml @SamantazFox @unixfox
scripts/ @syeopite scripts/ @syeopite
shards.lock @syeopite shards.lock @syeopite

View File

@ -143,32 +143,25 @@ module Invidious::Routes::Feeds
# RSS feeds # RSS feeds
def self.rss_channel(env) def self.rss_channel(env)
locale = env.get("preferences").as(Preferences).locale
env.response.headers["Content-Type"] = "application/atom+xml" env.response.headers["Content-Type"] = "application/atom+xml"
env.response.content_type = "application/atom+xml" env.response.content_type = "application/atom+xml"
if env.params.url["ucid"].matches?(/^[\w-]+$/)
ucid = env.params.url["ucid"] ucid = env.params.url["ucid"]
else
return error_atom(400, InfoException.new("Invalid channel ucid provided."))
end
params = HTTP::Params.parse(env.params.query["params"]? || "") params = HTTP::Params.parse(env.params.query["params"]? || "")
begin
channel = get_about_info(ucid, locale)
rescue ex : ChannelRedirect
return env.redirect env.request.resource.gsub(ucid, ex.channel_id)
rescue ex : NotFoundException
return error_atom(404, ex)
rescue ex
return error_atom(500, ex)
end
namespaces = { namespaces = {
"yt" => "http://www.youtube.com/xml/schemas/2015", "yt" => "http://www.youtube.com/xml/schemas/2015",
"media" => "http://search.yahoo.com/mrss/", "media" => "http://search.yahoo.com/mrss/",
"default" => "http://www.w3.org/2005/Atom", "default" => "http://www.w3.org/2005/Atom",
} }
response = YT_POOL.client &.get("/feeds/videos.xml?channel_id=#{channel.ucid}") response = YT_POOL.client &.get("/feeds/videos.xml?channel_id=#{ucid}")
return error_atom(404, NotFoundException.new("Channel does not exist.")) if response.status_code == 404
rss = XML.parse(response.body) rss = XML.parse(response.body)
videos = rss.xpath_nodes("//default:feed/default:entry", namespaces).map do |entry| videos = rss.xpath_nodes("//default:feed/default:entry", namespaces).map do |entry|
@ -179,7 +172,7 @@ module Invidious::Routes::Feeds
updated = Time.parse_rfc3339(entry.xpath_node("default:updated", namespaces).not_nil!.content) updated = Time.parse_rfc3339(entry.xpath_node("default:updated", namespaces).not_nil!.content)
author = entry.xpath_node("default:author/default:name", namespaces).not_nil!.content author = entry.xpath_node("default:author/default:name", namespaces).not_nil!.content
ucid = entry.xpath_node("yt:channelId", namespaces).not_nil!.content video_ucid = entry.xpath_node("yt:channelId", namespaces).not_nil!.content
description_html = entry.xpath_node("media:group/media:description", namespaces).not_nil!.to_s description_html = entry.xpath_node("media:group/media:description", namespaces).not_nil!.to_s
views = entry.xpath_node("media:group/media:community/media:statistics", namespaces).not_nil!.["views"].to_i64 views = entry.xpath_node("media:group/media:community/media:statistics", namespaces).not_nil!.["views"].to_i64
@ -187,7 +180,7 @@ module Invidious::Routes::Feeds
title: title, title: title,
id: video_id, id: video_id,
author: author, author: author,
ucid: ucid, ucid: video_ucid,
published: published, published: published,
views: views, views: views,
description_html: description_html, description_html: description_html,
@ -200,30 +193,32 @@ module Invidious::Routes::Feeds
}) })
end end
author = ""
author = videos[0].author if videos.size > 0
XML.build(indent: " ", encoding: "UTF-8") do |xml| XML.build(indent: " ", encoding: "UTF-8") do |xml|
xml.element("feed", "xmlns:yt": "http://www.youtube.com/xml/schemas/2015", xml.element("feed", "xmlns:yt": "http://www.youtube.com/xml/schemas/2015",
"xmlns:media": "http://search.yahoo.com/mrss/", xmlns: "http://www.w3.org/2005/Atom", "xmlns:media": "http://search.yahoo.com/mrss/", xmlns: "http://www.w3.org/2005/Atom",
"xml:lang": "en-US") do "xml:lang": "en-US") do
xml.element("link", rel: "self", href: "#{HOST_URL}#{env.request.resource}") xml.element("link", rel: "self", href: "#{HOST_URL}#{env.request.resource}")
xml.element("id") { xml.text "yt:channel:#{channel.ucid}" } xml.element("id") { xml.text "yt:channel:#{ucid}" }
xml.element("yt:channelId") { xml.text channel.ucid } xml.element("yt:channelId") { xml.text ucid }
xml.element("icon") { xml.text channel.author_thumbnail } xml.element("title") { author }
xml.element("title") { xml.text channel.author } xml.element("link", rel: "alternate", href: "#{HOST_URL}/channel/#{ucid}")
xml.element("link", rel: "alternate", href: "#{HOST_URL}/channel/#{channel.ucid}")
xml.element("author") do xml.element("author") do
xml.element("name") { xml.text channel.author } xml.element("name") { xml.text author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{channel.ucid}" } xml.element("uri") { xml.text "#{HOST_URL}/channel/#{ucid}" }
end end
xml.element("image") do xml.element("image") do
xml.element("url") { xml.text channel.author_thumbnail } xml.element("url") { xml.text "" }
xml.element("title") { xml.text channel.author } xml.element("title") { xml.text author }
xml.element("link", rel: "self", href: "#{HOST_URL}#{env.request.resource}") xml.element("link", rel: "self", href: "#{HOST_URL}#{env.request.resource}")
end end
videos.each do |video| videos.each do |video|
video.to_xml(channel.auto_generated, params, xml) video.to_xml(false, params, xml)
end end
end end
end end
@ -311,8 +306,9 @@ module Invidious::Routes::Feeds
end end
response = YT_POOL.client &.get("/feeds/videos.xml?playlist_id=#{plid}") response = YT_POOL.client &.get("/feeds/videos.xml?playlist_id=#{plid}")
document = XML.parse(response.body) return error_atom(404, NotFoundException.new("Playlist does not exist.")) if response.status_code == 404
document = XML.parse(response.body)
document.xpath_nodes(%q(//*[@href]|//*[@url])).each do |node| document.xpath_nodes(%q(//*[@href]|//*[@url])).each do |node|
node.attributes.each do |attribute| node.attributes.each do |attribute|
case attribute.name case attribute.name