mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Add helper function parse_subscription_export_csv() which parses the csv format returned by the subscription exporter
This commit is contained in:
parent
3fba342ed2
commit
7cbd79fee5
1 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue