Delete entries not on playlist
This commit is contained in:
parent
072de7c41b
commit
50bc34effb
15
sync.py
15
sync.py
|
@ -5,15 +5,22 @@ import sys
|
||||||
playlist = sys.argv[1]
|
playlist = sys.argv[1]
|
||||||
playlistpath = playlist[:playlist.rfind('/')]
|
playlistpath = playlist[:playlist.rfind('/')]
|
||||||
|
|
||||||
|
synced = set()
|
||||||
for i in open(playlist).read().split('\n'):
|
for i in open(playlist).read().split('\n'):
|
||||||
target = i[i.rfind('/') + 1:i.rfind('.')] + '.mp3'
|
target = i[i.rfind('/') + 1:i.rfind('.')] + '.mp3'
|
||||||
|
synced.add(target)
|
||||||
if i == '' or os.path.exists(target):
|
if i == '' or os.path.exists(target):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(i)
|
print('Syncing', i)
|
||||||
if i.endswith('.mp3'):
|
if i.endswith('.mp3'):
|
||||||
print('mp3')
|
print('Copying mp3')
|
||||||
shutil.copy(i, target)
|
shutil.copy(playlistpath + '/' + i, target)
|
||||||
else:
|
else:
|
||||||
print('transcoding')
|
print('Transcoding')
|
||||||
os.system(f'ffmpeg -i "{playlistpath}/{i}" "{target}"')
|
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)
|
||||||
|
|
Loading…
Reference in a new issue