File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 14
14
15
15
module_name = "ytmusic-deleter"
16
16
17
- install_reqs = ["click" , "ytmusicapi == 0.25 .0" , "enlighten" ]
17
+ install_reqs = ["click" , "ytmusicapi >= 1.5 .0" , "enlighten" ]
18
18
19
19
develop_reqs = [
20
20
"pre-commit" ,
Original file line number Diff line number Diff line change
1
+ from json import JSONDecodeError
1
2
import logging
2
3
import os
3
4
import re
4
5
import sys
5
6
from pathlib import Path
6
7
from random import shuffle as unsort
7
8
from time import strftime
9
+ import ytmusicapi
8
10
9
11
import click
10
12
import enlighten
17
19
18
20
def ensure_auth (credential_dir ):
19
21
global youtube_auth
20
- headers_file_path = Path (credential_dir ) / const .HEADERS_FILE
22
+ oauth_file_path : str = str ( Path (credential_dir ) / const .OAUTH_FILENAME )
21
23
try :
22
- logging .info (f'Looking for { headers_file_path } "' )
23
- youtube_auth = YTMusic (headers_file_path )
24
- logging .info (f'Found { headers_file_path } "' )
25
- except (KeyError , AttributeError ):
26
- logging .info (f"Creating { const .HEADERS_FILE } file..." )
27
- youtube_auth = YTMusic (YTMusic .setup (filepath = headers_file_path ))
28
- logging .info (f'Created { headers_file_path } "' )
24
+ logging .info (f'Attempting authentication with: { oauth_file_path } ' )
25
+ youtube_auth = YTMusic (oauth_file_path )
26
+ logging .info (f'Authenticated with: { oauth_file_path } "' )
27
+ except JSONDecodeError :
28
+ logging .info (f"Creating file: { const .OAUTH_FILENAME } " )
29
+ ytmusicapi .setup_oauth (filepath = oauth_file_path , open_browser = True )
30
+ youtube_auth = YTMusic (oauth_file_path )
31
+ logging .info (f'Created: { oauth_file_path } "' )
29
32
30
33
31
34
@click .group ()
Original file line number Diff line number Diff line change 1
1
LIKE = "LIKE"
2
2
INDIFFERENT = "INDIFFERENT"
3
- HEADERS_FILE = "headers_auth .json"
3
+ OAUTH_FILENAME = "oauth .json"
4
4
UNKNOWN_ARTIST = "Unknown Artist"
You can’t perform that action at this time.
0 commit comments