Created
November 9, 2020 21:22
-
-
Save locofocos/10d72892e7e8eddbc6f40e9560aacf65 to your computer and use it in GitHub Desktop.
A ruby script for converting Google Play Music playlists to a Soundizz CSV format for importing to Spotify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# json_file_path is the response body from some REST endpoint that google play music | |
# used to return the contents of a playlist as you loaded it in the web UI. | |
# So you need to have saved this before GPM shut down. | |
# | |
# output_csv_file_path will contain a CSV file in a format suitable for https://soundiiz.com/ | |
require 'JSON' | |
require 'byebug' | |
raise 'need json_file_path' unless ARGV[0] | |
json_file_path = ARGV[0] | |
puts 'json_file_path is ' + json_file_path | |
raise 'need output_csv_file_path' unless ARGV[1] | |
output_csv_file_path = ARGV[1] | |
puts 'output_csv_file_path is ' + output_csv_file_path | |
puts | |
string_input = File.read(json_file_path) | |
json_input = JSON.parse(string_input) | |
songs = json_input[1].first | |
output = "title;artist;album;isrc;\n" | |
songs.each do |song| | |
title = song[1] | |
artist = song[3] | |
album = song[4] | |
output += title | |
output += ';' | |
output += artist | |
output += ';' | |
output += album | |
output += ';' | |
output += ';' | |
output += "\n" | |
end | |
File.write(output_csv_file_path, output) | |
puts 'wrote to ' + output_csv_file_path | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment