Skip to content

Commit

Permalink
Fix singleton regression
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Mar 15, 2021
1 parent ace5892 commit b9721da
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [0.7.1] 2021-03-15

### Fixed

- Fixed singleton regression where track list was getting read incorrectly.


## [0.7.0] 2021-03-15

### Added
Expand Down
30 changes: 17 additions & 13 deletions beetsplug/bandcamp/_metaguru.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def urlify(pretty_string: str) -> str:
else p + "-"
if not p.endswith("-")
else p,
pretty_string.lower(),
pretty_string.lower().replace("'", ""),
"",
).strip("-")

Expand Down Expand Up @@ -167,11 +167,11 @@ def _search(self, pattern: Pattern[str]) -> str:
match = re.search(pattern, self.html)
return match.groups()[0] if match else ""

@cached_property
@property
def album_name(self) -> str:
return self.meta["name"]

@cached_property
@property
def clean_album_name(self) -> str:
args = [self.label, self.catalognum]
if not self._singleton:
Expand All @@ -192,7 +192,7 @@ def image(self) -> str:
image = self.meta.get("image", "")
return image[0] if isinstance(image, list) else image

@cached_property
@property
def label(self) -> str:
return self._search(PATTERNS["label"])

Expand All @@ -209,7 +209,7 @@ def release_date(self) -> date:
datestr = self.parse_release_date(self.html)
return datetime.strptime(datestr, DATE_FORMAT).date()

@cached_property
@property
def disctitle(self) -> str:
if self._media and self.media != "Digital Media":
return self._media.get("name", "")
Expand Down Expand Up @@ -241,7 +241,7 @@ def media(self) -> str:
return MEDIA_MAP[self._media["musicReleaseFormat"]]
return DEFAULT_MEDIA

@cached_property
@property
def mediums(self) -> int:
if self.media != "Vinyl":
return 1
Expand All @@ -261,7 +261,7 @@ def description(self) -> str:
descr = ""
return descr

@cached_property
@property
def tracks(self) -> List[JSONDict]:
"""`raw_track` example
"@type": "ListItem",
Expand Down Expand Up @@ -369,28 +369,32 @@ def _common_album(self) -> JSONDict:
)

def _trackinfo(self, track: JSONDict, medium_total: int, **kwargs) -> TrackInfo:
index = kwargs.pop("index", None) or track.get("position")
return TrackInfo(
**self._common,
title=track.get("title"),
track_id=track.get("url"),
track_id=kwargs.pop("track_id", None) or track.get("url"),
artist=track.get("artist") or self.albumartist,
index=track.get("position"),
index=index,
length=self.get_duration(track),
track_alt=track.get("track_alt"),
disctitle=self.disctitle or None,
medium=self.medium,
medium_index=track.get("position"),
medium_index=index,
medium_total=medium_total,
**self._common,
**kwargs,
)

@property
def singleton(self) -> TrackInfo:
self._singleton = True
kwargs: JSONDict = {}
track = self.meta
track.update(self.parse_track_name(self.album_name))
kwargs = dict(track_id=self.album_id, index=1)
if NEW_BEETS:
kwargs.update(**self._common_album, albumartist=self.bandcamp_albumartist)
return self._trackinfo(self.tracks.pop(), 1, **kwargs)

return self._trackinfo(track, 1, **kwargs)

def albuminfo(self, include_all: bool) -> AlbumInfo:
if self.media == "Digital Media" or include_all:
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 = "beetcamp"
version = "0.7.0"
version = "0.7.1"
description = "Bandcamp autotagger source for beets (http://beets.io)."
authors = ["Šarūnas Nejus <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit b9721da

Please sign in to comment.