diff --git a/pyqrcodeng.pyi b/pyqrcodeng.pyi new file mode 100644 index 0000000..02e479b --- /dev/null +++ b/pyqrcodeng.pyi @@ -0,0 +1,4 @@ +class QRCode: + def terminal(self, quiet_zone: int) -> str: ... + +def create(data: str) -> QRCode: ... diff --git a/pytube.pyi b/pytube.pyi new file mode 100644 index 0000000..92854d3 --- /dev/null +++ b/pytube.pyi @@ -0,0 +1,60 @@ +from __future__ import annotations +from collections.abc import Iterable +from typing import Any, Callable, Iterator, Optional + +class exceptions: + class PytubeError(Exception): ... + +class Channel: + channel_id: str + + def __init__(self, url: str) -> None: + pass + +class innertube: + class InnerTube: + base_url: str + base_data: dict[str, str] + base_params: dict[str, str] + + def _call_api( + self, endpoint: str, params: dict[str, str], data: dict[str, str] + ) -> dict[str, Any]: ... + def __init__(self, client: str) -> None: ... + +class Stream: + resolution: str + is_progressive: bool + is_adaptive: bool + abr: str + def download( + self, + output_path: Optional[str] = None, + filename_prefix: Optional[str] = None, + ) -> str: ... + +class StreamQuery(Iterable[Stream]): + resolution: str + def filter( + self, + type: Optional[str] = None, + custom_filter_functions: Optional[ + list[Callable[[StreamQuery], bool]] + ] = None, + only_audio: bool = False, + ) -> StreamQuery: ... + def __iter__(self) -> Iterator[Stream]: ... + +class YouTube: + def __init__(self, url: str) -> None: ... + + length: int + title: str + author: str + watch_url: str + streams: StreamQuery + +class Search: + results: Optional[list[YouTube]] + + def __init__(self, query: str) -> None: ... diff --git a/syng/client.py b/syng/client.py index e421ae5..77571ea 100644 --- a/syng/client.py +++ b/syng/client.py @@ -62,7 +62,7 @@ sources: dict[str, Source] = {} currentLock: asyncio.Semaphore = asyncio.Semaphore(0) -def default_config(): +def default_config() -> dict[str, Optional[int | str]]: return { "preview_duration": 3, "last_song": None, diff --git a/syng/sources/s3.py b/syng/sources/s3.py index a7f6e88..cee6af9 100644 --- a/syng/sources/s3.py +++ b/syng/sources/s3.py @@ -148,16 +148,16 @@ class S3Source(Source): if os.path.splitext(entry.ident)[1] == ".cdg": cdg_filename: str = os.path.basename(entry.ident) - path_to_file: str = os.path.dirname(entry.ident) + path_to_files: str = os.path.dirname(entry.ident) - cdg_path: str = os.path.join(path_to_file, cdg_filename) + cdg_path: str = os.path.join(path_to_files, cdg_filename) target_file_cdg: str = os.path.join(self.tmp_dir, cdg_path) ident_mp3: str = entry.ident[:-3] + "mp3" target_file_mp3: str = target_file_cdg[:-3] + "mp3" os.makedirs(os.path.dirname(target_file_cdg), exist_ok=True) - video_task: asyncio.Task[Any] = asyncio.create_task( + cdg_task: asyncio.Task[Any] = asyncio.create_task( asyncio.to_thread( self.minio.fget_object, self.bucket, @@ -174,7 +174,7 @@ class S3Source(Source): ) ) - await video_task + await cdg_task await audio_task return target_file_cdg, target_file_mp3 video_filename: str = os.path.basename(entry.ident) diff --git a/syng/sources/youtube.py b/syng/sources/youtube.py index 4c7cd5b..26340f8 100644 --- a/syng/sources/youtube.py +++ b/syng/sources/youtube.py @@ -19,7 +19,7 @@ from pytube import Search from pytube import Stream from pytube import StreamQuery from pytube import YouTube -from pytube.exceptions import PytubeError +from pytube import exceptions try: from yt_dlp import YoutubeDL @@ -152,7 +152,7 @@ class YoutubeSource(Source): artist=yt_song.author, performer=performer, ) - except PytubeError: + except exceptions.PytubeError: return None return await asyncio.to_thread(_get_entry, performer, ident)