Overwrite track file with unique tracks

This commit is contained in:
Ritiek Malhotra
2018-10-02 12:36:55 +05:30
parent 667477a4be
commit e076d11a19
3 changed files with 60 additions and 9 deletions

View File

@@ -65,15 +65,13 @@ def check_exists(music_file, raw_song, meta_tags):
def download_list(text_file):
""" Download all songs from the list. """
with open(text_file, 'r') as listed:
# read tracks into a list and remove any duplicates
lines = listed.read().splitlines()
lines = internals.remove_duplicates(lines)
# ignore blank lines in text_file (if any)
try:
lines.remove('')
except ValueError:
pass
log.info('Checking and removing any duplicate tracks')
lines = internals.get_unique_tracks(text_file)
# override file with unique tracks
with open(text_file, 'w') as listed:
listed.write('\n'.join(lines))
log.info(u'Preparing to download {} songs'.format(len(lines)))
downloaded_songs = []