summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/invidious/helpers/utils.cr22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index 8453d605..6d12fe8d 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -1,3 +1,5 @@
+require "csv"
+
# See http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
def ci_lower_bound(pos, n)
if n == 0
@@ -367,3 +369,23 @@ def fetch_random_instance
return filtered_instance_list.sample(1)[0]
end
+
+def parse_subscription_export_csv(csv_content : String)
+ rows = CSV.new(csv_content, headers: true)
+ subscriptions = Array(String).new
+
+ rows.each do |row|
+ # Channel ID is the first column in the csv export we can't use the header
+ # name, because I believe the header name is localized depending on the
+ # language the user has set on their account
+ channel_id = row[0].strip
+
+ if channel_id.empty?
+ next
+ end
+
+ subscriptions << channel_id
+ end
+
+ subscriptions
+end