diff options
| author | bbielsa <bgb7@njit.edu> | 2021-10-27 17:54:40 -0400 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2022-01-08 18:07:06 +0100 |
| commit | 43ff3be751920bedb394ff5cf8cd27812131c489 (patch) | |
| tree | 6d59a56c92968d2cd32d680d2e57e52657c2d2b3 | |
| parent | 7cbd79fee5f87c5c611685100ef8167d90b831f5 (diff) | |
| download | invidious-43ff3be751920bedb394ff5cf8cd27812131c489.tar.gz invidious-43ff3be751920bedb394ff5cf8cd27812131c489.tar.bz2 invidious-43ff3be751920bedb394ff5cf8cd27812131c489.zip | |
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
| -rw-r--r-- | src/invidious.cr | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index fb67af87..3a358c20 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -821,11 +821,14 @@ post "/data_control" do |env| 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 + elsif body[0] == '[' subscriptions = JSON.parse(body) user.subscriptions += subscriptions.as_a.compact_map do |entry| entry["snippet"]["resourceId"]["channelId"].as_s end + else + subscriptions = parse_subscription_export_csv(body) + user.subscriptions += subscriptions end user.subscriptions.uniq! |
