forked from Nandaka/PixivUtil2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PixivRanking.py
55 lines (44 loc) · 1.48 KB
/
PixivRanking.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
50
51
52
53
54
55
import json
from PixivException import PixivException
class PixivRanking:
mode = ""
curr_page = 0
next_page = None
prev_page = None
curr_date = ""
next_date = None
prev_date = None
rank_total = 0
contents = list()
filters = None
def __init__(self, js_str, filters):
js_data = json.loads(js_str)
self.mode = js_data["mode"]
self.curr_date = js_data["date"]
self.next_date = js_data["next_date"]
self.prev_date = js_data["prev_date"]
self.curr_page = js_data["page"]
self.next_page = js_data["next"]
self.prev_page = js_data["prev"]
self.rank_total = js_data["rank_total"]
self.contents = js_data["contents"]
self.filters = filters
if self.filters is not None:
self.filter_contents()
def filter_contents(self):
for content in self.contents:
for filter_str in self.filters:
if content["illust_content_type"][filter_str]:
self.contents.remove(content)
break
class PixivNewIllust:
last_id = 0
images = None
type_mode = None
def __init__(self, js_str, type_mode):
js_data = json.loads(js_str)
if bool(js_data["error"]):
raise PixivException(js_data["message"], errorCode=PixivException.OTHER_ERROR)
self.last_id = js_data["body"]["lastId"]
self.images = js_data["body"]["illusts"]
self.type_mode = type_mode