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 json
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -69,8 +68,8 @@ class YTMusicOAuth:
|
||||||
return self._parse_token(response)
|
return self._parse_token(response)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def dump_token(token, filepath):
|
def dump_token(token: Dict, filepath: Optional[str]):
|
||||||
if not Path(filepath).is_file():
|
if not filepath or len(filepath) > 255:
|
||||||
return
|
return
|
||||||
with open(filepath, encoding="utf8", mode="w") as file:
|
with open(filepath, encoding="utf8", mode="w") as file:
|
||||||
json.dump(token, file, indent=True)
|
json.dump(token, file, indent=True)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ def parse_args(args):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args(sys.argv[1:])
|
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...")
|
print(f"Creating {filename} with your authentication credentials...")
|
||||||
func = setup_oauth if args.setup_type == "oauth" else setup
|
func = setup_oauth if args.setup_type == "oauth" else setup
|
||||||
return func(filename)
|
return func(filename)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue