-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.js
85 lines (79 loc) · 2.4 KB
/
archive.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
Bitport.prototype.torrentTable = function(html) {
var table = [];
var children = $(html).find("#queue-items").find("tr").each(function(i, e) {
var rows = $(e).find("td");
var torrent = {};
var prop = 0;
rows.each(function(i, node) {
switch (node.className) {
case "td-name":
torrent.name = node.innerText;
prop++;
break;
case "td-weak":
torrent.size = node.innerText;
prop++;
break;
case "td-status":
torrent.status = node.innerText;
prop++;
break;
case "align-right td-folder":
torrent.dir = node.innerText;
prop++;
break;
case "td-remove":
torrent.remove = "https://bitport.io/" + $(node).find("a").attr("href");
prop++;
break;
}
});
if (prop > 0) {
table.push(torrent);
}
});
return table;
}
Bitport.prototype.getAddedTorrents = function() {
var _this = this;
return request({
url: "https://bitport.io/recapitulation"
})
.then(function(data, status, xhr) {
var torrents = _this.torrentTable(data);
_this.addedTorrents = torrents;
return true;
})
};
/*
Bitport.prototype.login=function(user,name){
var config = {
url:"https://bitport.io/login"
};
return request(config).then(function(data,status,xhr){
var token =$(data).find("#frm-signInForm-_token_").val();
var credentials={
url: "https://bitport.io/login?do=signInForm-submit",
data:{
email:"dahnny012@sharklasers",
password:"password123",
_token_:token
}
}
request(credentials).then(function(data,status,xhr){
console.log(data);
console.log(xhr.getResponseHeader('Set-Cookie'))
});
})
}
*/
Bitport.prototype.removeAddedTorrent = function(index) {
if (index > this.addedTorrents.length) {
console.log("Index not in range");
return;
}
var target = this.addedTorrents[index];
return request({
url: target.remove
});
}