17
17
18
18
19
19
def decrypt_cryptojs_aes (data ):
20
- encrypted_stores = data [' context' ][ ' dispatcher' ][ ' stores' ]
20
+ encrypted_stores = data [" context" ][ " dispatcher" ][ " stores" ]
21
21
_cs = data ["_cs" ]
22
22
_cr = data ["_cr" ]
23
23
24
- _cr = b"" .join (int .to_bytes (i , length = 4 , byteorder = "big" , signed = True ) for i in json .loads (_cr )["words" ])
24
+ _cr = b"" .join (
25
+ int .to_bytes (i , length = 4 , byteorder = "big" , signed = True )
26
+ for i in json .loads (_cr )["words" ]
27
+ )
25
28
password = hashlib .pbkdf2_hmac ("sha1" , _cs .encode ("utf8" ), _cr , 1 , dklen = 32 ).hex ()
26
29
27
30
encrypted_stores = b64decode (encrypted_stores )
@@ -30,12 +33,12 @@ def decrypt_cryptojs_aes(data):
30
33
encrypted_stores = encrypted_stores [16 :]
31
34
32
35
def EVPKDF (
33
- password ,
34
- salt ,
35
- keySize = 32 ,
36
- ivSize = 16 ,
37
- iterations = 1 ,
38
- hashAlgorithm = "md5" ,
36
+ password ,
37
+ salt ,
38
+ keySize = 32 ,
39
+ ivSize = 16 ,
40
+ iterations = 1 ,
41
+ hashAlgorithm = "md5" ,
39
42
) -> tuple :
40
43
"""OpenSSL EVP Key Derivation Function
41
44
Args:
@@ -74,7 +77,9 @@ def EVPKDF(
74
77
key , iv = key_iv [:keySize ], key_iv [keySize :final_length ]
75
78
return key , iv
76
79
77
- key , iv = EVPKDF (password , salt , keySize = 32 , ivSize = 16 , iterations = 1 , hashAlgorithm = "md5" )
80
+ key , iv = EVPKDF (
81
+ password , salt , keySize = 32 , ivSize = 16 , iterations = 1 , hashAlgorithm = "md5"
82
+ )
78
83
79
84
cipher = AES .new (key , AES .MODE_CBC , iv = iv )
80
85
plaintext = cipher .decrypt (encrypted_stores )
@@ -129,19 +134,19 @@ class YahooDailyReader(_DailyBaseReader):
129
134
"""
130
135
131
136
def __init__ (
132
- self ,
133
- symbols = None ,
134
- start = None ,
135
- end = None ,
136
- retry_count = 3 ,
137
- pause = 0.1 ,
138
- session = None ,
139
- adjust_price = False ,
140
- ret_index = False ,
141
- chunksize = 1 ,
142
- interval = "d" ,
143
- get_actions = False ,
144
- adjust_dividends = True ,
137
+ self ,
138
+ symbols = None ,
139
+ start = None ,
140
+ end = None ,
141
+ retry_count = 3 ,
142
+ pause = 0.1 ,
143
+ session = None ,
144
+ adjust_price = False ,
145
+ ret_index = False ,
146
+ chunksize = 1 ,
147
+ interval = "d" ,
148
+ get_actions = False ,
149
+ adjust_dividends = True ,
145
150
):
146
151
super ().__init__ (
147
152
symbols = symbols ,
@@ -225,10 +230,12 @@ def _read_one_data(self, url, params):
225
230
j = json .loads (re .search (ptrn , resp .text , re .DOTALL ).group (1 ))
226
231
227
232
if "_cs" in j and "_cr" in j :
228
- new_j = decrypt_cryptojs_aes (j ) # returns j["context"]["dispatcher"]["stores"]
233
+ new_j = decrypt_cryptojs_aes (
234
+ j
235
+ ) # returns j["context"]["dispatcher"]["stores"]
229
236
# from old code
230
237
231
- data = new_j [' HistoricalPriceStore' ]
238
+ data = new_j [" HistoricalPriceStore" ]
232
239
233
240
except KeyError :
234
241
msg = "No data fetched for symbol {} using {}"
0 commit comments