From 22c15735a158b36f02ab30d05f1c317cb51d2f06 Mon Sep 17 00:00:00 2001 From: ho1ger Date: Tue, 5 May 2015 19:45:19 +0200 Subject: [PATCH 1/2] specify directory where mp3 should be stored; toggle sort by album/artist; fixed eye3d bug --- jbripper.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/jbripper.py b/jbripper.py index a56c605..9e8269a 100755 --- a/jbripper.py +++ b/jbripper.py @@ -8,6 +8,11 @@ import threading import time +## Options +dldir = "ripped/" # "": put mp3 directly into spotifyripper directory; "ripped/": put into "ripped" subdir +sort = True #True: sort mp3 into artist/album subdir; False: don't sort; put all mp3 into same directory + + playback = False # set if you want to listen to the tracks that are currently ripped (start with "padsp ./jbripper.py ..." if using pulse audio) rawpcm = False # also saves a .pcm file with the raw PCM data as delivered by libspotify () @@ -16,6 +21,7 @@ ripping = False end_of_track = threading.Event() + def printstr(str): # print without newline sys.stdout.write(str) sys.stdout.flush() @@ -24,11 +30,16 @@ def shell(cmdline): # execute shell commands (unicode support) call(cmdline, shell=True) def rip_init(session, track): - global pipe, ripping, pcmfile, rawpcm + global pipe, ripping, pcmfile, rawpcm, directory num_track = "%02d" % (track.index(),) mp3file = track.name()+".mp3" pcmfile = track.name()+".pcm" - directory = os.getcwd() + "/" + track.artists()[0].name() + "/" + track.album().name() + "/" + + if sort: + directory = os.getcwd() + "/" + dldir + track.artists()[0].name() + "/" + track.album().name() + "/" + else: + directory = os.getcwd() + "/" + dldir + if not os.path.exists(directory): os.makedirs(directory) printstr("ripping " + mp3file + " ...") @@ -56,13 +67,13 @@ def rip(session, frames, frame_size, num_frames, sample_type, sample_rate, chann pcmfile.write(frames) def rip_id3(session, track): # write ID3 data + global directory num_track = "%02d" % (track.index(),) mp3file = track.name()+".mp3" artist = track.artists()[0].name() album = track.album().name() title = track.name() year = track.album().year() - directory = os.getcwd() + "/" + track.artists()[0].name() + "/" + track.album().name() + "/" # download cover image = session.image_create(track.album().cover()) @@ -80,7 +91,6 @@ def rip_id3(session, track): # write ID3 data " -A \"" + album + "\"" + \ " -n " + str(num_track) + \ " -Y " + str(year) + \ - " -Q " + \ " \"" + directory + mp3file + "\"" shell(cmd) From 584b7dfcedd8db07f9c5ffc030cb30a24f6eed89 Mon Sep 17 00:00:00 2001 From: ho1ger Date: Tue, 5 May 2015 19:47:29 +0200 Subject: [PATCH 2/2] specify directory where mp3 should be stored; toggle sort by album/artist; fixed eye3d bug --- jbripper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/jbripper.py b/jbripper.py index 9e8269a..d718c08 100755 --- a/jbripper.py +++ b/jbripper.py @@ -12,7 +12,6 @@ dldir = "ripped/" # "": put mp3 directly into spotifyripper directory; "ripped/": put into "ripped" subdir sort = True #True: sort mp3 into artist/album subdir; False: don't sort; put all mp3 into same directory - playback = False # set if you want to listen to the tracks that are currently ripped (start with "padsp ./jbripper.py ..." if using pulse audio) rawpcm = False # also saves a .pcm file with the raw PCM data as delivered by libspotify ()