Fix prompt when using '/' to create sub-directories (#503)

* Fix prompt when using '/' to create sub-directories

* Fix and update CHANGES.md
This commit is contained in:
Ritiek Malhotra
2019-02-27 10:45:05 -08:00
committed by GitHub
parent ac7d42535f
commit 2825f6c593
2 changed files with 16 additions and 12 deletions

View File

@@ -7,12 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased] ## [Unreleased]
### Added ### Added
- - Set custom Spotify Client ID and Client Secret via config.yml ([@ManveerBasra](https://github.com/ManveerBasra)) (#502)
- Use YouTube as fallback metadata if track not found on Spotify. Also added `--no-fallback-metadata`
to preserve old behaviour ([@ritiek](https://github.com/ritiek)) (#457)
### Changed ### Changed
- -
### Fixed ### Fixed
- Fix already downloaded prompt when using "/" in `--file-format` to create sub-directories ([@ritiek](https://github.com/ritiek)) (#503)
- Fix writing playlist tracks to file ([@ritiek](https://github.com/ritiek)) (#506) - Fix writing playlist tracks to file ([@ritiek](https://github.com/ritiek)) (#506)
## [1.1.2] - 2019-02-10 ## [1.1.2] - 2019-02-10
@@ -27,14 +30,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.1.1] - 2019-01-03 ## [1.1.1] - 2019-01-03
### Added ### Added
- Use YouTube as fallback metadata if track not found on Spotify. Also added `--no-fallback-metadata`
to preserve old behaviour ([@ritiek](https://github.com/ritiek)) (#457)
- Output informative message in case of no result found in YouTube search ([@Amit-L](https://github.com/Amit-L)) (#452) - Output informative message in case of no result found in YouTube search ([@Amit-L](https://github.com/Amit-L)) (#452)
- Ability to pass multiple tracks with `-s` option ([@ritiek](https://github.com/ritiek)) (#442) - Ability to pass multiple tracks with `-s` option ([@ritiek](https://github.com/ritiek)) (#442)
### Changed ### Changed
- Allowed to fetch metadata from Spotify upon searching Spotify-URL and `--no-metadata` to gather YouTube - Allowed to fetch metadata from Spotify upon searching Spotify-URL and `--no-metadata` to gather YouTube custom-search fields ([@Amit-L](https://github.com/Amit-L)) (#452)
custom-search fields ([@Amit-L](https://github.com/Amit-L)) (#452)
- Change FFmpeg to use the built-in encoder `aac` instead of 3rd party `libfdk-aac` which does not - Change FFmpeg to use the built-in encoder `aac` instead of 3rd party `libfdk-aac` which does not
ship with the apt package ([@ritiek](https://github.com/ritiek)) (#448) ship with the apt package ([@ritiek](https://github.com/ritiek)) (#448)
- Monkeypatch ever-changing network-relying tests ([@ritiek](https://github.com/ritiek)) (#448) - Monkeypatch ever-changing network-relying tests ([@ritiek](https://github.com/ritiek)) (#448)

View File

@@ -14,16 +14,20 @@ from spotdl import youtube_tools
class CheckExists: class CheckExists:
def __init__(self, music_file, meta_tags=None): def __init__(self, music_file, meta_tags=None):
self.music_file = music_file
self.meta_tags = meta_tags self.meta_tags = meta_tags
basepath, filename = os.path.split(music_file)
filepath = os.path.join(const.args.folder, basepath)
os.makedirs(filepath, exist_ok=True)
self.filepath = filepath
self.filename = filename
def already_exists(self, raw_song): def already_exists(self, raw_song):
""" Check if the input song already exists in the given folder. """ """ Check if the input song already exists in the given folder. """
log.debug( log.debug(
"Cleaning any temp files and checking " "Cleaning any temp files and checking "
'if "{}" already exists'.format(self.music_file) 'if "{}" already exists'.format(self.filename)
) )
songs = os.listdir(const.args.folder) songs = os.listdir(self.filepath)
self._remove_temp_files(songs) self._remove_temp_files(songs)
for song in songs: for song in songs:
@@ -45,17 +49,17 @@ class CheckExists:
def _remove_temp_files(self, songs): def _remove_temp_files(self, songs):
for song in songs: for song in songs:
if song.endswith(".temp"): if song.endswith(".temp"):
os.remove(os.path.join(const.args.folder, song)) os.remove(os.path.join(self.filepath, song))
def _has_metadata(self, song): def _has_metadata(self, song):
# check if the already downloaded song has correct metadata # check if the already downloaded song has correct metadata
# if not, remove it and download again without prompt # if not, remove it and download again without prompt
already_tagged = metadata.compare( already_tagged = metadata.compare(
os.path.join(const.args.folder, song), self.meta_tags os.path.join(self.filepath, song), self.meta_tags
) )
log.debug("Checking if it is already tagged correctly? {}", already_tagged) log.debug("Checking if it is already tagged correctly? {}", already_tagged)
if not already_tagged: if not already_tagged:
os.remove(os.path.join(const.args.folder, song)) os.remove(os.path.join(self.filepath, song))
return False return False
return True return True
@@ -80,7 +84,7 @@ class CheckExists:
return True return True
def _match_filenames(self, song): def _match_filenames(self, song):
if os.path.splitext(song)[0] == self.music_file: if os.path.splitext(song)[0] == self.filename:
log.debug('Found an already existing song: "{}"'.format(song)) log.debug('Found an already existing song: "{}"'.format(song))
return True return True