Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
- Fast `Redis` cache
- A user-friendly interface for selecting the desired artist and then the desired album
- Working on Linux/MacOS
- Suported formats: `.flac`, `.dsf`

## QuickStart
### Installation

```bash
git clone https://github.com/Olezhich/AudioTagLoader.git

Expand All @@ -25,4 +28,23 @@ echo DISCOGS_TOKEN="YOUR_DISCOGS_TOKEN" > .secrets

# run docker redis container
docker-compose -f cache/docker-compose.yml up -d
```

You also may add `autag` script into `$PATH`.

### Uisng

```bash
# First step: go to taget directory where your tracks exists

cd YOUR_DIR

# Second step: load tags into tags.txt file

# Load tags by artist name:
autag fba "The Artist Name" .

# Final step: set tags into tracks

autag set
```
8 changes: 4 additions & 4 deletions audiotagloader/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def _get_albums_by_artist(self, artist: Artist) -> list[Album]:

pattern = re.compile(rf"^({artist.aliases})\*?\s*\S+\s*(.+)$")

target_albums = []
target_albums = set()

for i in range(releases.pages):
for master in releases.page(i):
title_match = pattern.match(master.title)
if title_match:
try:
target_albums.append(
target_albums.add(
Album(
id=master.id,
title=title_match.group(2),
Expand All @@ -58,7 +58,7 @@ def _get_albums_by_artist(self, artist: Artist) -> list[Album]:
except Exception:
pass

return target_albums
return sorted([i for i in target_albums], key=lambda x: x.year)

@cache
def _get_cover_image(self, album_id: int) -> Image:
Expand Down Expand Up @@ -108,7 +108,7 @@ def get_track_tags_by_artist(
albums = self._get_albums_by_artist(current_artist)

for i in range(len(albums)):
print(f"[{i:02d}] {albums[i].year} - {albums[i].title}")
print(f"[{i:02d}] {albums[i].year} - {albums[i].title} {albums[i].id}")

current_album = albums[
max(0, min(len(albums) - 1, int(input("select album: "))))
Expand Down
10 changes: 9 additions & 1 deletion audiotagloader/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def aliases(self) -> str:
return "|".join([re.escape(alias) for alias in lst])


class Album(BaseModel):
class Album(BaseModel, frozen=True):
id: int
title: str = Field(default="")
year: int = Field(default=0)
Expand All @@ -43,6 +43,14 @@ def normlize_list(cls, value: list[str] | None) -> list[str]:
return res
return value

def __hash__(self):
return hash(self.id)

def __eq__(self, other):
if not isinstance(other, Album):
return False
return self.id == other.id


class Image(BaseModel):
url: str = Field(default="")
Expand Down