/
Funimation.py
51 lines (39 loc) · 1.67 KB
/
Funimation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import requests
base_url = "https://prod-api-funimationnow.dadcdigital.com/api/"
funi_recs = "fun/modules/?territory=en-US&inclusion=Regions|US&slug=pi-schedule-shows&user_id=d812ecb2-8cbe-11e7-861d-22000b56051a&session_id=d812f2c0-8cbe-11e7-861d-22000b56051a"
my_queue = "source/funimation/queue"#/?flat=true"
class Funimation(object):
def __init__(self, username=""):
self.username = username
self.auth_token = None
self.csrftoken = None
def info_for_title(self, title):
endpoint = "source/catalog/title/{}".format(title)
url = base_url + endpoint
r = requests.get(url)
json_entries = r.json()
print(json_entries)
def login(self, username, password):
endpoint = "auth/login/"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
'Territory': 'US'
}
r = requests.post(base_url + endpoint, data = {'username':username,'password':password}, headers = headers, verify=False)
print(r.headers)
print("------------------")
self.csrftoken = r.headers['Set-Cookie'].split(';')[0].split('=')[1]
return(r.json())#["token"]
#return auth_token
def get_my_queue(self, auth_token = None):
if auth_token:
self.auth_token = auth_token
if self.auth_token:
headers = {"Authorization":"Token " + self.auth_token}#, "x-csrftoken":self.csrftoken, "territory":"US", "accept-language":"en-US,en;q=0.8"}
r = requests.get(base_url + my_queue, headers = headers, verify=False)
return r.json()
else:
return "No auth token, could not proceed with getting Funimation anime queue"
if __name__ == '__main__':
funi = Funimation()
#funi.get_my_queue()