Created
September 18, 2015 11:03
-
-
Save josteink/c4d9bc311f7c2e632f36 to your computer and use it in GitHub Desktop.
A emacs-lisp function to convert a spotify-playlist exported from spotlistr to work with gmusic-playlist to import into Google Music.
This file contains hidden or 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
(defun hour-minute-seconds-to-milliseconds (input) | |
"Convert a string of format 01:02:03 to milliseconds." | |
(with-temp-buffer | |
(insert input) | |
(goto-char (point-min)) | |
(search-forward-regexp "\\([[:digit:]]+\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\)") | |
(let* ((hour (string-to-number (match-string 1))) | |
(minutes (* 60 hour)) | |
(minute (string-to-number (match-string 2))) | |
(seconds (* 60 (+ minute minutes))) | |
(second (string-to-number (match-string 3))) | |
(total (+ second seconds))) | |
(* 1000 total)))) | |
(defun kill-ring-to-milliseconds () | |
(interactive) | |
(insert (number-to-string (hour-minute-seconds-to-milliseconds (car kill-ring))))) | |
(defun convert-playlist () | |
(interactive) | |
(goto-char (point-min)) | |
(with-no-warnings | |
(while t | |
(search-forward "|") ;; to ensure failure on when we have passed last item. | |
(end-of-line) | |
(search-backward "|") | |
(forward-char) | |
(forward-char) | |
(kill-line) | |
(kill-ring-to-milliseconds) | |
(beginning-of-line) | |
(let ((line-move-visual nil)) | |
(next-line nil nil))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can have a try this Spotify to Google Play Converter, called Free Spotify to MP3 Converter for Mac, which can download Spotify music and playlists as local files compatible with Google Play Music and then you can freely transfer Spotify playlists to Google Player.
This is a detailed tutorial for your reference: How to Transfer Spotify Playlist to Google Play