summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthtmnisamnstr <gavinj1984@gmail.com>2023-04-03 17:07:58 -0700
committerthtmnisamnstr <gavinj1984@gmail.com>2023-04-03 17:07:58 -0700
commitfffdaa1410db7f9b5c67b1b47d401a2744e7b220 (patch)
tree4b84be41e8227be1782fd4e19c2853d8f0f7c51e
parent3341929060bb20c086974a282fd1e33029f685f3 (diff)
downloadinvidious-fffdaa1410db7f9b5c67b1b47d401a2744e7b220.tar.gz
invidious-fffdaa1410db7f9b5c67b1b47d401a2744e7b220.tar.bz2
invidious-fffdaa1410db7f9b5c67b1b47d401a2744e7b220.zip
Updated csv reading as per feedback and ran
Signed-off-by: thtmnisamnstr <gavinj1984@gmail.com>
-rw-r--r--src/invidious/user/imports.cr53
1 files changed, 26 insertions, 27 deletions
diff --git a/src/invidious/user/imports.cr b/src/invidious/user/imports.cr
index 757f5b13..673991f7 100644
--- a/src/invidious/user/imports.cr
+++ b/src/invidious/user/imports.cr
@@ -40,7 +40,7 @@ struct Invidious::User
title = csv_head[4]
description = csv_head[5]
visibility = csv_head[6]
-
+
if visibility.compare("Public", case_insensitive: true) == 0
privacy = PlaylistPrivacy::Public
else
@@ -51,34 +51,33 @@ struct Invidious::User
Invidious::Database::Playlists.update_description(playlist.id, description)
# Add each video to the playlist from the body content
- CSV.each_row(raw_body) do |row|
- if row.size >= 1
- video_id = row[0]
- if playlist
- next if !video_id
- next if video_id == "Video Id"
-
- begin
- video = get_video(video_id)
- rescue ex
- next
- end
-
- playlist_video = PlaylistVideo.new({
- title: video.title,
- id: video.id,
- author: video.author,
- ucid: video.ucid,
- length_seconds: video.length_seconds,
- published: video.published,
- plid: playlist.id,
- live_now: video.live_now,
- index: Random::Secure.rand(0_i64..Int64::MAX),
- })
+ csv_body = CSV.new(raw_body, headers: true)
+ csv_body.each do |row|
+ video_id = row[0]
+ if playlist
+ next if !video_id
+ next if video_id == "Video Id"
- Invidious::Database::PlaylistVideos.insert(playlist_video)
- Invidious::Database::Playlists.update_video_added(playlist.id, playlist_video.index)
+ begin
+ video = get_video(video_id)
+ rescue ex
+ next
end
+
+ playlist_video = PlaylistVideo.new({
+ title: video.title,
+ id: video.id,
+ author: video.author,
+ ucid: video.ucid,
+ length_seconds: video.length_seconds,
+ published: video.published,
+ plid: playlist.id,
+ live_now: video.live_now,
+ index: Random::Secure.rand(0_i64..Int64::MAX),
+ })
+
+ Invidious::Database::PlaylistVideos.insert(playlist_video)
+ Invidious::Database::Playlists.update_video_added(playlist.id, playlist_video.index)
end
end