-
Notifications
You must be signed in to change notification settings - Fork 45
/
kissasian.js
190 lines (159 loc) · 5.67 KB
/
kissasian.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
// python -m http.server
// http://localhost:8000/kissasian.js
// CONFIG
var siteName = "Kissasian"
var rootUrl = 'http://kissasian.com'
var URL = window.location.origin
// END CONFIG
var episodeLinks = $('table.listing a').map(function(i,el) { return $(el).attr('href'); });
var episodeNames = $('table.listing a').map(function(i,el) { return $.trim( $(el).html() ); });
$.ajaxSetup({async:false});
$.getScript(rootUrl + "/Scripts/asp.js");
// --------
// HACKS
var _0xea24 = ["\x6B\x72\x73\x6B\x31", "\x75\x68\x38\x61\x32\x44\x4E\x6A", "\x6B\x72\x73\x6B", "\x70\x73\x59\x73\x7A\x70\x33\x7A", "\x6B\x72\x73\x6B\x32", "\x7A\x75\x6E\x55\x76\x48\x33\x66"]; window[_0xea24[0]] = _0xea24[1]; window[_0xea24[2]] = _0xea24[3]; window[_0xea24[4]] = _0xea24[5]
var jsS = [
"/Scripts/common.js",
"/Scripts/aes.js",
"/Scripts/sha256.min.js",
"/Scripts/kissenc.min.js?v=2"
];
console.log('Loading scripts ...');
for (var i=0; i < jsS.length; i++){
console.log(jsS[i]);
$.getScript(rootUrl + jsS[i]);
}
// END HACKS
// ----------
console.log('Starting ' + siteName + ' Batch Downloader script...');
var startEpisode;
do {
startEpisode = Number(prompt("Enter episode (listing) number you want to start from", defaultText="1"));
if(startEpisode <= 0 || startEpisode > episodeLinks.length) {
alert("Episode number entered must be greater than 0 and lesser than total number of eps");
} else {
break;
}
} while(true);
var endEpisode;
do {
endEpisode = Number(prompt("Enter episode (listing) number you want to end at", defaultText="2"));
if(endEpisode <= 0 || endEpisode > episodeLinks.length || endEpisode < startEpisode) {
alert("Episode number entered must be greater than 0 and lesser than total number of eps");
} else {
break;
}
} while(true);
var videoQuality = prompt(
"Enter video quality preferences for the download. Example - '720,480'\nThis first looks for 720p, if 720 is not available, it picks 480.",
defaultText="720,480"
);
if (videoQuality == null){
videoQuality = "720,480,360";
}
var opOptions = prompt(
"How do you want output to be?\n0 = simple list of links\n1 = List with filenames (for wget, aria2 helper scripts)\n2 = HTML page with links",
defaultText="0"
);
if (opOptions == null){
opOptions = "0";
}
var i;
var linkStr = "";
console.log('Starting to fetch links..');
for (i = (episodeLinks.length - startEpisode); i >= (episodeLinks.length - endEpisode); i--) {
console.log('Fetching listing ' + (episodeLinks.length - i) + ' [' + episodeNames[i] + ']');
jQuery.ajax({
url: URL + episodeLinks[i],
tryCount : 0,
retryLimit : 3,
success: function(result) {
var $result = eval($(result));
// dynamic javascript
var stringStart = result.search("var wra");
if (stringStart != -1){
var stringEnd = result.search("document.write");
var javascriptToExecute = result.substring(stringStart, stringEnd);
// console.log(javascriptToExecute)
eval(javascriptToExecute);
// console.log(wra);
}
// end dynamic javascript
var data = $(result).find("#divDownload"); // download data
if (data == null || data == "" || data.length == 0){ // captcha maybe
console.log("Captcha detected at " + URL + episodeLinks[i]);
prompt("Captcha detected. Solve it by opening the link below in a new tab. After solving, press OK.",
defaultText=URL + episodeLinks[i]);
this.tryCount++;
$.ajax(this); // retry
return;
}
// after above as dont want many episodeN divs
$("body").append('<div id="episode' + i + '" style="display: none;"></div>')
$('#episode' + i).append(wra);
var links = $('#episode' + i).find("a");
// console.log(links);
var quals = videoQuality.split(',');
var found = false;
// pick download
for (var j=0; j<quals.length; j++){
// check if the format exists or not
if (found)
return;
$.each(links, function(index, el) {
// console.log(el);
if ( $(el).html().search(quals[j]) > -1 ){
long_url = $(el).attr('href');
name = getDownloadName(episodeNames[i], $(el).html());
if (opOptions == "1"){
linkStr += encodeURI(long_url) + " " + name + "\n";
} else if (opOptions == "2"){
linkStr += '<a href="' + long_url + '" download="' + name + '">' + name + '</a><br>';
} else {
linkStr += long_url + "\n";
}
found = true;
// console.log('Episode ' + (episodeLinks.length - i));
console.log(long_url);
}
});
}
// successful response processed
},
error: function(xhr, textStatus, errorThrown ) {
console.log(textStatus)
// http://stackoverflow.com/questions/10024469/
this.tryCount++;
if (this.tryCount <= this.retryLimit) {
//try again
console.log('Retrying..');
$.ajax(this);
}
return;
},
async: false,
script: true
});
}
console.log('Opening list of links')
download("links." + ((opOptions == '2') ? 'html' : 'txt'), (opOptions == '2') ? 'text/html' : 'text/plain', linkStr)
// http://ourcodeworld.com/articles/read/189/how-to-create-a-file-and-generate-a-download-with-javascript-in-the-browser-without-a-server
function download(filename, datatype, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:' + datatype + ';charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
// element.setAttribute('target', '_blank');
// ^^ problems with safari
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
function sleep(miliseconds) {
var currentTime = new Date().getTime();
while (currentTime + miliseconds >= new Date().getTime()) {
}
}
function getDownloadName(epName, dl){
return (epName + "__" + dl).replace(/\s/g, '_');
}