Skip to content

Commit

Permalink
v4.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat authored May 25, 2023
2 parents 5edc15e + 1217595 commit 1924fbe
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Refer to our [Installation Guide](https://spotdl.rtfd.io/en/latest/installation/

### Python (Recommended Method)
- _spotDL_ can be installed by running `pip install spotdl`.
- To update spotDL run `pip install --upgrade spotdl`

> On some systems you might have to change `pip` to `pip3`.
<details>
Expand Down Expand Up @@ -115,7 +117,7 @@ For a list of all **options** use ```spotdl -h```

- `url`: Get direct download link for each song from the query.
- Usage:
`spotdl web [query]`
`spotdl url [query]`

- `sync`: Updates directories. Compares the directory with the current state of the playlist. Newly added songs will be downloaded and removed songs will be deleted. No other songs will be downloaded and no other files will be deleted.

Expand Down
6 changes: 4 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Refer to our [Installation Guide](https://spotdl.rtfd.io/en/latest/installation/

### Python (Recommended Method)
- _spotDL_ can be installed by running `pip install spotdl`.
- To update spotDL run `pip install --upgrade spotdl`
> On some systems you might have to change `pip` to `pip3`.

Expand Down Expand Up @@ -94,6 +95,7 @@ General usage:
```sh
spotdl [operation] [options] QUERY
```
When downloading songs, the song's Spotify Popularity variable [(described here)](https://developer.spotify.com/documentation/web-api/reference/get-track) is stored in metadata as a comment, so you can sort your downloaded songs by popularity.
There are different **operations** spotDL can perform. The *default* is `download`, which simply downloads the songs from YouTube and embeds metadata.
Expand Down Expand Up @@ -135,11 +137,11 @@ spotDL uses YouTube as a source for music downloads. This method is used to avoi
spotDL downloads music from YouTube and is designed to always download the highest possible bitrate; which is 128 kbps for regular users and 256 kbps for YouTube Music premium users.
Check the [Audio Formats](docs/USAGE.md#audio-formats-and-quality) page for more info.
Check the [Audio Formats](USAGE#audio-formats-and-quality) page for more info.
## Contributing
Interested in contributing? Check out our [CONTRIBUTING.md](docs/CONTRIBUTING.md) to find
Interested in contributing? Check out our [CONTRIBUTING.md](CONTRIBUTING) to find
resources around contributing along with a guide on how to set up a development environment.
## Donate
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spotdl"
version = "4.1.10"
version = "4.1.11"
description = "Download your Spotify playlists and songs along with album art and metadata"
license = "MIT"
authors = ["spotDL Team <spotdladmins@googlegroups.com>"]
Expand Down
2 changes: 1 addition & 1 deletion spotdl/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Version module for spotdl.
"""

__version__ = "4.1.10"
__version__ = "4.1.11"
2 changes: 1 addition & 1 deletion spotdl/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def search_and_download(self, song: Song) -> Tuple[Song, Optional[Path]]:
self.settings["bitrate"] in ["auto", "disable", None]
and temp_file.suffix == output_file.suffix
):
shutil.move(temp_file, output_file)
shutil.move(str(temp_file), output_file)
success = True
result = None
else:
Expand Down
2 changes: 2 additions & 0 deletions spotdl/types/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Song:
copyright_text: Optional[str]
download_url: Optional[str] = None
lyrics: Optional[str] = None
popularity: Optional[int] = None
album_id: Optional[str] = None
list_name: Optional[str] = None
list_url: Optional[str] = None
Expand Down Expand Up @@ -118,6 +119,7 @@ def from_url(cls, url: str) -> "Song":
explicit=raw_track_meta["explicit"],
publisher=raw_album_meta["label"],
url=raw_track_meta["external_urls"]["spotify"],
popularity=raw_track_meta["popularity"],
cover_url=max(
raw_album_meta["images"], key=lambda i: i["width"] * i["height"]
)["url"]
Expand Down
7 changes: 6 additions & 1 deletion spotdl/utils/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,12 @@ def create_file_name(
long_title = len(song.name) > (length_limit * 0.50)

path_separator = "/" if "/" in template else "\\"
name_template = template.rsplit(path_separator, 1)[1]
name_template_parts = template.rsplit(path_separator, 1)
name_template = (
name_template_parts[1]
if len(name_template_parts) == 1
else name_template_parts[0]
)

if long_artist:
logger.warning(
Expand Down
14 changes: 9 additions & 5 deletions spotdl/utils/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class MetadataError(Exception):
"date": "\xa9day",
"title": "\xa9nam",
"year": "\xa9day",
"originaldate": "purd",
"comment": "\xa9cmt",
"group": "\xa9grp",
"writer": "\xa9wrt",
Expand All @@ -80,7 +79,6 @@ class MetadataError(Exception):
"date": "TDRC",
"title": "TIT2",
"year": "TDRC",
"originaldate": "TDOR",
"comment": "COMM::XXX",
"group": "TIT1",
"writer": "TEXT",
Expand Down Expand Up @@ -163,7 +161,6 @@ def embed_metadata(output_file: Path, song: Song, id3_separator: str = "/"):
)
audio_file[tag_preset["title"]] = song.name
audio_file[tag_preset["date"]] = song.date
audio_file[tag_preset["originaldate"]] = song.date
audio_file[tag_preset["encodedby"]] = song.publisher

# Embed metadata that isn't always present
Expand Down Expand Up @@ -212,6 +209,15 @@ def embed_metadata(output_file: Path, song: Song, id3_separator: str = "/"):
if song.download_url:
audio_file.add(COMM(encoding=3, text=song.download_url))

if song.popularity:
audio_file.add(
COMM(
encoding=3,
lang="eng",
text="Spotify Popularity: " + str(song.popularity),
)
)

# Embed album art
audio_file = embed_cover(audio_file, song, encoding)

Expand Down Expand Up @@ -469,8 +475,6 @@ def get_file_metadata(path: Path, id3_separator: str = "/") -> Optional[Dict[str
else:
if key == "artist":
song_meta["artists"] = val
if key == "originaldate":
song_meta["year"] = int(str(val[0])[:4])
elif key == "tracknumber":
song_meta["track_number"] = int(val[0])
elif key == "discnumber":
Expand Down
2 changes: 1 addition & 1 deletion spotdl/utils/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import concurrent.futures
import json
import re
import logging
import re
from pathlib import Path
from typing import Dict, List, Optional

Expand Down
18 changes: 13 additions & 5 deletions tests/types/test_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_song_init():
disc_count=1,
publisher="test",
url="test",
popularity=1,
)

assert song.name == "test"
Expand All @@ -51,6 +52,7 @@ def test_song_init():
assert song.cover_url == "test"
assert song.explicit is True
assert song.download_url == "test"
assert song.popularity == 1


def test_song_wrong_init():
Expand Down Expand Up @@ -99,6 +101,7 @@ def test_song_from_url():
)
assert song.explicit == False
assert song.download_url == None
assert song.popularity == 0


@pytest.mark.vcr()
Expand All @@ -122,8 +125,9 @@ def test_song_from_search_term():
assert song.tracks_count == 1
assert song.isrc == "GB2LD2110301"
assert song.song_id == "4SN9kQlguIcjPtMNQJwD30"
assert song.explicit == False
assert song.download_url == None
assert song.explicit is False
assert song.download_url is None
assert song.popularity is not None and song.popularity >= 0


def test_song_from_data_dump():
Expand Down Expand Up @@ -156,7 +160,8 @@ def test_song_from_data_dump():
"disc_count": 1,
"copyright_text": "",
"publisher": "",
"url": "https://open.spotify.com/track/1t2qKa8K72IBC8yQlhD9bU"
"url": "https://open.spotify.com/track/1t2qKa8K72IBC8yQlhD9bU",
"popularity": 0
}
"""
)
Expand All @@ -178,8 +183,9 @@ def test_song_from_data_dump():
song.cover_url
== "https://i.scdn.co/image/ab67616d0000b273fe2cb38e4d2412dbb0e54332"
)
assert song.explicit == False
assert song.download_url == None
assert song.explicit is False
assert song.download_url is None
assert song.popularity == 0


def test_song_from_data_dump_wrong_type():
Expand Down Expand Up @@ -220,6 +226,7 @@ def test_song_from_dict():
"copyright_text": "",
"publisher": "",
"url": "https://open.spotify.com/track/1t2qKa8K72IBC8yQlhD9bU",
"popularity": 0,
}
)

Expand All @@ -241,3 +248,4 @@ def test_song_from_dict():
== "https://i.scdn.co/image/ab67616d0000b273fe2cb38e4d2412dbb0e54332"
)
assert song.explicit == False
assert song.popularity == 0
1 change: 1 addition & 0 deletions tests/utils/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_embed_metadata(tmpdir, monkeypatch, output_format):
"copyright_text": "",
"publisher": "",
"url": "https://open.spotify.com/track/1t2qKa8K72IBC8yQlhD9bU",
"popularity": 0,
}

song = Song.from_dict(song_obj)
Expand Down

0 comments on commit 1924fbe

Please sign in to comment.