aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2023-02-21 22:33:38 -0500
committerAnthony Wang2023-02-21 22:33:38 -0500
commit50bc34effbebee371f442f3cbc5ac2855bcda2ab (patch)
tree3cd589f7325fb160eb7cba3744c54b2e62edf9f7
parent072de7c41b1bdfcc56cfa1934234bbc795324da9 (diff)
Delete entries not on playlistHEADmaster
-rw-r--r--sync.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/sync.py b/sync.py
index ba9a22b..4272340 100644
--- a/sync.py
+++ b/sync.py
@@ -5,15 +5,22 @@ import sys
playlist = sys.argv[1]
playlistpath = playlist[:playlist.rfind('/')]
+synced = set()
for i in open(playlist).read().split('\n'):
target = i[i.rfind('/') + 1:i.rfind('.')] + '.mp3'
+ synced.add(target)
if i == '' or os.path.exists(target):
continue
- print(i)
+ print('Syncing', i)
if i.endswith('.mp3'):
- print('mp3')
- shutil.copy(i, target)
+ print('Copying mp3')
+ shutil.copy(playlistpath + '/' + i, target)
else:
- print('transcoding')
+ print('Transcoding')
os.system(f'ffmpeg -i "{playlistpath}/{i}" "{target}"')
+
+for i in os.listdir():
+ if i.endswith('.mp3') and i not in synced:
+ print('Removing', i)
+ os.remove(i)