22 Commits

Author SHA1 Message Date
Ritiek Malhotra
ddb4b01897 Merge pull request #494 from ritiek/release-v1.1.2
Release changes for v1.1.2
2019-02-10 20:52:42 +05:30
Ritiek Malhotra
1d401d26c1 Bump to v1.1.2 2019-02-10 20:30:39 +05:30
Ritiek Malhotra
cfa9f78ce4 Mark section for v1.1.2 2019-02-10 20:28:52 +05:30
Ritiek Malhotra
01c6c11a1d Black format code 2019-02-10 20:26:22 +05:30
Ritiek Malhotra
eb1be87039 Merge pull request #493 from ritiek/fetch-all-album-types
Fetch all album types for an artist by default
2019-02-08 18:03:37 +05:30
Ritiek Malhotra
925521aa3b Fix tests for now 2019-02-04 20:18:01 +05:30
Ritiek Malhotra
1d2b43a5f9 Update CHANGES.md 2019-02-04 15:27:04 +05:30
Ritiek Malhotra
542201091d Fetch all artist albums by default 2019-02-04 15:24:37 +05:30
Ritiek Malhotra
a182fe5eb3 Use argparse special features to handle displaying version info (#486)
* Use argparse special features to handle displaying version info

* Remove version argument check from spotdl.py
2019-01-21 05:56:21 -08:00
Ritiek Malhotra
3dac0125a9 Merge pull request #477 from ritiek/missing-changelogs
Changelog entries for missed PRs
2019-01-14 21:24:16 -08:00
Ritiek Malhotra
fbf930fe43 Changelog entries for missed PRs 2019-01-15 10:53:07 +05:30
Ritiek Malhotra
b72eb773f3 Merge pull request #475 from ritiek/fix-m4a-when-encoder-not-found
Fix renaming files when encoder is not found
2019-01-14 19:55:24 -08:00
Ritiek Malhotra
8944dec8e0 Merge branch 'master' into fix-m4a-when-encoder-not-found 2019-01-14 19:48:33 -08:00
Ritiek Malhotra
76906cfdbc Merge pull request #476 from Silverfeelin/master
Use folder argument as base for album/playlist file exports.
2019-01-13 11:38:24 -08:00
Silverfeelin
a18f888e97 Update CHANGES.md 2019-01-13 20:25:05 +01:00
Silverfeelin
6c07267312 Use folder argument as base for album/playlist file exports. 2019-01-13 17:12:05 +01:00
Ritiek Malhotra
f078875f0e Update CHANGES.md 2019-01-13 18:32:48 +05:30
Ritiek Malhotra
31cd1c5856 Move 'encoder not found' warning to more appropriate place 2019-01-13 18:19:38 +05:30
Ritiek Malhotra
54d3336aa2 Fix renaming files when encoder is not present 2019-01-13 18:19:06 +05:30
Ritiek Malhotra
94500e31a3 Merge pull request #469 from tillhainbach/master
Use first artist from album object for album artist
2019-01-08 20:06:00 -08:00
tillhainbach
bf6e6fb0c5 first artist from album object for album artist 2019-01-08 22:53:22 +01:00
ifduyue
67ae7d5c4c Add missing import time (#465)
This fixes #464
2019-01-04 09:56:21 +00:00
9 changed files with 56 additions and 30 deletions

View File

@@ -4,7 +4,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
-
### Changed
-
### Fixed
-
## [1.1.2] - 2019-02-10
### Changed
- Fetch all artist albums by default instead of only fetching the "album" type ([@ritiek](https://github.com/ritiek)) (#493)
- Option `-f` (`--folder`) is used when exporting text files using `-p` (`--playlist`) for playlists or `-b` (`--album`) for albums ([@Silverfeelin](https://github.com/Silverfeelin)) (#476)
- Use first artist from album object for album artist ([@tillhainbach](https://github.com/tillhainbach))
### Fixed
- Fix renaming files when encoder is not found ([@ritiek](https://github.com/ritiek)) (#475)
- Add missing `import time` ([@ifduyue](https://github.com/ifduyue)) (#465)
## [1.1.1] - 2019-01-03
### Added

View File

@@ -1 +1 @@
__version__ = "1.1.1"
__version__ = "1.1.2"

View File

@@ -83,7 +83,12 @@ class Converter:
os.rename(self.output_file, self.input_file)
log.debug(command)
code = subprocess.call(command)
try:
code = subprocess.call(command)
except FileNotFoundError:
if self.rename_to_temp:
os.rename(self.input_file, self.output_file)
raise
if self.delete_original:
log.debug('Removing original file: "{}"'.format(self.input_file))
@@ -134,7 +139,12 @@ class Converter:
os.rename(self.output_file, self.input_file)
log.debug(command)
code = subprocess.call(command)
try:
code = subprocess.call(command)
except FileNotFoundError:
if self.rename_to_temp:
os.rename(self.input_file, self.output_file)
raise
if self.delete_original:
log.debug('Removing original file: "{}"'.format(self.input_file))

View File

@@ -1,6 +1,7 @@
import spotipy
import urllib
import os
import time
from logzero import logger as log
from spotdl import const
@@ -130,6 +131,8 @@ class Downloader:
trim_silence=const.args.trim_silence,
)
except FileNotFoundError:
encoder = "avconv" if const.args.avconv else "ffmpeg"
log.warning("Could not find {0}, skip encoding".format(encoder))
output_song = self.unconverted_filename(songname)
if not const.args.no_metadata and self.meta_tags is not None:
@@ -168,8 +171,6 @@ class Downloader:
@staticmethod
def unconverted_filename(songname):
encoder = "avconv" if const.args.avconv else "ffmpeg"
log.warning("Could not find {0}, skipping conversion".format(encoder))
const.args.output_ext = const.args.input_ext
output_song = songname + const.args.output_ext
return output_song

View File

@@ -7,6 +7,7 @@ import argparse
import mimetypes
import os
import spotdl
from spotdl import internals
@@ -120,9 +121,6 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
"--username",
help="load tracks from user's playlist into <playlist_name>.txt",
)
group.add_argument(
"-V", "--version", help="show version and exit", action="store_true"
)
parser.add_argument(
"--write-m3u",
@@ -257,6 +255,12 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
parser.add_argument(
"-c", "--config", default=None, help="path to custom config.yml file"
)
parser.add_argument(
"-V",
"--version",
action="version",
version="%(prog)s {}".format(spotdl.__version__),
)
parsed = parser.parse_args(raw_args)

View File

@@ -146,7 +146,7 @@ class EmbedMetadata:
def _embed_basic_metadata(self, audiofile, preset=TAG_PRESET):
meta_tags = self.meta_tags
audiofile[preset["artist"]] = meta_tags["artists"][0]["name"]
audiofile[preset["albumartist"]] = meta_tags["artists"][0]["name"]
audiofile[preset["albumartist"]] = meta_tags["album"]["artists"][0]["name"]
audiofile[preset["album"]] = meta_tags["album"]["name"]
audiofile[preset["title"]] = meta_tags["name"]
audiofile[preset["date"]] = meta_tags["release_date"]

View File

@@ -49,10 +49,6 @@ def match_args():
def main():
const.args = handle.get_arguments()
if const.args.version:
print("spotdl {version}".format(version=__version__))
sys.exit()
internals.filter_path(const.args.folder)
youtube_tools.set_api_key()

View File

@@ -7,7 +7,9 @@ from titlecase import titlecase
from logzero import logger as log
import pprint
import sys
import os
from spotdl import const
from spotdl import internals
@@ -146,7 +148,8 @@ def write_playlist(playlist_url, text_file=None):
tracks = playlist["tracks"]
if not text_file:
text_file = u"{0}.txt".format(slugify(playlist["name"], ok="-_()[]{}"))
return write_tracks(tracks, text_file)
filepath = os.path.join(const.args.folder if const.args.folder else "", text_file)
return write_tracks(tracks, filepath)
def fetch_album(album):
@@ -155,13 +158,13 @@ def fetch_album(album):
return album
def fetch_albums_from_artist(artist_url, album_type="album"):
def fetch_albums_from_artist(artist_url, album_type=None):
"""
This funcction returns all the albums from a give artist_url using the US
market
:param artist_url - spotify artist url
:param album_type - the type of album to fetch (ex: single) the default is
a standard album
all albums
:param return - the album from the artist
"""
@@ -192,7 +195,7 @@ def write_all_albums_from_artist(artist_url, text_file=None):
album_base_url = "https://open.spotify.com/album/"
# fetching all default albums
albums = fetch_albums_from_artist(artist_url)
albums = fetch_albums_from_artist(artist_url, album_type=None)
# if no file if given, the default save file is in the current working
# directory with the name of the artist
@@ -204,20 +207,14 @@ def write_all_albums_from_artist(artist_url, text_file=None):
log.info("Fetching album: " + album["name"])
write_album(album_base_url + album["id"], text_file=text_file)
# fetching all single albums
singles = fetch_albums_from_artist(artist_url, album_type="single")
for single in singles:
log.info("Fetching single: " + single["name"])
write_album(album_base_url + single["id"], text_file=text_file)
def write_album(album_url, text_file=None):
album = fetch_album(album_url)
tracks = spotify.album_tracks(album["id"])
if not text_file:
text_file = u"{0}.txt".format(slugify(album["name"], ok="-_()[]{}"))
return write_tracks(tracks, text_file)
filepath = os.path.join(const.args.folder if const.args.folder else "", text_file)
return write_tracks(tracks, filepath)
def write_tracks(tracks, text_file):

View File

@@ -113,7 +113,8 @@ class TestFetchAlbumsFromArtist:
return albums
def test_len(self, albums_from_artist_fixture):
assert len(albums_from_artist_fixture) == 18
# TODO: Mock this test (failed in #493)
assert len(albums_from_artist_fixture) == 52
def test_zeroth_album_name(self, albums_from_artist_fixture):
assert albums_from_artist_fixture[0]["name"] == "Revolution Radio"
@@ -128,11 +129,9 @@ class TestFetchAlbumsFromArtist:
assert albums_from_artist_fixture[0]["total_tracks"] == 12
# XXX: Mock this test off if it fails in future
# TODO: Mock this test (failed in #493)
def test_write_all_albums_from_artist(tmpdir):
# current number of tracks on spotify since as of 10/10/2018
# in US market only
expect_tracks = 49
expect_tracks = 282
text_file = os.path.join(str(tmpdir), "test_ab.txt")
spotify_tools.write_all_albums_from_artist(
"https://open.spotify.com/artist/4dpARuHxo51G3z768sgnrY", text_file