oauth: fix dump_token path detection

This commit is contained in:
sigma67 2023-04-20 21:13:32 +02:00
commit 9f2b5d6d2e
No known key found for this signature in database
GPG key ID: 1C314227DF0103D0
2 changed files with 3 additions and 4 deletions

View file

@ -1,6 +1,5 @@
import json
import time
from pathlib import Path
from typing import Dict, Optional
import requests
@ -69,8 +68,8 @@ class YTMusicOAuth:
return self._parse_token(response)
@staticmethod
def dump_token(token, filepath):
if not Path(filepath).is_file():
def dump_token(token: Dict, filepath: Optional[str]):
if not filepath or len(filepath) > 255:
return
with open(filepath, encoding="utf8", mode="w") as file:
json.dump(token, file, indent=True)

View file

@ -52,7 +52,7 @@ def parse_args(args):
def main():
args = parse_args(sys.argv[1:])
filename = args.file if args.file else f"{args.setup_type}.json"
filename = args.file.as_posix() if args.file else f"{args.setup_type}.json"
print(f"Creating {filename} with your authentication credentials...")
func = setup_oauth if args.setup_type == "oauth" else setup
return func(filename)