-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_other_data.py
40 lines (31 loc) · 1.26 KB
/
get_other_data.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
from trakt_engine import BASE_URL, CORE
from urllib.parse import urljoin
import os
def all_time_stats():
def get_comments():
page = 1
comments = 0
while True:
url = urljoin(BASE_URL, f'users/{os.environ["username"]}/comments/all/all?include_replies=False&page={page}')
data = CORE._handle_request(url=url, method='get')
if not data:
break
comments += len(data)
page += 1
return comments
url = urljoin(BASE_URL, f'users/{os.environ["username"]}/stats')
data = CORE._handle_request(url=url, method='get')
plays : int = data['movies']['plays'] + data['episodes']['plays']
hours : float = round(((data['movies']['minutes'] + data['episodes']['minutes']) / 60), 0)
collected : int = data['movies']['collected'] + data['episodes']['collected']
ratings : int = data['ratings']['total']
lists : int = len(CORE._handle_request(url=urljoin(BASE_URL, f'users/{os.environ["username"]}/lists'), method='get'))
comments : int = get_comments()
return {
'plays': plays,
'hours': hours,
'collected': collected,
'ratings': ratings,
'lists': lists,
'comments': comments
}