From 271d8958be1a9f4527e1617b3d8fbfcaaa2bee33 Mon Sep 17 00:00:00 2001 From: regagain Date: Wed, 2 Sep 2015 23:16:54 +0200 Subject: [PATCH 1/4] Added an option to keep old files --- .cmus-syncrc | 2 ++ cmus-sync | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.cmus-syncrc b/.cmus-syncrc index 638031e..29568c2 100644 --- a/.cmus-syncrc +++ b/.cmus-syncrc @@ -6,3 +6,5 @@ playlist = /home/sam/Phone/SD card/Music/playlist music = /home/sam/External/Music playlist = /home/sam/.config/cmus/playlist.pl +[misc] +keep_old_files = off diff --git a/cmus-sync b/cmus-sync index 9ba4e8e..57c6ba1 100755 --- a/cmus-sync +++ b/cmus-sync @@ -8,7 +8,7 @@ import os import configparser from os.path import expanduser -def cmus_sync(source, play_cmus, phone, play_phone): +def cmus_sync(source, play_cmus, phone, play_phone, keep_old_files): a = set() b = set() source_path = [] @@ -33,11 +33,15 @@ def cmus_sync(source, play_cmus, phone, play_phone): path = pair[0] # these items should be added to dest add = a-b - # these items should be removed from dest - remove = b-a + + # remove old files? + if keep_old_files == "off": + # these items should be removed from dest + remove = b-a + + remove_songs(remove,phone,source_path) - remove_songs(remove,phone,source_path) - add_songs(add,phone, source_path) + add_songs(add,phone,source_path) shutil.copy(play_cmus,play_phone) @@ -159,6 +163,7 @@ if __name__=='__main__': play_phone = config["phone"] ["playlist"] source = config["source"] ["music"] play_cmus = config["source"] ["playlist"] + keep_old_files = config["misc"] ["keep_old_files"] # prints the paths from the config file print("\nSource: %s"%(source)) @@ -166,6 +171,6 @@ if __name__=='__main__': print("Source playlist: %s"%(play_cmus)) print("Phone playlist: %s\n"%(play_phone)) - cmus_sync(source, play_cmus, phone, play_phone) + cmus_sync(source, play_cmus, phone, play_phone, keep_old_files) #end time for program print("--- %s seconds ---" % (round((time.time() - start_time),3))) From 5f924cedec5e52e3bca95cc6f11b11d21c1a74bb Mon Sep 17 00:00:00 2001 From: regagain Date: Thu, 3 Sep 2015 19:32:24 +0200 Subject: [PATCH 2/4] keep_old_files is now a boolean --- cmus-sync | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmus-sync b/cmus-sync index 57c6ba1..02531c2 100755 --- a/cmus-sync +++ b/cmus-sync @@ -35,7 +35,7 @@ def cmus_sync(source, play_cmus, phone, play_phone, keep_old_files): add = a-b # remove old files? - if keep_old_files == "off": + if keep_old_files is False: # these items should be removed from dest remove = b-a @@ -163,7 +163,8 @@ if __name__=='__main__': play_phone = config["phone"] ["playlist"] source = config["source"] ["music"] play_cmus = config["source"] ["playlist"] - keep_old_files = config["misc"] ["keep_old_files"] + #keep_old_files = config["misc"] ["keep_old_files"] + keep_old_files = config.getboolean("misc", "keep_old_files") # prints the paths from the config file print("\nSource: %s"%(source)) From d15829a2b915f137712c2583bdbe169a68523f1b Mon Sep 17 00:00:00 2001 From: regagain Date: Thu, 3 Sep 2015 19:34:18 +0200 Subject: [PATCH 3/4] removed old, unused code --- cmus-sync | 1 - 1 file changed, 1 deletion(-) diff --git a/cmus-sync b/cmus-sync index 02531c2..1c1829d 100755 --- a/cmus-sync +++ b/cmus-sync @@ -163,7 +163,6 @@ if __name__=='__main__': play_phone = config["phone"] ["playlist"] source = config["source"] ["music"] play_cmus = config["source"] ["playlist"] - #keep_old_files = config["misc"] ["keep_old_files"] keep_old_files = config.getboolean("misc", "keep_old_files") # prints the paths from the config file From 46a02d48476ec1b8a010924f4cc392eb441e1abc Mon Sep 17 00:00:00 2001 From: regagain Date: Fri, 11 Sep 2015 21:43:01 +0200 Subject: [PATCH 4/4] Update .cmus-syncrc Changed default value --- .cmus-syncrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cmus-syncrc b/.cmus-syncrc index 29568c2..955f9d8 100644 --- a/.cmus-syncrc +++ b/.cmus-syncrc @@ -7,4 +7,4 @@ music = /home/sam/External/Music playlist = /home/sam/.config/cmus/playlist.pl [misc] -keep_old_files = off +keep_old_files = False