mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2026-02-11 11:59:23 +00:00
Use Black to format code
This commit is contained in:
@@ -28,8 +28,7 @@ class CheckExists:
|
||||
for song in songs:
|
||||
# check if a song with the same name is already present in the given folder
|
||||
if self._match_filenames(song):
|
||||
if internals.is_spotify(raw_song) and \
|
||||
not self._has_metadata(song):
|
||||
if internals.is_spotify(raw_song) and not self._has_metadata(song):
|
||||
return False
|
||||
|
||||
log.warning('"{}" already exists'.format(song))
|
||||
@@ -53,9 +52,7 @@ class CheckExists:
|
||||
already_tagged = metadata.compare(
|
||||
os.path.join(const.args.folder, 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:
|
||||
os.remove(os.path.join(const.args.folder, song))
|
||||
return False
|
||||
@@ -64,8 +61,7 @@ class CheckExists:
|
||||
|
||||
def _prompt_song(self, song):
|
||||
log.info(
|
||||
'"{}" has already been downloaded. '
|
||||
"Re-download? (y/N): ".format(song)
|
||||
'"{}" has already been downloaded. ' "Re-download? (y/N): ".format(song)
|
||||
)
|
||||
prompt = input("> ")
|
||||
if prompt.lower() == "y":
|
||||
|
||||
@@ -99,10 +99,7 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
|
||||
group.add_argument(
|
||||
"-s",
|
||||
"--song",
|
||||
nargs='+',
|
||||
help="download track by spotify link or name"
|
||||
"-s", "--song", nargs="+", help="download track by spotify link or name"
|
||||
)
|
||||
group.add_argument("-l", "--list", help="download tracks from a file")
|
||||
group.add_argument(
|
||||
@@ -116,7 +113,7 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
|
||||
group.add_argument(
|
||||
"-ab",
|
||||
"--all-albums",
|
||||
help="load all tracks from artist URL into <artist_name>.txt"
|
||||
help="load all tracks from artist URL into <artist_name>.txt",
|
||||
)
|
||||
group.add_argument(
|
||||
"-u",
|
||||
@@ -128,10 +125,10 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--write-m3u',
|
||||
"--write-m3u",
|
||||
help="generate an .m3u playlist file with youtube links given "
|
||||
"a text file containing tracks",
|
||||
action='store_true'
|
||||
"a text file containing tracks",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-m",
|
||||
@@ -266,12 +263,19 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
|
||||
if parsed.config is not None and to_merge:
|
||||
parsed = override_config(parsed.config, parser)
|
||||
|
||||
if to_group and parsed.list and \
|
||||
not mimetypes.MimeTypes().guess_type(parsed.list)[0] == "text/plain":
|
||||
parser.error("{0} is not of a valid argument to --list, argument must be plain text file".format(parsed.list))
|
||||
if (
|
||||
to_group
|
||||
and parsed.list
|
||||
and not mimetypes.MimeTypes().guess_type(parsed.list)[0] == "text/plain"
|
||||
):
|
||||
parser.error(
|
||||
"{0} is not of a valid argument to --list, argument must be plain text file".format(
|
||||
parsed.list
|
||||
)
|
||||
)
|
||||
|
||||
if parsed.write_m3u and not parsed.list:
|
||||
parser.error('--write-m3u can only be used with --list')
|
||||
parser.error("--write-m3u can only be used with --list")
|
||||
|
||||
parsed.log_level = log_leveller(parsed.log_level)
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ def refresh_token():
|
||||
new_token = generate_token()
|
||||
spotify = spotipy.Spotify(auth=new_token)
|
||||
|
||||
|
||||
# token is mandatory when using Spotify's API
|
||||
# https://developer.spotify.com/news-stories/2017/01/27/removing-unauthenticated-calls-to-the-web-api/
|
||||
_token = generate_token()
|
||||
|
||||
@@ -53,7 +53,7 @@ def match_video_and_metadata(track, force_pafy=True):
|
||||
# Let it generate metadata, youtube doesn't know spotify slang
|
||||
if not const.args.no_metadata or internals.is_spotify(track):
|
||||
meta_tags = spotify_tools.generate_metadata(track)
|
||||
|
||||
|
||||
if force_pafy:
|
||||
content = go_pafy(track, meta_tags)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user