File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -105,12 +105,25 @@ struct Invidious::User
105105 # Youtube
106106 # -------------------
107107
108+ private def is_opml? (mimetype : String , extension : String )
109+ opml_mimetypes = [
110+ " application/xml" ,
111+ " text/xml" ,
112+ " text/x-opml" ,
113+ " text/x-opml+xml" ,
114+ ]
115+
116+ opml_extensions = [" xml" , " opml" ]
117+
118+ return opml_mimetypes.any?(& .== mimetype) || opml_extensions.any?(& .== extension)
119+ end
120+
108121 # Import subscribed channels from Youtube
109122 # Returns success status
110123 def from_youtube (user : User , body : String , filename : String , type : String ) : Bool
111124 extension = filename.split(" ." ).last
112125
113- if extension == " xml " || type == " application/xml " || type == " text/xml "
126+ if is_opml?( type , extension)
114127 subscriptions = XML .parse(body)
115128 user.subscriptions += subscriptions.xpath_nodes(%q( //outline[@type="rss"]) ).map do |channel |
116129 channel[" xmlUrl" ].match(/UC[a-zA-Z0-9_-] {22} / ).not_nil![0 ]
You can’t perform that action at this time.
0 commit comments