mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-12 22:26:16 -04:00
Cleanup imports
This commit is contained in:
parent
936975a681
commit
77917dc6f0
10 changed files with 14 additions and 46 deletions
|
@ -39,3 +39,6 @@ ignore_missing_imports = True
|
|||
|
||||
[mypy-deezer.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-appdirs.*]
|
||||
ignore_missing_imports = True
|
||||
|
|
|
@ -7,8 +7,8 @@ import shutil
|
|||
from pprint import pformat
|
||||
from typing import Any, Dict
|
||||
|
||||
from click import style, secho
|
||||
import tomlkit
|
||||
from click import secho
|
||||
|
||||
from streamrip.exceptions import InvalidSourceError
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
import os
|
||||
import re
|
||||
from appdirs import user_config_dir
|
||||
from pathlib import Path
|
||||
|
||||
from appdirs import user_config_dir
|
||||
|
||||
APPNAME = "streamrip"
|
||||
APP_DIR = user_config_dir(APPNAME)
|
||||
HOME = Path.home()
|
||||
|
|
|
@ -10,8 +10,8 @@ from hashlib import md5
|
|||
from string import Formatter
|
||||
from typing import Dict, Generator, List, Optional, Tuple, Type, Union
|
||||
|
||||
from click import style, secho
|
||||
import requests
|
||||
from click import secho, style
|
||||
from tqdm import tqdm
|
||||
|
||||
from streamrip.clients import (
|
||||
|
|
|
@ -11,10 +11,9 @@ from abc import ABC, abstractmethod
|
|||
from pprint import pformat
|
||||
from typing import Any, Dict, Generator, Optional, Sequence, Tuple, Union
|
||||
|
||||
from click import style, secho
|
||||
import deezer
|
||||
import requests
|
||||
from Cryptodome.Cipher import AES, Blowfish # type: ignore
|
||||
from click import secho
|
||||
from Cryptodome.Cipher import AES
|
||||
|
||||
from .constants import (
|
||||
AGENT,
|
||||
|
@ -588,40 +587,6 @@ class DeezerClient(Client):
|
|||
AES.new("jo6aey6haid2Teih".encode(), AES.MODE_ECB).encrypt(data)
|
||||
).decode("utf-8")
|
||||
|
||||
def _decrypt_stream(self, url: str, meta_id: str, output_stream):
|
||||
headers = {"User-Agent": AGENT}
|
||||
chunk_len = 0
|
||||
# isCryptedStream = (
|
||||
# "/mobile/" in track.downloadURL or "/media/" in track.downloadURL
|
||||
# )
|
||||
|
||||
# itemData = {
|
||||
# "id": track.id,
|
||||
# "title": track.title,
|
||||
# "artist": track.mainArtist.name,
|
||||
# }
|
||||
|
||||
with requests.get(url, headers=headers, stream=True, timeout=10) as request:
|
||||
request.raise_for_status()
|
||||
blowfish_key = generate_blowfish_key(meta_id)
|
||||
|
||||
file_size = int(request.headers["Content-Length"])
|
||||
if file_size == 0:
|
||||
raise Exception
|
||||
|
||||
for chunk in request.iter_content(2048 * 3):
|
||||
if len(chunk) >= 2048:
|
||||
chunk = decrypt_chunk(blowfish_key, chunk[0:2048]) + chunk[2048:]
|
||||
|
||||
output_stream.write(chunk)
|
||||
chunk_len += len(chunk)
|
||||
|
||||
# except (SSLError, u3SSLError):
|
||||
# streamTrack(outputStream, track, chunkLength, downloadObject, listener)
|
||||
# except (RequestsConnectionError, ReadTimeout, ChunkedEncodingError):
|
||||
# sleep(2)
|
||||
# streamTrack(outputStream, track, start, downloadObject, listener)
|
||||
|
||||
@staticmethod
|
||||
def _quality_id_from_filetype(filetype: str) -> Optional[int]:
|
||||
return {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Streamrip specific exceptions."""
|
||||
from typing import List
|
||||
|
||||
from click import style, secho
|
||||
from click import echo, style
|
||||
|
||||
|
||||
class AuthenticationError(Exception):
|
||||
|
|
|
@ -15,7 +15,7 @@ import subprocess
|
|||
from tempfile import gettempdir
|
||||
from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
from click import style, secho
|
||||
from click import echo, secho, style
|
||||
from mutagen.flac import FLAC, Picture
|
||||
from mutagen.id3 import APIC, ID3, ID3NoHeaderError
|
||||
from mutagen.mp4 import MP4, MP4Cover
|
||||
|
|
|
@ -10,7 +10,6 @@ from typing import Generator, Hashable, Iterable, Optional, Union
|
|||
from .constants import (
|
||||
ALBUM_KEYS,
|
||||
COPYRIGHT,
|
||||
COVER_SIZES,
|
||||
FLAC_KEY,
|
||||
MP3_KEY,
|
||||
MP4_KEY,
|
||||
|
@ -19,7 +18,7 @@ from .constants import (
|
|||
TRACK_KEYS,
|
||||
)
|
||||
from .exceptions import InvalidContainerError, InvalidSourceError
|
||||
from .utils import get_cover_urls, get_quality_id, safe_get, tidal_cover_url
|
||||
from .utils import get_cover_urls, get_quality_id, safe_get
|
||||
|
||||
logger = logging.getLogger("streamrip")
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ from collections import OrderedDict
|
|||
from string import Formatter
|
||||
from typing import Dict, Hashable, Iterator, Optional, Tuple, Union
|
||||
|
||||
from click import secho
|
||||
import requests
|
||||
from click import secho, style
|
||||
from Cryptodome.Cipher import Blowfish
|
||||
from pathvalidate import sanitize_filename
|
||||
from requests.packages import urllib3
|
||||
|
|
|
@ -2,7 +2,7 @@ import os
|
|||
import shutil
|
||||
import subprocess
|
||||
|
||||
from click import style, secho, echo
|
||||
from click import echo, secho
|
||||
|
||||
test_urls = {
|
||||
"qobuz": "https://www.qobuz.com/us-en/album/blackest-blue-morcheeba/h4nngz0wgqesc",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue