mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
integrate legacy yt xml subscription import with new json sub import
This commit is contained in:
parent
489d0151ad
commit
a2f79a163f
1 changed files with 10 additions and 4 deletions
|
@ -760,10 +760,16 @@ post "/data_control" do |env|
|
|||
end
|
||||
end
|
||||
when "import_youtube"
|
||||
subscriptions = JSON.parse(body)
|
||||
|
||||
user.subscriptions += subscriptions.as_a.compact_map do |entry|
|
||||
entry["snippet"]["resourceId"]["channelId"].as_s
|
||||
if body[0..4] == "<opml"
|
||||
subscriptions = XML.parse(body)
|
||||
user.subscriptions += subscriptions.xpath_nodes(%q(//outline[@type="rss"])).map do |channel|
|
||||
channel["xmlUrl"].match(/UC[a-zA-Z0-9_-]{22}/).not_nil![0]
|
||||
end
|
||||
else
|
||||
subscriptions = JSON.parse(body)
|
||||
user.subscriptions += subscriptions.as_a.compact_map do |entry|
|
||||
entry["snippet"]["resourceId"]["channelId"].as_s
|
||||
end
|
||||
end
|
||||
user.subscriptions.uniq!
|
||||
|
||||
|
|
Loading…
Reference in a new issue