summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2021-10-29 16:01:52 +0200
committerSamantaz Fox <coding@samantaz.fr>2021-10-29 16:26:42 +0200
commit6cf0ff6b49ee6b189eb5a308089dc86d42f79019 (patch)
treec8616d72e46ad6790b2dcaf27f4bb196ea17f198
parent86f75758a76427dd7564ef17bc6a33b6d7ce2e62 (diff)
downloadinvidious-6cf0ff6b49ee6b189eb5a308089dc86d42f79019.tar.gz
invidious-6cf0ff6b49ee6b189eb5a308089dc86d42f79019.tar.bz2
invidious-6cf0ff6b49ee6b189eb5a308089dc86d42f79019.zip
Remove useless auto_generated param from PlaylistVideo#to_xml
given the variables available in this function's context, 'author' and 'ucid' provide the same data 'self.author' and 'self.ucid', respectively. Given that fact, the variable `auto_generated` has no impact on the logic of this function, and hence can be safely removed. this greatly simplifies the code and makes it perfectly compatible with crystal's calling convention for '#to_xml' methods.
-rw-r--r--src/invidious/playlists.cr21
-rw-r--r--src/invidious/routes/feeds.cr4
2 files changed, 6 insertions, 19 deletions
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index e25180c1..f37667b5 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -11,7 +11,7 @@ struct PlaylistVideo
property index : Int64
property live_now : Bool
- def to_xml(auto_generated, xml : XML::Builder)
+ def to_xml(xml : XML::Builder)
xml.element("entry") do
xml.element("id") { xml.text "yt:video:#{self.id}" }
xml.element("yt:videoId") { xml.text self.id }
@@ -20,13 +20,8 @@ struct PlaylistVideo
xml.element("link", rel: "alternate", href: "#{HOST_URL}/watch?v=#{self.id}")
xml.element("author") do
- if auto_generated
- xml.element("name") { xml.text self.author }
- xml.element("uri") { xml.text "#{HOST_URL}/channel/#{self.ucid}" }
- else
- xml.element("name") { xml.text author }
- xml.element("uri") { xml.text "#{HOST_URL}/channel/#{ucid}" }
- end
+ xml.element("name") { xml.text self.author }
+ xml.element("uri") { xml.text "#{HOST_URL}/channel/#{self.ucid}" }
end
xml.element("content", type: "xhtml") do
@@ -47,14 +42,8 @@ struct PlaylistVideo
end
end
- def to_xml(auto_generated, xml : XML::Builder? = nil)
- if xml
- to_xml(auto_generated, xml)
- else
- XML.build do |xml|
- to_xml(auto_generated, xml)
- end
- end
+ def to_xml(_xml : Nil = nil)
+ XML.build { |xml| to_xml(xml) }
end
def to_json(json : JSON::Builder, index : Int32? = nil)
diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr
index 40c41dc1..f4a8467b 100644
--- a/src/invidious/routes/feeds.cr
+++ b/src/invidious/routes/feeds.cr
@@ -281,9 +281,7 @@ module Invidious::Routes::Feeds
xml.element("name") { xml.text playlist.author }
end
- videos.each do |video|
- video.to_xml(false, xml)
- end
+ videos.each &.to_xml(xml)
end
end
else