forked from bill-ahmed/qbit-matUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_data.js
350 lines (338 loc) · 13.8 KB
/
sample_data.js
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
var GetRandomInt = require('./utils.js').GetRandomInt;
// Maximum upload/download speeds for mock data
const MIN_SPEED = 0;
const MAX_SPEED = 90000000;
// Max/Min file sizes possible
const MIN_FILE_SIZE = 0;
const MAX_FILE_SIZE = 900000000000;
// Min and max ETA seconds
const MIN_ETA_SIZE = 0;
const MAX_ETA_SIZE = 28800; // 8 hours
// Some possible states a torrent can be in
const torrent_states = [
'forcedUP', 'error', 'pausedUP', 'pausedDL', 'queuedUP', 'uploading',
'stalledUP', 'downloading', 'stalledDL', 'moving', 'checkingResumeData',
'metaDL', 'allocating', 'checkingUP'
];
var RID = -1; // For /sync/maindata endpoint
var states_length = torrent_states.length - 1;
function getRandomId() {
return Math.random().toString(36).substring(15);
}
/**Mock data for /sync/maindata endpoint */
function GetMainData(){
RID += 1;
let result =
{
"categories": {},
"full_update": true,
"rid": RID,
"server_state": {
"alltime_dl": 134924863044,
"alltime_ul": 169885275053,
"average_time_queue": 3787,
"connection_status": "connected",
"dht_nodes": GetRandomInt(0, 400),
"dl_info_data": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"dl_info_speed": GetRandomInt(MIN_SPEED, MAX_SPEED),
"dl_rate_limit": GetRandomInt(MIN_SPEED, 10000),
"free_space_on_disk": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE * 100),
"global_ratio": "1.25",
"queued_io_jobs": 0,
"queueing": true,
"read_cache_hits": "26.34",
"read_cache_overload": "0",
"refresh_interval": 1500,
"total_buffers_size": 66060288,
"total_peer_connections": 10,
"total_queued_size": 0,
"total_wasted_session": 0,
"up_info_data": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"up_info_speed": GetRandomInt(MIN_SPEED, MAX_SPEED),
"up_rate_limit": GetRandomInt(MIN_SPEED, 10000),
"use_alt_speed_limits": GetRandomInt(1, 4) % 2 === 0,
"write_cache_overload": "0"
},
"torrents_removed": ["0daea5cece5"],
"torrents": {
"03b82ec41283e57ffb5a284e9a7773199dddc72a": {
"added_on": 1561931538,
"amount_left": 0,
"auto_tmm": false,
"category": "",
"completed": 6211419,
"completion_on": 18500,
"dl_limit": -1,
"dlspeed": GetRandomInt(MIN_SPEED, MAX_SPEED),
"downloaded": 7262278,
"downloaded_session": 0,
"eta": 8640000,
"f_l_piece_prio": false,
"force_start": false,
"last_activity": 1583846813,
"magnet_uri": "magnet #0",
"max_ratio": -1,
"max_seeding_time": -1,
"name": "The Quick Brown Fox",
"num_complete": 33,
"num_incomplete": 1,
"num_leechs": 0,
"num_seeds": 0,
"priority": 0,
"progress": Math.random(),
"ratio": 0.2930033799312006,
"ratio_limit": -2,
"save_path": "D:/",
"seeding_time_limit": -2,
"seen_complete": 1583845906,
"seq_dl": false,
"size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"state": torrent_states[GetRandomInt(0, states_length)],
"super_seeding": false,
"tags": "",
"time_active": 5328405,
"total_size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"tracker": "some tracker #0",
"up_limit": -1,
"uploaded": 2127872,
"uploaded_session": 0,
"upspeed": GetRandomInt(MIN_SPEED, MAX_SPEED)
},
"0daea5cece5": {
"added_on": 1574566015,
"amount_left": 0,
"auto_tmm": false,
"category": "",
"completed": 209869298,
"completion_on": 18000,
"dl_limit": -1,
"dlspeed": GetRandomInt(MIN_SPEED, MAX_SPEED),
"downloaded": 210629655,
"downloaded_session": 0,
"eta": GetRandomInt(MIN_ETA_SIZE, MAX_ETA_SIZE),
"f_l_piece_prio": false,
"force_start": true,
"last_activity": 1583690488,
"magnet_uri": "magnet_uri",
"max_ratio": -1,
"max_seeding_time": -1,
"name": "Some.show.#1.with.super.loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong name",
"num_complete": 18,
"num_incomplete": 1,
"num_leechs": 0,
"num_seeds": 0,
"priority": 0,
"progress": Math.random(),
"ratio": 1.0442750048657679,
"ratio_limit": -2,
"save_path": "A:/Movies & TV/Some show/",
"seeding_time_limit": -2,
"seen_complete": 1580860752,
"seq_dl": false,
"size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"state": torrent_states[GetRandomInt(0, states_length)],
"super_seeding": false,
"tags": "",
"time_active": 718637,
"total_size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"tracker": "https some tracker",
"up_limit": -1,
"uploaded": 219955284,
"uploaded_session": 0,
"upspeed": GetRandomInt(MIN_SPEED, MAX_SPEED)
},
"0f4eefe81227d7211b31a500144fe6a48b5b7d46": {
"added_on": 1574566016,
"amount_left": 0,
"auto_tmm": false,
"category": "",
"completed": 310964698,
"completion_on": 1574566096,
"dl_limit": -1,
"dlspeed": GetRandomInt(MIN_SPEED, MAX_SPEED),
"downloaded": 311199215,
"downloaded_session": 0,
"eta": GetRandomInt(MIN_ETA_SIZE, MAX_ETA_SIZE),
"f_l_piece_prio": false,
"force_start": false,
"last_activity": 1583690567,
"magnet_uri": "magnet",
"max_ratio": -1,
"max_seeding_time": -1,
"name": "Another show #2 with decently-sized name",
"num_complete": 12,
"num_incomplete": 1,
"num_leechs": 0,
"num_seeds": 0,
"priority": 0,
"progress": Math.random(),
"ratio": 0.5514229655110152,
"ratio_limit": -2,
"save_path": "B:/TV/Some show #2/",
"seeding_time_limit": -2,
"seen_complete": 1583660691,
"seq_dl": false,
"size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"state": torrent_states[GetRandomInt(0, states_length)],
"super_seeding": false,
"tags": "",
"time_active": 876906,
"total_size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"tracker": "https tracker",
"up_limit": -1,
"uploaded": 171602394,
"uploaded_session": 0,
"upspeed": GetRandomInt(MIN_SPEED, MAX_SPEED)
},
"16ce8f1b00e2b0e0fbc4dc8b46e629c8cd2ef0e1": {
"added_on": 1555812938,
"amount_left": 0,
"auto_tmm": false,
"category": "",
"completed": 966283000,
"completion_on": 1555813080,
"dl_limit": -1,
"dlspeed": GetRandomInt(MIN_SPEED, MAX_SPEED),
"downloaded": 966470211,
"downloaded_session": 0,
"eta": GetRandomInt(MIN_ETA_SIZE, MAX_ETA_SIZE),
"f_l_piece_prio": false,
"force_start": true,
"last_activity": 1583770394,
"magnet_uri": "another magnet",
"max_ratio": -1,
"max_seeding_time": -1,
"name": "Ubuntu Debian 18.04 LTS",
"num_complete": 14,
"num_incomplete": 1,
"num_leechs": 0,
"num_seeds": 0,
"priority": 0,
"progress": Math.random(),
"ratio": 1.1216271900179653,
"ratio_limit": -2,
"save_path": "C:/Downloads/Images/",
"seeding_time_limit": -2,
"seen_complete": 1566641377,
"seq_dl": false,
"size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"state": torrent_states[GetRandomInt(0, states_length)],
"super_seeding": false,
"tags": "",
"time_active": 10218680,
"total_size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"tracker": "https my tracker #3",
"up_limit": -1,
"uploaded": 1084019267,
"uploaded_session": 0,
"upspeed": GetRandomInt(MIN_SPEED, MAX_SPEED)
}
}
};
_addTorrentEntriesToMockData(1000, result.torrents);
return result;
}
/** Given some mock MainData, add num_entries copies of some data to list of torrents
* @param num_entries The number of entries to add
* @param data The raw data to append to
*/
function _addTorrentEntriesToMockData(num_entries, data) {
let key = "0daea5cece5555";
let name = "Ubuntu LTS ";
let savePath = "A:/Images/";
for(let i = 0; i < num_entries; i++) {
data[key + i] =
{
"added_on": 1574566015,
"amount_left": 0,
"auto_tmm": false,
"category": "",
"completed": 209869298,
"completion_on": 1574566120,
"dl_limit": -1,
"dlspeed": GetRandomInt(MIN_SPEED, MAX_SPEED),
"downloaded": 210629655,
"downloaded_session": 0,
"eta": GetRandomInt(MIN_ETA_SIZE, MAX_ETA_SIZE),
"f_l_piece_prio": false,
"force_start": GetRandomInt(0,1) % 2 === 0,
"last_activity": 1583690488,
"magnet_uri": "magnet_uri",
"max_ratio": -1,
"max_seeding_time": -1,
"name": name + i,
"num_complete": 18,
"num_incomplete": 1,
"num_leechs": 0,
"num_seeds": 0,
"priority": 0,
"progress": Math.random(),
"ratio": 1.0442750048657679,
"ratio_limit": -2,
"save_path": savePath + name + i,
"seeding_time_limit": -2,
"seen_complete": 1580860752,
"seq_dl": false,
"size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"state": torrent_states[GetRandomInt(0, states_length)],
"super_seeding": false,
"tags": "",
"time_active": 718637,
"total_size": GetRandomInt(MIN_FILE_SIZE, MAX_FILE_SIZE),
"tracker": "https some tracker",
"up_limit": -1,
"uploaded": 219955284,
"uploaded_session": 0,
"upspeed": GetRandomInt(MIN_SPEED, MAX_SPEED)
}
}
}
/** Mock object to represent this user's preference
* NOTE: This object is imcomplete; for more info: https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-Documentation#get-qbittorrent-preferences
*/
function GetUserPreferences() {
return (
{
"locale":"ru_RU",
"save_path":"C:/Users/Dayman/Downloads",
"temp_path_enabled":false,
"temp_path":"C:/Users/Dayman/Documents/Downloads/temp",
"scan_dirs":["D:/Browser Downloads"],
"download_in_scan_dirs":[false],
"export_dir_enabled":false,
"export_dir":"",
"autorun_enabled":false,
"autorun_program":"",
"preallocate_all":false,
"queueing_enabled":true,
"max_active_downloads":2,
"max_active_torrents":200,
"max_active_uploads":200,
"listen_port":31498,
"upnp":false,
"dl_limit":3072,
"up_limit":0,
"max_connec":500,
"max_connec_per_torrent":100,
"max_uploads_per_torrent":15,
"schedule_from_hour": 8,
"schedule_from_min": 0,
"schedule_to_hour": 20,
"schedule_to_min": 0,
"scheduler_days": 2,
"scheduler_enabled": false,
"alt_dl_limit": 10240,
"alt_up_limit": 10240,
}
);
}
function GetAppVersion() {
return "v4.1.3";
}
function GetAPIVersion() {
return "2.0";
}
module.exports.GetMainData = GetMainData;
module.exports.GetUserPreferences = GetUserPreferences;
module.exports.GetAppVersion = GetAppVersion;
module.exports.GetAPIVersion = GetAPIVersion;