Add all filters to config; Sort imports
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import datetime
|
||||
import hashlib
|
||||
import logging
|
||||
import datetime
|
||||
import time
|
||||
import os
|
||||
import time
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Generator, Sequence, Tuple, Union
|
||||
|
||||
import requests
|
||||
import tidalapi
|
||||
from dogpile.cache import make_region
|
||||
|
||||
from .constants import AGENT, QOBUZ_FEATURED_KEYS, CACHE_DIR
|
||||
from .constants import AGENT, CACHE_DIR, QOBUZ_FEATURED_KEYS
|
||||
from .exceptions import (
|
||||
AuthenticationError,
|
||||
IneligibleError,
|
||||
@@ -18,7 +19,6 @@ from .exceptions import (
|
||||
InvalidQuality,
|
||||
)
|
||||
from .spoofbuz import Spoofer
|
||||
from dogpile.cache import make_region
|
||||
|
||||
os.makedirs(CACHE_DIR, exist_ok=True)
|
||||
region = make_region().configure(
|
||||
|
||||
@@ -49,7 +49,13 @@ class Config:
|
||||
self.tidal = {"enabled": True, "email": None, "password": None}
|
||||
self.deezer = {"enabled": True}
|
||||
self.downloads_database = None
|
||||
self.filters = {"no_extras": False, "albums_only": False}
|
||||
self.filters = {
|
||||
"no_extras": False,
|
||||
"albums_only": False,
|
||||
"no_features": False,
|
||||
"studio_albums": False,
|
||||
"remaster_only": False,
|
||||
}
|
||||
self.downloads = {"folder": folder, "quality": quality}
|
||||
self.metadata = {
|
||||
"embed_cover": False,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
# ------- Testing ----------
|
||||
from typing import Generator, Optional, Sequence, Tuple, Union
|
||||
|
||||
import click
|
||||
@@ -14,8 +12,6 @@ from .db import QobuzDB
|
||||
from .downloader import Album, Artist, Playlist, Track
|
||||
from .exceptions import InvalidSourceError, ParsingError
|
||||
|
||||
# --------------------------
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -83,11 +79,10 @@ class QobuzDL:
|
||||
|
||||
item = MEDIA_CLASS[media_type](client=self.client, id=item_id)
|
||||
if isinstance(item, Artist):
|
||||
filters_ = tuple(self.config.filters.keys())
|
||||
keys = self.config.filters.keys()
|
||||
filters_ = tuple(key for key in keys if self.config.filters[key])
|
||||
arguments["filters"] = filters_
|
||||
logger.debug(
|
||||
"Added filter argument for artist/label: %s", filters_
|
||||
)
|
||||
logger.debug("Added filter argument for artist/label: %s", filters_)
|
||||
|
||||
logger.debug("Arguments from config: %s", arguments)
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
from abc import ABC, abstractmethod
|
||||
from pprint import pprint, pformat
|
||||
from pprint import pformat, pprint
|
||||
from tempfile import gettempdir
|
||||
from typing import Any, Callable, Optional, Union, Sequence, Tuple
|
||||
from typing import Any, Callable, Optional, Sequence, Tuple, Union
|
||||
|
||||
import click
|
||||
import requests
|
||||
@@ -15,7 +15,13 @@ from pathvalidate import sanitize_filename, sanitize_filepath
|
||||
|
||||
from . import converter
|
||||
from .clients import ClientInterface
|
||||
from .constants import EXT, FLAC_MAX_BLOCKSIZE, TRACK_FORMAT, FOLDER_FORMAT, ALBUM_KEYS
|
||||
from .constants import (
|
||||
ALBUM_KEYS,
|
||||
EXT,
|
||||
FLAC_MAX_BLOCKSIZE,
|
||||
FOLDER_FORMAT,
|
||||
TRACK_FORMAT,
|
||||
)
|
||||
from .exceptions import (
|
||||
InvalidQuality,
|
||||
InvalidSourceError,
|
||||
@@ -23,7 +29,13 @@ from .exceptions import (
|
||||
TooLargeCoverArt,
|
||||
)
|
||||
from .metadata import TrackMetadata
|
||||
from .util import quality_id, safe_get, tidal_cover_url, tqdm_download, clean_format
|
||||
from .util import (
|
||||
clean_format,
|
||||
quality_id,
|
||||
safe_get,
|
||||
tidal_cover_url,
|
||||
tqdm_download,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -580,7 +592,6 @@ class Album(Tracklist):
|
||||
def load_meta(self):
|
||||
assert hasattr(self, "id"), "id must be set to load metadata"
|
||||
self.meta = self.client.get(self.id, media_type="album")
|
||||
# pprint(self.meta)
|
||||
|
||||
# update attributes based on response
|
||||
for k, v in self._parse_get_resp(self.meta, self.client).items():
|
||||
@@ -622,7 +633,7 @@ class Album(Tracklist):
|
||||
"albumartist": resp.get("artist", {}).get("name"),
|
||||
"year": str(resp.get("release_date_original"))[:4],
|
||||
"version": resp.get("version"),
|
||||
"release_type": resp.get("release_type", "n/a"),
|
||||
"release_type": resp.get("release_type", "album"),
|
||||
"cover_urls": resp.get("image"),
|
||||
"streamable": resp.get("streamable"),
|
||||
"quality": quality_id(
|
||||
@@ -1209,6 +1220,7 @@ class Artist(Tracklist):
|
||||
:type album: Album
|
||||
:rtype: bool
|
||||
"""
|
||||
# Doesn't work yet
|
||||
return album["release_type"] == "album"
|
||||
|
||||
# --------- Magic Methods --------
|
||||
|
||||
@@ -7,10 +7,10 @@ from typing import Generator, Optional, Tuple, Union
|
||||
from .constants import (
|
||||
COPYRIGHT,
|
||||
FLAC_KEY,
|
||||
TRACK_KEYS,
|
||||
MP3_KEY,
|
||||
MP4_KEY,
|
||||
PHON_COPYRIGHT,
|
||||
TRACK_KEYS,
|
||||
)
|
||||
from .exceptions import InvalidContainerError
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import logging
|
||||
import logging.handlers as handlers
|
||||
import os
|
||||
from typing import Optional
|
||||
from string import Formatter
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
from tqdm import tqdm
|
||||
from pathvalidate import sanitize_filename
|
||||
from tqdm import tqdm
|
||||
|
||||
from .constants import LOG_DIR, TIDAL_COVER_URL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user