oauth: fix dump_token path detection
This commit is contained in:
parent
8aee43837b
commit
9f2b5d6d2e
2 changed files with 3 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue