mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-13 06:34:45 -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.*]
|
[mypy-deezer.*]
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
|
||||||
|
[mypy-appdirs.*]
|
||||||
|
ignore_missing_imports = True
|
||||||
|
|
|
@ -7,8 +7,8 @@ import shutil
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
from click import style, secho
|
|
||||||
import tomlkit
|
import tomlkit
|
||||||
|
from click import secho
|
||||||
|
|
||||||
from streamrip.exceptions import InvalidSourceError
|
from streamrip.exceptions import InvalidSourceError
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from appdirs import user_config_dir
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from appdirs import user_config_dir
|
||||||
|
|
||||||
APPNAME = "streamrip"
|
APPNAME = "streamrip"
|
||||||
APP_DIR = user_config_dir(APPNAME)
|
APP_DIR = user_config_dir(APPNAME)
|
||||||
HOME = Path.home()
|
HOME = Path.home()
|
||||||
|
|
|
@ -10,8 +10,8 @@ from hashlib import md5
|
||||||
from string import Formatter
|
from string import Formatter
|
||||||
from typing import Dict, Generator, List, Optional, Tuple, Type, Union
|
from typing import Dict, Generator, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from click import style, secho
|
|
||||||
import requests
|
import requests
|
||||||
|
from click import secho, style
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from streamrip.clients import (
|
from streamrip.clients import (
|
||||||
|
|
|
@ -11,10 +11,9 @@ from abc import ABC, abstractmethod
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from typing import Any, Dict, Generator, Optional, Sequence, Tuple, Union
|
from typing import Any, Dict, Generator, Optional, Sequence, Tuple, Union
|
||||||
|
|
||||||
from click import style, secho
|
|
||||||
import deezer
|
import deezer
|
||||||
import requests
|
from click import secho
|
||||||
from Cryptodome.Cipher import AES, Blowfish # type: ignore
|
from Cryptodome.Cipher import AES
|
||||||
|
|
||||||
from .constants import (
|
from .constants import (
|
||||||
AGENT,
|
AGENT,
|
||||||
|
@ -588,40 +587,6 @@ class DeezerClient(Client):
|
||||||
AES.new("jo6aey6haid2Teih".encode(), AES.MODE_ECB).encrypt(data)
|
AES.new("jo6aey6haid2Teih".encode(), AES.MODE_ECB).encrypt(data)
|
||||||
).decode("utf-8")
|
).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
|
@staticmethod
|
||||||
def _quality_id_from_filetype(filetype: str) -> Optional[int]:
|
def _quality_id_from_filetype(filetype: str) -> Optional[int]:
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Streamrip specific exceptions."""
|
"""Streamrip specific exceptions."""
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from click import style, secho
|
from click import echo, style
|
||||||
|
|
||||||
|
|
||||||
class AuthenticationError(Exception):
|
class AuthenticationError(Exception):
|
||||||
|
|
|
@ -15,7 +15,7 @@ import subprocess
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple, Union
|
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.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
|
||||||
|
|
|
@ -10,7 +10,6 @@ from typing import Generator, Hashable, Iterable, Optional, Union
|
||||||
from .constants import (
|
from .constants import (
|
||||||
ALBUM_KEYS,
|
ALBUM_KEYS,
|
||||||
COPYRIGHT,
|
COPYRIGHT,
|
||||||
COVER_SIZES,
|
|
||||||
FLAC_KEY,
|
FLAC_KEY,
|
||||||
MP3_KEY,
|
MP3_KEY,
|
||||||
MP4_KEY,
|
MP4_KEY,
|
||||||
|
@ -19,7 +18,7 @@ from .constants import (
|
||||||
TRACK_KEYS,
|
TRACK_KEYS,
|
||||||
)
|
)
|
||||||
from .exceptions import InvalidContainerError, InvalidSourceError
|
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")
|
logger = logging.getLogger("streamrip")
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ from collections import OrderedDict
|
||||||
from string import Formatter
|
from string import Formatter
|
||||||
from typing import Dict, Hashable, Iterator, Optional, Tuple, Union
|
from typing import Dict, Hashable, Iterator, Optional, Tuple, Union
|
||||||
|
|
||||||
from click import secho
|
|
||||||
import requests
|
import requests
|
||||||
|
from click import secho, style
|
||||||
from Cryptodome.Cipher import Blowfish
|
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
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from click import style, secho, echo
|
from click import echo, secho
|
||||||
|
|
||||||
test_urls = {
|
test_urls = {
|
||||||
"qobuz": "https://www.qobuz.com/us-en/album/blackest-blue-morcheeba/h4nngz0wgqesc",
|
"qobuz": "https://www.qobuz.com/us-en/album/blackest-blue-morcheeba/h4nngz0wgqesc",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue