mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-14 15:15:06 -04:00
Run isort and other cleanup
This commit is contained in:
parent
ca67173162
commit
8d0dc7fb7f
12 changed files with 86 additions and 95 deletions
|
@ -22,7 +22,7 @@ project = "streamrip"
|
||||||
copyright = "2021, nathom"
|
copyright = "2021, nathom"
|
||||||
author = "nathom"
|
author = "nathom"
|
||||||
|
|
||||||
pygments_style = 'sphinx'
|
pygments_style = "sphinx"
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
22
rip/cli.py
22
rip/cli.py
|
@ -1,6 +1,8 @@
|
||||||
"""The streamrip command line interface."""
|
"""The streamrip command line interface."""
|
||||||
import click
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
from streamrip import __version__
|
from streamrip import __version__
|
||||||
|
|
||||||
logging.basicConfig(level="WARNING")
|
logging.basicConfig(level="WARNING")
|
||||||
|
@ -303,12 +305,14 @@ def lastfm(ctx, source, url):
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def config(ctx, **kwargs):
|
def config(ctx, **kwargs):
|
||||||
"""Manage the streamrip configuration file."""
|
"""Manage the streamrip configuration file."""
|
||||||
from streamrip.clients import TidalClient
|
|
||||||
from .constants import CONFIG_PATH
|
|
||||||
from hashlib import md5
|
|
||||||
from getpass import getpass
|
|
||||||
import shutil
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
from getpass import getpass
|
||||||
|
from hashlib import md5
|
||||||
|
|
||||||
|
from streamrip.clients import TidalClient
|
||||||
|
|
||||||
|
from .constants import CONFIG_PATH
|
||||||
|
|
||||||
global config
|
global config
|
||||||
if kwargs["reset"]:
|
if kwargs["reset"]:
|
||||||
|
@ -398,11 +402,13 @@ def convert(ctx, **kwargs):
|
||||||
$ rip convert ALAC --sampling-rate 48000 /my/music
|
$ rip convert ALAC --sampling-rate 48000 /my/music
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from streamrip import converter
|
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
from tqdm import tqdm
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
from streamrip import converter
|
||||||
|
|
||||||
codec_map = {
|
codec_map = {
|
||||||
"FLAC": converter.FLAC,
|
"FLAC": converter.FLAC,
|
||||||
"ALAC": converter.ALAC,
|
"ALAC": converter.ALAC,
|
||||||
|
|
|
@ -10,9 +10,10 @@ from typing import Any, Dict
|
||||||
import click
|
import click
|
||||||
import tomlkit
|
import tomlkit
|
||||||
|
|
||||||
from .constants import CONFIG_DIR, CONFIG_PATH, DOWNLOADS_DIR
|
|
||||||
from streamrip.exceptions import InvalidSourceError
|
from streamrip.exceptions import InvalidSourceError
|
||||||
|
|
||||||
|
from .constants import CONFIG_DIR, CONFIG_PATH, DOWNLOADS_DIR
|
||||||
|
|
||||||
logger = logging.getLogger("streamrip")
|
logger = logging.getLogger("streamrip")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import click
|
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
APPNAME = "streamrip"
|
APPNAME = "streamrip"
|
||||||
APP_DIR = click.get_app_dir(APPNAME)
|
APP_DIR = click.get_app_dir(APPNAME)
|
||||||
HOME = Path.home()
|
HOME = Path.home()
|
||||||
|
|
56
rip/core.py
56
rip/core.py
|
@ -5,7 +5,6 @@ import html
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from string import Formatter
|
from string import Formatter
|
||||||
|
@ -15,16 +14,6 @@ import click
|
||||||
import requests
|
import requests
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from streamrip.media import (
|
|
||||||
Track,
|
|
||||||
Video,
|
|
||||||
YoutubeVideo,
|
|
||||||
Album,
|
|
||||||
Artist,
|
|
||||||
Label,
|
|
||||||
Playlist,
|
|
||||||
Tracklist,
|
|
||||||
)
|
|
||||||
from streamrip.clients import (
|
from streamrip.clients import (
|
||||||
Client,
|
Client,
|
||||||
DeezerClient,
|
DeezerClient,
|
||||||
|
@ -33,36 +22,43 @@ from streamrip.clients import (
|
||||||
SoundCloudClient,
|
SoundCloudClient,
|
||||||
TidalClient,
|
TidalClient,
|
||||||
)
|
)
|
||||||
from .config import Config
|
|
||||||
from streamrip.constants import MEDIA_TYPES
|
from streamrip.constants import MEDIA_TYPES
|
||||||
from streamrip.utils import set_progress_bar_theme, TQDM_DEFAULT_THEME
|
|
||||||
from .constants import (
|
|
||||||
URL_REGEX,
|
|
||||||
SOUNDCLOUD_URL_REGEX,
|
|
||||||
LASTFM_URL_REGEX,
|
|
||||||
QOBUZ_INTERPRETER_URL_REGEX,
|
|
||||||
YOUTUBE_URL_REGEX,
|
|
||||||
DEEZER_DYNAMIC_LINK_REGEX,
|
|
||||||
CONFIG_PATH,
|
|
||||||
DB_PATH,
|
|
||||||
FAILED_DB_PATH,
|
|
||||||
)
|
|
||||||
from . import db
|
|
||||||
from streamrip.exceptions import (
|
from streamrip.exceptions import (
|
||||||
AuthenticationError,
|
AuthenticationError,
|
||||||
PartialFailure,
|
|
||||||
ItemExists,
|
ItemExists,
|
||||||
MissingCredentials,
|
MissingCredentials,
|
||||||
NonStreamable,
|
NonStreamable,
|
||||||
NoResultsFound,
|
NoResultsFound,
|
||||||
ParsingError,
|
ParsingError,
|
||||||
|
PartialFailure,
|
||||||
)
|
)
|
||||||
from .utils import (
|
from streamrip.media import (
|
||||||
extract_deezer_dynamic_link,
|
Album,
|
||||||
extract_interpreter_url,
|
Artist,
|
||||||
|
Label,
|
||||||
|
Playlist,
|
||||||
|
Track,
|
||||||
|
Tracklist,
|
||||||
|
Video,
|
||||||
|
YoutubeVideo,
|
||||||
|
)
|
||||||
|
from streamrip.utils import TQDM_DEFAULT_THEME, set_progress_bar_theme
|
||||||
|
|
||||||
|
from . import db
|
||||||
|
from .config import Config
|
||||||
|
from .constants import (
|
||||||
|
CONFIG_PATH,
|
||||||
|
DB_PATH,
|
||||||
|
DEEZER_DYNAMIC_LINK_REGEX,
|
||||||
|
FAILED_DB_PATH,
|
||||||
|
LASTFM_URL_REGEX,
|
||||||
|
QOBUZ_INTERPRETER_URL_REGEX,
|
||||||
|
SOUNDCLOUD_URL_REGEX,
|
||||||
|
URL_REGEX,
|
||||||
|
YOUTUBE_URL_REGEX,
|
||||||
)
|
)
|
||||||
from .exceptions import DeezloaderFallback
|
from .exceptions import DeezloaderFallback
|
||||||
|
from .utils import extract_deezer_dynamic_link, extract_interpreter_url
|
||||||
|
|
||||||
logger = logging.getLogger("streamrip")
|
logger = logging.getLogger("streamrip")
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from streamrip.utils import gen_threadsafe_session
|
|
||||||
from streamrip.constants import AGENT
|
|
||||||
from typing import Tuple
|
|
||||||
import re
|
import re
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
|
from streamrip.constants import AGENT
|
||||||
|
from streamrip.utils import gen_threadsafe_session
|
||||||
|
|
||||||
interpreter_artist_regex = re.compile(r"getSimilarArtist\(\s*'(\w+)'")
|
interpreter_artist_regex = re.compile(r"getSimilarArtist\(\s*'(\w+)'")
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
__version__ = "0.7.1"
|
__version__ = "0.7.1"
|
||||||
|
|
||||||
from . import clients, converter, media, constants
|
from . import clients, constants, converter, media
|
||||||
|
|
|
@ -4,31 +4,31 @@ import base64
|
||||||
import binascii
|
import binascii
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
from Cryptodome.Cipher import Blowfish, AES # type: ignore
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from pprint import pformat
|
|
||||||
import requests
|
|
||||||
import deezer # type: ignore
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Generator, Sequence, Tuple, Union, Dict, Any, Optional
|
from pprint import pformat
|
||||||
|
from typing import Any, Dict, Generator, Optional, Sequence, Tuple, Union
|
||||||
|
|
||||||
import click # type: ignore
|
import click # type: ignore
|
||||||
|
import deezer # type: ignore
|
||||||
|
import requests
|
||||||
|
from Cryptodome.Cipher import AES, Blowfish # type: ignore
|
||||||
|
|
||||||
from .constants import (
|
from .constants import (
|
||||||
AGENT,
|
AGENT,
|
||||||
AVAILABLE_QUALITY_IDS,
|
AVAILABLE_QUALITY_IDS,
|
||||||
DEEZER_BASE,
|
DEEZER_BASE,
|
||||||
DEEZER_FORMATS,
|
|
||||||
DEEZER_DL,
|
DEEZER_DL,
|
||||||
|
DEEZER_FORMATS,
|
||||||
DEEZER_MAX_Q,
|
DEEZER_MAX_Q,
|
||||||
QOBUZ_BASE,
|
QOBUZ_BASE,
|
||||||
QOBUZ_FEATURED_KEYS,
|
QOBUZ_FEATURED_KEYS,
|
||||||
|
SOUNDCLOUD_APP_VERSION,
|
||||||
SOUNDCLOUD_BASE,
|
SOUNDCLOUD_BASE,
|
||||||
SOUNDCLOUD_CLIENT_ID,
|
SOUNDCLOUD_CLIENT_ID,
|
||||||
SOUNDCLOUD_USER_ID,
|
SOUNDCLOUD_USER_ID,
|
||||||
SOUNDCLOUD_APP_VERSION,
|
|
||||||
TIDAL_AUTH_URL,
|
TIDAL_AUTH_URL,
|
||||||
TIDAL_BASE,
|
TIDAL_BASE,
|
||||||
TIDAL_CLIENT_INFO,
|
TIDAL_CLIENT_INFO,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,48 +5,53 @@ and the other objects. They can also be downloaded individually, for example,
|
||||||
as a single track.
|
as a single track.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import abc
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import abc
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
from tqdm import tqdm
|
from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple, Union
|
||||||
from typing import Any, Optional, Union, Iterable, Generator, Dict, Tuple, List
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from mutagen.flac import FLAC, Picture
|
from mutagen.flac import FLAC, Picture
|
||||||
from mutagen.id3 import APIC, ID3, ID3NoHeaderError
|
from mutagen.id3 import APIC, ID3, ID3NoHeaderError
|
||||||
from mutagen.mp4 import MP4, MP4Cover
|
from mutagen.mp4 import MP4, MP4Cover
|
||||||
from pathvalidate import sanitize_filepath, sanitize_filename
|
from pathvalidate import sanitize_filename, sanitize_filepath
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
from . import converter
|
from . import converter
|
||||||
from .clients import Client, DeezloaderClient
|
from .clients import Client, DeezloaderClient
|
||||||
from .constants import FLAC_MAX_BLOCKSIZE, FOLDER_FORMAT, TRACK_FORMAT, ALBUM_KEYS
|
from .constants import (
|
||||||
|
ALBUM_KEYS,
|
||||||
|
FLAC_MAX_BLOCKSIZE,
|
||||||
|
FOLDER_FORMAT,
|
||||||
|
TRACK_FORMAT,
|
||||||
|
)
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
InvalidQuality,
|
InvalidQuality,
|
||||||
PartialFailure,
|
|
||||||
ItemExists,
|
|
||||||
InvalidSourceError,
|
InvalidSourceError,
|
||||||
|
ItemExists,
|
||||||
NonStreamable,
|
NonStreamable,
|
||||||
|
PartialFailure,
|
||||||
TooLargeCoverArt,
|
TooLargeCoverArt,
|
||||||
)
|
)
|
||||||
from .metadata import TrackMetadata
|
from .metadata import TrackMetadata
|
||||||
from .utils import (
|
from .utils import (
|
||||||
clean_format,
|
|
||||||
tqdm_stream,
|
|
||||||
downsize_image,
|
|
||||||
get_cover_urls,
|
|
||||||
decrypt_mqa_file,
|
|
||||||
tqdm_download,
|
|
||||||
get_container,
|
|
||||||
DownloadStream,
|
DownloadStream,
|
||||||
|
clean_format,
|
||||||
|
decrypt_mqa_file,
|
||||||
|
downsize_image,
|
||||||
ext,
|
ext,
|
||||||
|
get_container,
|
||||||
|
get_cover_urls,
|
||||||
get_stats_from_quality,
|
get_stats_from_quality,
|
||||||
safe_get,
|
safe_get,
|
||||||
tidal_cover_url,
|
tidal_cover_url,
|
||||||
|
tqdm_download,
|
||||||
|
tqdm_stream,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger("streamrip")
|
logger = logging.getLogger("streamrip")
|
||||||
|
|
|
@ -19,7 +19,7 @@ from .constants import (
|
||||||
TRACK_KEYS,
|
TRACK_KEYS,
|
||||||
)
|
)
|
||||||
from .exceptions import InvalidContainerError, InvalidSourceError
|
from .exceptions import InvalidContainerError, InvalidSourceError
|
||||||
from .utils import get_quality_id, safe_get, tidal_cover_url, get_cover_urls
|
from .utils import get_cover_urls, get_quality_id, safe_get, tidal_cover_url
|
||||||
|
|
||||||
logger = logging.getLogger("streamrip")
|
logger = logging.getLogger("streamrip")
|
||||||
|
|
||||||
|
|
|
@ -3,31 +3,24 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import functools
|
||||||
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from string import Formatter
|
|
||||||
from typing import (
|
|
||||||
Dict,
|
|
||||||
Hashable,
|
|
||||||
Optional,
|
|
||||||
Tuple,
|
|
||||||
Union,
|
|
||||||
Generator,
|
|
||||||
)
|
|
||||||
from collections import OrderedDict
|
|
||||||
import functools
|
|
||||||
from Cryptodome.Cipher import Blowfish
|
|
||||||
import hashlib
|
|
||||||
import re
|
import re
|
||||||
|
from collections import OrderedDict
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
|
from string import Formatter
|
||||||
|
from typing import Dict, Generator, Hashable, Optional, Tuple, Union
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import requests
|
import requests
|
||||||
|
from Cryptodome.Cipher import Blowfish
|
||||||
from pathvalidate import sanitize_filename
|
from pathvalidate import sanitize_filename
|
||||||
from requests.packages import urllib3
|
from requests.packages import urllib3
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from .constants import TIDAL_COVER_URL, COVER_SIZES
|
from .constants import COVER_SIZES, TIDAL_COVER_URL
|
||||||
from .exceptions import InvalidQuality, InvalidSourceError, NonStreamable
|
from .exceptions import InvalidQuality, InvalidSourceError, NonStreamable
|
||||||
|
|
||||||
urllib3.disable_warnings()
|
urllib3.disable_warnings()
|
||||||
|
@ -60,19 +53,6 @@ def safe_get(d: dict, *keys: Hashable, default=None):
|
||||||
curr = res
|
curr = res
|
||||||
return res
|
return res
|
||||||
|
|
||||||
"""
|
|
||||||
FLAC = 9
|
|
||||||
MP3_320 = 3
|
|
||||||
MP3_128 = 1
|
|
||||||
MP4_RA3 = 15
|
|
||||||
MP4_RA2 = 14
|
|
||||||
MP4_RA1 = 13
|
|
||||||
DEFAULT = 8
|
|
||||||
LOCAL = 0
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
__QUALITY_MAP: Dict[str, Dict[int, Union[int, str, Tuple[int, str]]]] = {
|
__QUALITY_MAP: Dict[str, Dict[int, Union[int, str, Tuple[int, str]]]] = {
|
||||||
"qobuz": {
|
"qobuz": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue