summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-06-12 21:09:39 +0200
committerSamantaz Fox <coding@samantaz.fr>2023-06-12 21:09:39 +0200
commite6f5fcbc4b7eab7bdeee1a1d2586334f34f50af7 (patch)
treede1e2d7530faec03d1dbce0ad9338c83e11db8b4 /src
parentdf6b51f9c6de61f6f6b4db797856ff64d02f8223 (diff)
parent1b942f4f0a9b9bad3b9447de2adb99401204cc2c (diff)
downloadinvidious-e6f5fcbc4b7eab7bdeee1a1d2586334f34f50af7.tar.gz
invidious-e6f5fcbc4b7eab7bdeee1a1d2586334f34f50af7.tar.bz2
invidious-e6f5fcbc4b7eab7bdeee1a1d2586334f34f50af7.zip
User: Strip empty new lines before parsing CSV (#3895)
Diffstat (limited to 'src')
-rw-r--r--src/invidious/user/imports.cr8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/invidious/user/imports.cr b/src/invidious/user/imports.cr
index e4b25156..0a2fe1e2 100644
--- a/src/invidious/user/imports.cr
+++ b/src/invidious/user/imports.cr
@@ -6,7 +6,7 @@ struct Invidious::User
# Parse a youtube CSV subscription file
def parse_subscription_export_csv(csv_content : String)
- rows = CSV.new(csv_content, headers: true)
+ rows = CSV.new(csv_content.strip('\n'), headers: true)
subscriptions = Array(String).new
# Counter to limit the amount of imports.
@@ -32,10 +32,10 @@ struct Invidious::User
def parse_playlist_export_csv(user : User, raw_input : String)
# Split the input into head and body content
- raw_head, raw_body = raw_input.split("\n\n", limit: 2, remove_empty: true)
+ raw_head, raw_body = raw_input.strip('\n').split("\n\n", limit: 2, remove_empty: true)
# Create the playlist from the head content
- csv_head = CSV.new(raw_head, headers: true)
+ csv_head = CSV.new(raw_head.strip('\n'), headers: true)
csv_head.next
title = csv_head[4]
description = csv_head[5]
@@ -51,7 +51,7 @@ struct Invidious::User
Invidious::Database::Playlists.update_description(playlist.id, description)
# Add each video to the playlist from the body content
- csv_body = CSV.new(raw_body, headers: true)
+ csv_body = CSV.new(raw_body.strip('\n'), headers: true)
csv_body.each do |row|
video_id = row[0]
if playlist