Misc typing

This commit is contained in:
Nathan Thomas 2023-03-16 19:55:12 -07:00
parent 48b4da80e5
commit f81176b3dc
8 changed files with 26 additions and 22 deletions

View file

@ -374,7 +374,7 @@ class QobuzClient(Client):
self.label = resp["user"]["credential"]["parameters"]["short_label"]
def _api_get_file_url(
self, track_id: Union[str, int], quality: int = 3, sec: str = None
self, track_id: Union[str, int], quality: int = 3, sec: Optional[str] = None
) -> dict:
"""Get the file url given a track id.

View file

@ -191,3 +191,5 @@ DEEZER_BASE = "https://api.deezer.com"
DEEZER_DL = "http://dz.loaderapp.info/deezer"
SOUNDCLOUD_BASE = "https://api-v2.soundcloud.com"
MAX_FILES_OPEN = 128

View file

@ -5,7 +5,7 @@ import logging
import os
import re
from tempfile import gettempdir
from typing import Callable, Dict, Iterator, List, Optional
from typing import Callable, Dict, Iterable, List, Optional
import aiofiles
import aiohttp
@ -81,10 +81,10 @@ class DownloadStream:
except json.JSONDecodeError:
raise NonStreamable("File not found.")
def __iter__(self) -> Iterator:
def __iter__(self) -> Iterable:
"""Iterate through chunks of the stream.
:rtype: Iterator
:rtype: Iterable
"""
if self.source == "deezer" and self.is_encrypted.search(self.url) is not None:
assert isinstance(self.id, str), self.id
@ -151,7 +151,7 @@ class DownloadPool:
def __init__(
self,
urls: Iterator,
urls: Iterable,
tempdir: str = None,
chunk_callback: Optional[Callable] = None,
):

View file

@ -114,3 +114,7 @@ class PartialFailure(Exception):
"""
self.failed_items = failed_items
super().__init__()
class FfmpegError(Exception):
"""Raise if ffmpeg returns nonzero exit code."""