mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-15 07:34:48 -04:00
Fix #62
This commit is contained in:
parent
905a65d10d
commit
c5d139d4bd
1 changed files with 14 additions and 13 deletions
|
@ -7,7 +7,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
from typing import Generator, Iterable, Union
|
from typing import Dict, Generator, Iterable, Union
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from pathvalidate import sanitize_filename
|
from pathvalidate import sanitize_filename
|
||||||
|
@ -28,11 +28,6 @@ from .utils import (
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
TYPE_REGEXES = {
|
|
||||||
"remaster": re.compile(r"(?i)(re)?master(ed)?"),
|
|
||||||
"extra": re.compile(r"(?i)(anniversary|deluxe|live|collector|demo|expanded|remix)"),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Album(Tracklist):
|
class Album(Tracklist):
|
||||||
"""Represents a downloadable album.
|
"""Represents a downloadable album.
|
||||||
|
@ -649,6 +644,13 @@ class Artist(Tracklist):
|
||||||
|
|
||||||
# ----------- Filters --------------
|
# ----------- Filters --------------
|
||||||
|
|
||||||
|
TYPE_REGEXES = {
|
||||||
|
"remaster": re.compile(r"(?i)(re)?master(ed)?"),
|
||||||
|
"extra": re.compile(
|
||||||
|
r"(?i)(anniversary|deluxe|live|collector|demo|expanded|remix)"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
def _remove_repeats(self, bit_depth=max, sampling_rate=max) -> Generator:
|
def _remove_repeats(self, bit_depth=max, sampling_rate=max) -> Generator:
|
||||||
"""Remove the repeated albums from self. May remove different
|
"""Remove the repeated albums from self. May remove different
|
||||||
versions of the same album.
|
versions of the same album.
|
||||||
|
@ -656,7 +658,7 @@ class Artist(Tracklist):
|
||||||
:param bit_depth: either max or min functions
|
:param bit_depth: either max or min functions
|
||||||
:param sampling_rate: either max or min functions
|
:param sampling_rate: either max or min functions
|
||||||
"""
|
"""
|
||||||
groups = dict()
|
groups: Dict[str, list] = {}
|
||||||
for album in self:
|
for album in self:
|
||||||
if (t := self.essence(album.title)) not in groups:
|
if (t := self.essence(album.title)) not in groups:
|
||||||
groups[t] = []
|
groups[t] = []
|
||||||
|
@ -683,7 +685,7 @@ class Artist(Tracklist):
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
album["albumartist"] != "Various Artists"
|
album["albumartist"] != "Various Artists"
|
||||||
and TYPE_REGEXES["extra"].search(album.title) is None
|
and self.TYPE_REGEXES["extra"].search(album.title) is None
|
||||||
)
|
)
|
||||||
|
|
||||||
def _features(self, album: Album) -> bool:
|
def _features(self, album: Album) -> bool:
|
||||||
|
@ -709,7 +711,7 @@ class Artist(Tracklist):
|
||||||
:type album: Album
|
:type album: Album
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
return TYPE_REGEXES["extra"].search(album.title) is None
|
return self.TYPE_REGEXES["extra"].search(album.title) is None
|
||||||
|
|
||||||
def _non_remasters(self, album: Album) -> bool:
|
def _non_remasters(self, album: Album) -> bool:
|
||||||
"""Passed as a parameter by the user.
|
"""Passed as a parameter by the user.
|
||||||
|
@ -721,7 +723,7 @@ class Artist(Tracklist):
|
||||||
:type album: Album
|
:type album: Album
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
return TYPE_REGEXES["remaster"].search(album.title) is not None
|
return self.TYPE_REGEXES["remaster"].search(album.title) is not None
|
||||||
|
|
||||||
def _non_albums(self, album: Album) -> bool:
|
def _non_albums(self, album: Album) -> bool:
|
||||||
"""This will ignore non-album releases.
|
"""This will ignore non-album releases.
|
||||||
|
@ -731,8 +733,7 @@ class Artist(Tracklist):
|
||||||
:type album: Album
|
:type album: Album
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
# Doesn't work yet
|
return len(album) > 1
|
||||||
return album["release_type"] == "album"
|
|
||||||
|
|
||||||
# --------- Magic Methods --------
|
# --------- Magic Methods --------
|
||||||
|
|
||||||
|
@ -751,7 +752,7 @@ class Artist(Tracklist):
|
||||||
"""
|
"""
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self):
|
||||||
return hash(self.id)
|
return hash(self.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue