forked from tsoernes/leechflix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiv.js
54 lines (50 loc) · 1.87 KB
/
div.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
var info = scraperhelper.extractInfoFromName(name);
// @TODO add files to a different view if they do not have info or image
var searchTerm = {terms: info.title, year: info.year, specialChars: true};
asyncTasks.push(function(callback){
getOmdbInfo(searchTerm, function (err, res) {
if (err) {
var isCollection = true;
info.rlsDetails = name;
omdbInfo = {title: "Not found in IMDb", year: "", runtime: "", actors: "", plot: "", imdb: {id: "", rating: 10, votes: 0}, poster: "../static/folder2.jpg"};
} else {
omdbInfo = res;
var isCollection = false;
omdbInfo.genres = omdbInfo.genres.map(function(s) {return ' '+s;});
omdbInfo.genres[0] = omdbInfo.genres[0].substring(1);
}
var movieInfo = {
isCollection: isCollection,
title: omdbInfo.title,
year: omdbInfo.year,
release: [{
rlsDetails: info.rlsDetails,
detailsUrl: detailsUrl,
torrentUrl: torrentUrl,
size: size,
seeders: seeders,
leechers: leechers
}],
runtime: omdbInfo.runtime,
genres: omdbInfo.genres,
actors: omdbInfo.actors,
plot: omdbInfo.plot,
imdbId: omdbInfo.imdb.id,
imdbRating: omdbInfo.imdb.rating,
imdbVotes: omdbInfo.imdb.votes,
imgUrl: omdbInfo.poster
}
var added = false;
for (var j=0; j<results.length; j++) {
if (results[j].imdbId == movieInfo.imdbId) {
results[j].release.push(movieInfo.release[0]);
added = true;
break;
}
}
if (!added) {
results.push(movieInfo);
}
callback();
});
});