File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def read_file(fname):
17
17
18
18
setup (
19
19
name = pkg_name ,
20
- version = "0.1.2.3 " ,
20
+ version = "0.1.2.4 " ,
21
21
author = "Akash R Chandran" ,
22
22
author_email = "chandranrakash@gmail.com" ,
23
23
description = "A command line tool to fetch lyrics from spotify and save it to lrc file. It can fetch both synced and unsynced lyrics from spotify. " ,
Original file line number Diff line number Diff line change 1
1
import hashlib
2
2
import hmac
3
3
import math
4
+ import requests
4
5
5
6
# thanks to https://github.com/glomatico/votify/blob/main/votify/totp.py
6
7
class TOTP :
7
8
def __init__ (self ) -> None :
8
- self .secret = b"46765510475331268151846763111112875241781186186871271119692"
9
- self .version = 17
9
+ self .secret , self .version = self .get_secret_version ()
10
10
self .period = 30
11
11
self .digits = 6
12
12
@@ -25,4 +25,14 @@ def generate(self, timestamp: int) -> str:
25
25
| (hmac_result [offset + 3 ] & 0xFF )
26
26
)
27
27
28
- return str (binary % (10 ** self .digits )).zfill (self .digits )
28
+ return str (binary % (10 ** self .digits )).zfill (self .digits )
29
+
30
+ def get_secret_version (self ) -> tuple [str , int ]:
31
+ req = requests .get ("https://raw.githubusercontent.com/Thereallo1026/spotify-secrets/refs/heads/main/secrets/secrets.json" )
32
+ if req .status_code != 200 :
33
+ raise ValueError ("Failed to fetch TOTP secret and version." )
34
+ data = req .json ()[- 1 ]
35
+ ascii_codes = [ord (c ) for c in data ['secret' ]]
36
+ transformed = [val ^ ((i % 33 ) + 9 ) for i , val in enumerate (ascii_codes )]
37
+ secret_key = "" .join (str (num ) for num in transformed )
38
+ return bytes (secret_key , 'utf-8' ), data ['version' ]
You can’t perform that action at this time.
0 commit comments