mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-26 16:52:12 +05:30
FK: let crystal tool format do its magic and replace the spaces before in-line comments with a random number of tabs, to get the lint check to work
This commit is contained in:
parent
1e3bbe2781
commit
4a70164539
@ -30,13 +30,11 @@ struct Invidious::User
|
|||||||
return subscriptions
|
return subscriptions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def parse_playlist_export_csv(user : User, raw_input : String, filename : String)
|
def parse_playlist_export_csv(user : User, raw_input : String, filename : String)
|
||||||
|
|
||||||
LOGGER.trace("parse_playlist_export_csv: 01 raw_input '#{raw_input}'\n")
|
LOGGER.trace("parse_playlist_export_csv: 01 raw_input '#{raw_input}'\n")
|
||||||
|
|
||||||
raw_head = "" # playlists.csv - info-line for a given playlist in the google export, that's copied above the actual playlist-infos and separated by an empty line from
|
raw_head = "" # playlists.csv - info-line for a given playlist in the google export, that's copied above the actual playlist-infos and separated by an empty line from
|
||||||
raw_body = "" # the actual playlist content, ie. a list of videos
|
raw_body = "" # the actual playlist content, ie. a list of videos
|
||||||
|
|
||||||
# remove superfluous \n instances in front of and after any non-\n text.. so .. a trim?
|
# remove superfluous \n instances in front of and after any non-\n text.. so .. a trim?
|
||||||
raw_input = raw_input.strip('\n')
|
raw_input = raw_input.strip('\n')
|
||||||
@ -55,18 +53,17 @@ struct Invidious::User
|
|||||||
# TODO create an import-feature (elsewhere), which works for the original google export format, ie. the playlists/ subdirectory content as a ZIP file.. or a complete youtube music export file, but this goes way beyond the scope of a playlist import.
|
# TODO create an import-feature (elsewhere), which works for the original google export format, ie. the playlists/ subdirectory content as a ZIP file.. or a complete youtube music export file, but this goes way beyond the scope of a playlist import.
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
title = "title not set" # TODO i8n
|
title = "title not set" # TODO i8n
|
||||||
description = "from #{filename}" # TODO i8n
|
description = "from #{filename}" # TODO i8n
|
||||||
visibility = "Private"
|
visibility = "Private"
|
||||||
privacy = PlaylistPrivacy::Private
|
privacy = PlaylistPrivacy::Private
|
||||||
|
|
||||||
if (raw_head != "")
|
if (raw_head != "")
|
||||||
|
# ## XXX for documentation of current file format of playlists.csv (today it's 2024-01-07):
|
||||||
### XXX for documentation of current file format of playlists.csv (today it's 2024-01-07):
|
# 0 1 2 3 4 5 6 7 8 9 10 11
|
||||||
#0 1 2 3 4 5 6 7 8 9 10 11
|
# Playlist ID,Add new videos to top,Playlist image 1 Create timestamp,Playlist image 1 URL,Playlist image 1 Height,Playlist image 1 Width,Playlist title (original),Playlist title (original) language,Playlist create timestamp,Playlist update timestamp,Playlist video order,Playlist visibility
|
||||||
#Playlist ID,Add new videos to top,Playlist image 1 Create timestamp,Playlist image 1 URL,Playlist image 1 Height,Playlist image 1 Width,Playlist title (original),Playlist title (original) language,Playlist create timestamp,Playlist update timestamp,Playlist video order,Playlist visibility
|
# PLc5oiabcabcabcabcabcrOvXgzabcabcm,False,,,,,display name of playlist,,2015-01-01T01:02:03+00:00,2022-10-28T02:23:15+00:00,Manual,Public' ---
|
||||||
#PLc5oiabcabcabcabcabcrOvXgzabcabcm,False,,,,,display name of playlist,,2015-01-01T01:02:03+00:00,2022-10-28T02:23:15+00:00,Manual,Public' ---
|
# ##/documentation
|
||||||
###/documentation
|
|
||||||
|
|
||||||
# Create the playlist from the head content (if it seems to be valid):
|
# Create the playlist from the head content (if it seems to be valid):
|
||||||
csv_head = CSV.new(raw_head.strip('\n'), headers: true)
|
csv_head = CSV.new(raw_head.strip('\n'), headers: true)
|
||||||
@ -74,14 +71,14 @@ struct Invidious::User
|
|||||||
if csv_head[11]
|
if csv_head[11]
|
||||||
LOGGER.info("parse_playlist_export_csv: 03.1 raw_head is filled, doing dual csv playlist info scan. google takeout format after october 2023 (format seems to be one line of playlist metadata taken out of the google export's playlists.csv file, added above the actual playlist.csv content, separated by an empty line)")
|
LOGGER.info("parse_playlist_export_csv: 03.1 raw_head is filled, doing dual csv playlist info scan. google takeout format after october 2023 (format seems to be one line of playlist metadata taken out of the google export's playlists.csv file, added above the actual playlist.csv content, separated by an empty line)")
|
||||||
title = csv_head[6]
|
title = csv_head[6]
|
||||||
description = "Playlist was imported from file '#{filename}'\n\nCreated on #{csv_head[8]}\nLast updated on #{csv_head[9]}\n" # TODO i8n
|
description = "Playlist was imported from file '#{filename}'\n\nCreated on #{csv_head[8]}\nLast updated on #{csv_head[9]}\n" # TODO i8n
|
||||||
visibility = csv_head[11]
|
visibility = csv_head[11]
|
||||||
elsif csv_head[6]
|
elsif csv_head[6]
|
||||||
LOGGER.info("parse_playlist_export_csv: 03.2 raw_head is filled, doing dual csv playlist info scan. google takeout format before october 2023 (roughly).")
|
LOGGER.info("parse_playlist_export_csv: 03.2 raw_head is filled, doing dual csv playlist info scan. google takeout format before october 2023 (roughly).")
|
||||||
title = csv_head[4]
|
title = csv_head[4]
|
||||||
description = csv_head[5]
|
description = csv_head[5]
|
||||||
visibility = csv_head[6]
|
visibility = csv_head[6]
|
||||||
else # we are using the defaults defined above instead.
|
else # we are using the defaults defined above instead.
|
||||||
LOGGER.info("parse_playlist_export_csv: 03.3 raw_head is filled, but in an unknown format. Using base defaults instead.")
|
LOGGER.info("parse_playlist_export_csv: 03.3 raw_head is filled, but in an unknown format. Using base defaults instead.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -90,13 +87,13 @@ struct Invidious::User
|
|||||||
else
|
else
|
||||||
privacy = PlaylistPrivacy::Private
|
privacy = PlaylistPrivacy::Private
|
||||||
end
|
end
|
||||||
else # choose a title from the provided upload filename
|
else # choose a title from the provided upload filename
|
||||||
LOGGER.info("parse_playlist_export_csv: 03.2 raw_head is empty. Trying to guess fine-looking title and description from the provided upload filename.")
|
LOGGER.info("parse_playlist_export_csv: 03.2 raw_head is empty. Trying to guess fine-looking title and description from the provided upload filename.")
|
||||||
if (filename != "")
|
if (filename != "")
|
||||||
title = filename
|
title = filename
|
||||||
end
|
end
|
||||||
nameendpos = filename.rindex(" videos.", filename.size) # XXX everything up to " videos.csv"
|
nameendpos = filename.rindex(" videos.", filename.size) # XXX everything up to " videos.csv"
|
||||||
if !nameendpos # XXX everything up to file extension
|
if !nameendpos # XXX everything up to file extension
|
||||||
nameendpos = filename.rindex(".", filename.size)
|
nameendpos = filename.rindex(".", filename.size)
|
||||||
end
|
end
|
||||||
if nameendpos
|
if nameendpos
|
||||||
@ -113,7 +110,7 @@ struct Invidious::User
|
|||||||
video_id = row[0]
|
video_id = row[0]
|
||||||
if playlist
|
if playlist
|
||||||
next if !video_id
|
next if !video_id
|
||||||
next if video_id == "Video Id" # TODO i8n
|
next if video_id == "Video Id" # TODO i8n
|
||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(video_id)
|
video = get_video(video_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user