-
Notifications
You must be signed in to change notification settings - Fork 6
/
models.py
172 lines (159 loc) · 6.8 KB
/
models.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
boards = {
# Japanese Culture
"a": ["Anime & Manga", "favicon-ws.ico", "variables-ws.css"],
"c": ["Anime/Cute", "favicon-ws.ico", "variables-ws.css"],
"w": ["Anime/Wallpapers", "favicon-ws.ico", "variables-ws.css"],
"m": ["Mecha", "favicon-ws.ico", "variables-ws.css"],
"cgl": ["Cosplay & EGL", "favicon-ws.ico", "variables-ws.css"],
"cm": ["Cute/Male", "favicon-ws.ico", "variables-ws.css"],
"f": ["Flash", "favicon.ico", "variables.css"],
"n": ["Transportation", "favicon-ws.ico", "variables-ws.css"],
"jp": ["Otaku Culture", "favicon-ws.ico", "variables-ws.css"],
# Video Games
"v": ["Video Games", "favicon-ws.ico", "variables-ws.css"],
"vg": ["Video Games Generals", "favicon-ws.ico", "variables-ws.css"],
"vp": ["Pokemon", "favicon-ws.ico", "variables-ws.css"],
"vr": ["Retro Games", "favicon-ws.ico", "variables-ws.css"],
# Interests
"co": ["Comics & Cartoons", "favicon-ws.ico", "variables-ws.css"],
"g": ["Technology", "favicon-ws.ico", "variables-ws.css"],
"tv": ["Television & Film", "favicon-ws.ico", "variables-ws.css"],
"k": ["Weapons", "favicon-ws.ico", "variables-ws.css"],
"o": ["Auto", "favicon-ws.ico", "variables-ws.css"],
"an": ["Animals & Nature", "favicon-ws.ico", "variables-ws.css"],
"tg": ["Traditional Games", "favicon-ws.ico", "variables-ws.css"],
"sp": ["Sports", "favicon-ws.ico", "variables-ws.css"],
"asp": ["Alternative Sports", "favicon-ws.ico", "variables-ws.css"],
"sci": ["Science & Math", "favicon-ws.ico", "variables-ws.css"],
"his": ["History & Humanities", "favicon-ws-ico", "variables-ws.css"],
"int": ["International", "favicon-ws.ico", "variables-ws.css"],
"out": ["Outdoors", "favicon-ws.ico", "variables-ws.css"],
"toy": ["Toys", "favicon-ws.ico", "variables-ws.css"],
# Creative
"i": ["Oekaki", "favicon.ico", "variables.css"],
"po": ["Papercraft & Origami", "favicon-ws.ico", "variables-ws.css"],
"p": ["Photography", "favicon-ws.ico", "variables-ws.css"],
"ck": ["Food & Cooking", "favicon-ws.ico", "variables-ws.css"],
"ic": ["Artwork/Critique", "favicon.ico", "variables.css"],
"wg": ["Wallpapers/General", "favicon.ico", "variables.css"],
"lit": ["Literature", "favicon-ws.ico", "variables-ws.css"],
"mu": ["Music", "favicon-ws.ico", "variables-ws.css"],
"fa": ["Fashion", "favicon-ws.ico", "variables-ws.css"],
"3": ["3DCG", "favicon-ws.ico", "variables-ws.css"],
"gd": ["Graphic Design", "favicon-ws.ico", "variables-ws.css"],
"diy": ["Do-It-Yourself", "favicon-ws.ico", "variables-ws.css"],
"wsg": ["Worksafe GIF", "favicon-ws.ico", "variables-ws.css"],
"qst": ["Quests", "favicon-ws.ico", "variables-ws.css"],
# Other
"biz": ["Business & Finance", "favicon-ws.ico", "variables-ws.css"],
"trv": ["Travel", "favicon-ws.ico", "variables-ws.css"],
"fit": ["Fitness", "favicon-ws.ico", "variables-ws.css"],
"x": ["Paranormal", "favicon-ws.ico", "variables-ws.css"],
"adv": ["Advice", "favicon-ws.ico", "variables-ws.css"],
"lgbt": ["LGBT", "favicon-ws.ico", "variables-ws.css"],
"mlp": ["Pony", "favicon-ws.ico", "variables-ws.css"],
"news": ["Current News", "favicon-ws.ico", "variables-ws.css"],
"wsr": ["Worksafe Requests", "favicon-ws.ico", "variables-ws.css"],
"vip": ["Very Important Posts", "favicon-ws.ico", "variables-ws.css"],
# Misc.
"b": ["Random", "favicon.ico", "variables.css"],
"r9k": ["ROBOT9001", "favicon.ico", "variables.css"],
"pol": ["Politically Incorrect", "favicon.ico", "variables.css"],
"bant": ["International/Random", "favicon.ico", "variables.css"],
"soc": ["Cams & Meetups", "favicon.ico", "variables.css"],
"s4s": ["Shit 4chan Says", "favicon.ico", "variables.css"],
# Adult
"s": ["Beautiful Women", "favicon.ico", "variables.css"],
"hc": ["Hardcore", "favicon.ico", "variables.css"],
"hm": ["Handsome Men", "favicon.ico", "variables.css"],
"h": ["Hentai", "favicon.ico", "variables.css"],
"e": ["Ecchi", "favicon.ico", "variables.css"],
"u": ["Yuri", "favicon.ico", "variables.css"],
"d": ["Hentai/Alternative", "favicon.ico", "variables.css"],
"y": ["Yaoi", "favicon.ico", "variables.css"],
"t": ["Torrents", "favicon.ico", "variables.css"],
"hr": ["High Resolution", "favicon.ico", "variables.css"],
"gif": ["Adult GIF", "favicon.ico", "variables.css"],
"aco": ["Adult Cartoons", "favicon.ico", "variables.css"],
"r": ["Adult Requests", "favicon.ico", "variables.css"],
}
class Params():
verbose = False
preserve = False
total_retries = 5
total_posts = None
path_to_download = './'
use_db = False
archived = False
archived_only = False
def __init__(self, *args, **kwargs):
self.__instance = None
super().__init__(*args, **kwargs)
def __call__(self, *args, **kwargs):
if self.__instance is None:
self.__instance = super().__call__(*args, **kwargs)
return self.__instance
else:
return self.__instance
class Reply:
def __init__(self, post):
self.no = 0
self.resto = 0
self.sticky = 0
self.closed = 0
self.now = ""
self.time = 0
self.name = "Anonymous"
self.trip = ""
self.id = ""
self.capcode = ""
self.country = "XX"
self.country_name = ""
self.troll_country = ""
self.sub = ""
self.com = ""
self.tim = 0
self.filename = ""
self.ext = ""
self.fsize = 0
self.md5 = ""
self.w = 0
self.h = 0
self.tn_w = 0
self.tn_h = 0
self.filedeleted = 0
self.spoiler = 0
self.custom_spoiler = 0
self.replies = 0
self.images = 0
self.bumplimit = 0
self.imagelimit = 0
self.tag = ""
self.semantic_url = ""
self.since4pass = 0
self.unique_ips = 0
self.m_img = 0
self.archived = 0
self.archived_on = 0
self.tail_size = 0
self.img_src = ""
self.board = ""
self.custom_id = str(post["no"]) + str(post["time"])
self.preserved = False
allowed_keys = list(self.__dict__.keys())
self.__dict__.update((key, value) for key, value in post.items()
if key in allowed_keys)
# Raise execption on rejected keys
rejected_keys = set(post.keys()) - set(allowed_keys)
if rejected_keys:
print("Warning: invalid reply keys: {}".format(rejected_keys))
class Thread:
def __init__(self, tid, board, url):
self.tid = tid
self.board = board
self.url = url
self.set_board()
def set_board(self):
self.board_name = boards[self.board][0]
self.fav = boards[self.board][1]
self.css = boards[self.board][2]