ebb-earl-co / tidal-wave

Waving at the TIDAL music service
Apache License 2.0
35 stars 2 forks source link

Windows Token Hotfix #89

Closed AVAEO closed 4 months ago

AVAEO commented 4 months ago

On Windows 10 I have had issues recently with inputting the token when requesting a HiRes track.

Quick fix I found to work is replacing line 195 in login.py to access_token: Optional[str] = None if _token is None else _token.get("access_token").

This, as far as I'm aware, will fix the issue of 'AttributeError: 'NoneType' object has no attribute 'get''.

Fixing this leads to issue #88. Sadly haven't found a fix for this yet.

ebb-earl-co commented 4 months ago

Hi, @AVAEO , thank you for having opened an issue. Can you paste the logs into this issue, ideally in a code-formatted way?

like this here

It seems my neglect of the login_windows() code path has come to bite me!

AVAEO commented 4 months ago

Hi, @AVAEO , thank you for having opened an issue. Can you paste the logs into this issue, ideally in a code-formatted way?

like this here

It seems my neglect of the login_windows() code path has come to bite me!


2024-03-02:09:31:04,431 INFO     [models.py:662] TIDAL track ID parsed from input: 252584684
For which of Android [a] or Windows [w] would you like to provide an API token?: w
2024-03-02:09:31:06,118 WARNING  [login.py:50] FileNotFoundError: C:\Users\AVAEO\AppData\Local\tidal-wave\windows-tidal.token
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\AVAEO                                                                                  │
│ \AppData\Local\Programs\Python\Python312\Lib\site-packages\tidal_wave\main.py:89 in main  │
│                                                                                                  │
│    86 │   │   )                                                                                  │
│    87 │   │   raise typer.Exit(code=1)                                                           │
│    88 │                                                                                          │
│ ❱  89 │   s, audio_format = login(audio_format=audio_format)                                     │
│    90 │   if s is None:                                                                          │
│    91 │   │   raise typer.Exit(code=1)                                                           │
│    92                                                                                            │
│                                                                                                  │
│ ╭───────────────────────────────────── locals ─────────────────────────────────────╮             │
│ │        audio_format = <AudioFormat.hi_res: 'HiRes'>                              │             │
│ │ include_eps_singles = False                                                      │             │
│ │              logger = <Logger tidal_wave.main (DEBUG)>                           │             │
│ │            loglevel = <LogLevel.debug: 'DEBUG'>                                  │             │
│ │      no_extra_files = False                                                      │             │
│ │          no_flatten = False                                                      │             │
│ │    output_directory = WindowsPath('E:/Music')                                    │             │
│ │      tidal_resource = TidalTrack(url='https://tidal.com/browse/track/252584684') │             │
│ │           tidal_url = 'https://tidal.com/browse/track/252584684'                 │             │
│ ╰──────────────────────────────────────────────────────────────────────────────────╯             │
│                                                                                                  │
│ C:\Users\AVAEO                                                                                  │
│ \AppData\Local\Programs\Python\Python312\Lib\site-packages\tidal_wave\login.py:262 in     │
│ login                                                                                            │
│                                                                                                  │
│   259 │   │   │   if _input in {"android", "a"}:                                                 │
│   260 │   │   │   │   return (login_android(), audio_format)                                     │
│   261 │   │   │   elif _input in {"windows", "w"}:                                               │
│ ❱ 262 │   │   │   │   return (login_windows(), audio_format)                                     │
│   263 │   else:                                                                                  │
│   264 │   │   logger.critical(                                                                   │
│   265 │   │   │   "Please provide one of the following: "                                        │
│                                                                                                  │
│ ╭──────────────────────────────── locals ────────────────────────────────╮                       │
│ │               _input = 'w'                                             │                       │
│ │         audio_format = <AudioFormat.hi_res: 'HiRes'>                   │                       │
│ │      fire_tv_formats = {                                               │                       │
│ │                        │   <AudioFormat.lossless: 'Lossless'>,         │                       │
│ │                        │   <AudioFormat.low: 'Low'>,                   │                       │
│ │                        │   <AudioFormat.dolby_atmos: 'Atmos'>,         │                       │
│ │                        │   <AudioFormat.high: 'High'>,                 │                       │
│ │                        │   <AudioFormat.mqa: 'MQA'>                    │                       │
│ │                        }                                               │                       │
│ │ high_quality_formats = {                                               │                       │
│ │                        │   <AudioFormat.hi_res: 'HiRes'>,              │                       │
│ │                        │   <AudioFormat.sony_360_reality_audio: '360'> │                       │
│ │                        }                                               │                       │
│ │              options = {'windows', 'a', 'android', 'w'}                │                       │
│ ╰────────────────────────────────────────────────────────────────────────╯                       │
│                                                                                                  │
│ C:\Users\AVAEO                                                                                  │
│ \AppData\Local\Programs\Python\Python312\Lib\site-packages\tidal_wave\login.py:195 in     │
│ login_windows                                                                                    │
│                                                                                                  │
│   192 │   token_path: Path = TOKEN_DIR_PATH / "windows-tidal.token",                             │
│   193 ) -> Optional[requests.Session]:                                                           │
│   194 │   _token: Optional[dict] = load_token_from_disk(token_path=token_path)                   │
│ ❱ 195 │   access_token: Optional[str] = _token.get("access_token")                               │
│   196 #    access_token: Optional[str] = None if _token is None else _token.get("access_token"   │
│   197 │   if access_token is None:                                                               │
│   198 │   │   access_token: str = typer.prompt(                                                  │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │     _token = None                                                                            │ │
│ │ token_path = WindowsPath('C:/Users/AVAEO                                                    │ │
│ │             /AppData/Local/tidal-wave/windows-tidal.token')                          │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'get'