From e8167f0e3764d3bb1a093d5986c4ee7abce57593 Mon Sep 17 00:00:00 2001 From: Rafael Moraes <50295204+glomatico@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:12:21 -0300 Subject: [PATCH] add `cookies_browser` option --- votify/cli.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/votify/cli.py b/votify/cli.py index 9deca11..ccf5c2e 100644 --- a/votify/cli.py +++ b/votify/cli.py @@ -141,13 +141,18 @@ def load_config_file( is_flag=True, help="Don't print exceptions.", ) -# SpotifyApi specific options @click.option( "--cookies-path", type=Path, - default=spotify_api_sig.parameters["cookies_path"].default, + default=Path("./cookies.txt"), help="Path to cookies file.", ) +@click.option( + "--cookies-browser", + type=str, + default=None, + help="Browser to use to get cookies instead of loading a file.", +) # Downloader specific options @click.option( "--output-path", @@ -351,6 +356,7 @@ def main( log_level: str, no_exceptions: bool, cookies_path: Path, + cookies_browser: str, output_path: Path, temp_path: Path, wvd_path: Path, @@ -389,7 +395,12 @@ def main( ) logger.setLevel(log_level) logger.info("Starting Votify") - spotify_api = SpotifyApi(cookies_path) + if cookies_browser: + spotify_api = SpotifyApi.from_browser(cookies_browser) + else: + if not cookies_path.exists(): + logger.critical(X_NOT_FOUND_STRING.format("Cookies file", cookies_path)) + spotify_api = SpotifyApi.from_file(cookies_path) if spotify_api.config_info["isAnonymous"]: logger.critical( "Failed to get a valid session. Try logging in and exporting your cookies again"