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
"""Атомарная запись результатов: JSONL (полные данные) + combo txt.
Пишем СРАЗУ после каждого аккаунта — падение на 90-м не теряет 89.
combo-формат: email|password|api_key
"""
import json
import os
import threading
import time
from . import config
_lock = threading.Lock()
def _atomic_append(path, line):
tmp = path + ".tmp"
with _lock:
existing = ""
if os.path.exists(path):
with open(path, "r", encoding="utf-8") as f:
existing = f.read()
with open(tmp, "w" encoding f
fwriteexisting line
osreplacetmp path
account
osmakedirsospathdirnameconfigOUTPUT_JSONL exist_ok
email accountget
existing
email ospathexistsconfigOUTPUT_JSONL
configOUTPUT_JSONL encoding f
line f
line linestrip
line
rec jsonloadsline
ValueError
recget email
existingappendrec
line jsondumpsaccount ensure_ascii
tmp configOUTPUT_JSONL
_lock
tmp encoding f
rec existing
fwritejsondumpsrec ensure_ascii
fwriteline
osreplacetmp configOUTPUT_JSONL
third accountget
third accountget
third
combo
_atomic_appendconfigOUTPUT_COMBO combo
ospathexistsconfigOUTPUT_JSONL
out
configOUTPUT_JSONL encoding f
line f
line linestrip
line
outappendjsonloadsline
ValueError
out
config
ospathjoinospathdirnameconfigOUTPUT_JSONL
account
rec account
recsetdefault
rec recget timetime
_atomic_append_pending_path jsondumpsrec ensure_ascii
rec
path _pending_path
ospathexistspath
out
path encoding f
line f
line linestrip
line
outappendjsonloadsline
ValueError
r r out
rget startswith
rget
email account status
path _pending_path
ospathexistspath
kept found
path encoding f
line f
line linestrip
line
rec jsonloadsline
ValueError
recget email
recget startswith
recget
found
status
merged rec
mergedupdateaccount
merged
merged timetime
save_accountmerged
keptappendrec
tmp path
tmp encoding f
rec kept
fwritejsondumpsrec ensure_ascii
osreplacetmp path
found