Skip to content

Commit 7d54051

Browse files
committed
Fix album default lyrics filename
1 parent 0c59e0b commit 7d54051

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

lyricsgenius/types/album.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def save_lyrics(
8888
sanitize: bool = True,
8989
) -> None:
9090
if filename is None:
91-
filename = format_filename(f"saved_album_lyrics_{self.artist}_{self.name}")
91+
filename = format_filename(
92+
f"saved_album_lyrics_{self.artist['name']}_{self.name}"
93+
)
9294

9395
return super().save_lyrics(
9496
filename=filename,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "lyricsgenius"
7-
version = "3.12.0"
7+
version = "3.12.1"
88
dependencies = ["beautifulsoup4>=4.12.3", "requests>=2.27.1"]
99
requires-python = ">=3.11"
1010
authors = [{ name = "John W. R. Miller", email = "john.w.millr+lg@gmail.com" }]

tests/test_album.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,28 @@ def test_saving_txt_file(album_object: Album, tmp_path: Path) -> None:
212212
album_object.tracks[0][1].lyrics = original_lyrics
213213

214214

215+
def test_default_save_lyrics_filename_uses_artist_name(
216+
album_object: Album, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
217+
) -> None:
218+
monkeypatch.chdir(tmp_path)
219+
220+
album_object.save_lyrics(overwrite=True)
221+
222+
expected_filepath = (
223+
tmp_path / "saved_album_lyrics_py_testerson_mocking_the_tests.json"
224+
)
225+
assert expected_filepath.is_file(), (
226+
f"Default file not created at {expected_filepath}"
227+
)
228+
229+
created_files = list(tmp_path.iterdir())
230+
assert len(created_files) == 1
231+
assert created_files[0].name == expected_filepath.name
232+
233+
content = expected_filepath.read_text()
234+
assert f'"artist": "{album_object.artist["name"]}"' in content, content
235+
236+
215237
@pytest.fixture
216238
def genius_client() -> Genius:
217239
return Genius("dummy_access_token", sleep_time=0)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)