mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Test if body content is likely JSON, if so parse the json format of subscriptions export. If the content is anything else, assume it is CSV and parse
This commit is contained in:
parent
7cbd79fee5
commit
43ff3be751
1 changed files with 4 additions and 1 deletions
|
@ -821,11 +821,14 @@ post "/data_control" do |env|
|
||||||
user.subscriptions += subscriptions.xpath_nodes(%q(//outline[@type="rss"])).map do |channel|
|
user.subscriptions += subscriptions.xpath_nodes(%q(//outline[@type="rss"])).map do |channel|
|
||||||
channel["xmlUrl"].match(/UC[a-zA-Z0-9_-]{22}/).not_nil![0]
|
channel["xmlUrl"].match(/UC[a-zA-Z0-9_-]{22}/).not_nil![0]
|
||||||
end
|
end
|
||||||
else
|
elsif body[0] == '['
|
||||||
subscriptions = JSON.parse(body)
|
subscriptions = JSON.parse(body)
|
||||||
user.subscriptions += subscriptions.as_a.compact_map do |entry|
|
user.subscriptions += subscriptions.as_a.compact_map do |entry|
|
||||||
entry["snippet"]["resourceId"]["channelId"].as_s
|
entry["snippet"]["resourceId"]["channelId"].as_s
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
subscriptions = parse_subscription_export_csv(body)
|
||||||
|
user.subscriptions += subscriptions
|
||||||
end
|
end
|
||||||
user.subscriptions.uniq!
|
user.subscriptions.uniq!
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue