mirror of
https://github.com/glomatico/votify.git
synced 2026-10-05 07:22:18 +02:00
Add session_type handling to CLI/config
This commit is contained in:
+7
-7
@@ -9,6 +9,7 @@ from dataclass_click import dataclass_click
|
||||
|
||||
from .. import __version__
|
||||
from ..api.api import Librespot, SpotifyApi
|
||||
from ..api.enums import SessionType
|
||||
from ..downloader.audio import SpotifyAudioDownloader
|
||||
from ..downloader.base import SpotifyBaseDownloader
|
||||
from ..downloader.downloader import SpotifyDownloader
|
||||
@@ -92,17 +93,16 @@ async def main(config: CliConfig):
|
||||
database = None
|
||||
flat_filter = None
|
||||
|
||||
if not Librespot and not any(
|
||||
audio_quality.mp4 for audio_quality in config.audio_quality
|
||||
):
|
||||
logger.warning(
|
||||
"Librespot is not available, "
|
||||
"Vorbis audio quality for songs will not be available"
|
||||
if not Librespot and config.session_type == SessionType.LIBRESPOT:
|
||||
logger.critical(
|
||||
"Librespot session type selected, but Librespot is not available. "
|
||||
"Make sure you have installed the 'librespot' dependency."
|
||||
)
|
||||
return
|
||||
|
||||
api = await SpotifyApi.create_from_netscape_cookies(
|
||||
cookies_path,
|
||||
skip_librespot=not Librespot,
|
||||
session_type=config.session_type,
|
||||
)
|
||||
if api.anonymous_session:
|
||||
logger.critical(
|
||||
|
||||
@@ -7,6 +7,7 @@ import click
|
||||
from dataclass_click import argument, option
|
||||
|
||||
from ..api.api import SpotifyApi
|
||||
from ..api.enums import SessionType
|
||||
from ..downloader.audio import SpotifyAudioDownloader
|
||||
from ..downloader.base import SpotifyBaseDownloader
|
||||
from ..downloader.downloader import SpotifyDownloader
|
||||
@@ -16,15 +17,16 @@ from ..interface.audio import SpotifyAudioInterface
|
||||
from ..interface.base import SpotifyBaseInterface
|
||||
from ..interface.enums import (
|
||||
AudioQuality,
|
||||
AutoMediaOption,
|
||||
CoverSize,
|
||||
VideoFormat,
|
||||
VideoResolution,
|
||||
AutoMediaOption,
|
||||
)
|
||||
from ..interface.interface import SpotifyInterface
|
||||
from ..interface.video import SpotifyVideoInterface
|
||||
from .utils import Csv
|
||||
|
||||
api_sig = inspect.signature(SpotifyApi.__init__)
|
||||
api_from_cookies_sig = inspect.signature(SpotifyApi.create_from_netscape_cookies)
|
||||
|
||||
base_interface_sig = inspect.signature(SpotifyBaseInterface.__init__)
|
||||
@@ -125,6 +127,15 @@ class CliConfig:
|
||||
),
|
||||
]
|
||||
# API specific options
|
||||
session_type: Annotated[
|
||||
SessionType,
|
||||
option(
|
||||
"--session-type",
|
||||
help="Session type to use for Spotify API",
|
||||
default=api_sig.parameters["session_type"].default,
|
||||
type=SessionType,
|
||||
),
|
||||
]
|
||||
cookies_path: Annotated[
|
||||
str,
|
||||
option(
|
||||
|
||||
Reference in New Issue
Block a user