-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovies.js
151 lines (117 loc) · 3.3 KB
/
movies.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
var c = require('./common.js');
var log = c.log;
var warn = c.warn;
if (process.argv.length !== 3) {
log("argument required : config file");
return;
}
var configFile = process.argv[2];
log("loading config. file '" + configFile + "' ...");
var config = require('./config.js').new(configFile, true);
config.setIfEmpty('playerPath', 'C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe');
var store = require('./store.js').new(
config.get('storeCache'),
config.get('videoDirs')
);
store.readStore(function(read, error) {
if (error) { return warn(error); }
log("loaded store from file (" + read + " movies)");
//store.loadFromFiles(function() { });
//store.startResolving(true);
var server = require('./server.js').new(
config.get('serverPort'),
store,
config
);
server.start(function(port) {
log("server ready on http://localhost:" + port + "/");
});
});
/*
var scrapVideos = function(source, storeFile) {
var fs = require('fs');
store.readFiles(source, function(errors, dir, videos) {
if (errors) {
warn(errors)
} else {
log("found : " + videos.length);
var data = JSON.stringify(videos, null, 4);
fs.writeFile(storeFile, data, "utf8", function(error) {
if (error) {
warn(error);
} else {
log("written:" + storeFile);
log("--------------");
}
});
}
//log("done.");
});
};
scrapVideos('E:\\Video\\Films\\Films A VOIR', '.films_voir');
scrapVideos('E:\\Video\\Films\\Films VUS', '.films_vus');
*/
/*
var retryNotFound = false;
var resolveProgress = function(movie, waiting, httpHits, notFound, errors) {
log(
" - resolve : '" + (movie ? movie.title : "null") +
"'. waiting:" + waiting +
" httpHits:" + httpHits +
" notFound:" + notFound +
" errors:" + errors
);
};
var doSearch = function(index, store) {
var query = process.argv[2];
var results = index.query(query);
log(" ");
log("query='" + query + "'");
for (var i=0, l=results.length; i<l; ++i) {
var r = results[i];
var m = store.getMovieBySafeId(r.id);
log(
"res: " +
m.fileTitle + " (" + m.title + ")" +
" [" + (Math.round(r.score*10)/10) + "]"
);
}
};
store.readStore(function(read, error) {
if (error) { return warn(error); }
log("loaded store (" + read + ")");
store.loadFromFiles(function(errors) {
if (errors) { return warn(errors); }
log("loaded '" + this.movies.length + "' movies");
store.writeStore(function(written, error) {
if (error) { return warn(error); }
log("wrote store (" + written + ")");
store.imdbResolveAll(function(stats, errors) {
if (errors) { warn(errors); }
log(
"resolved movies from Imdb (" +
stats.hits + " requests, " +
stats.missed + " not found, " +
stats.errors + " errors)"
);
store.writeStore(function(written, error) {
if (error) { return warn(error); }
log("wrote store (" + written + ")");
var index = require('./indexer.js').new();
store.forMovies(function(m) {
index.addDoc(m.safeId, m.fileTitle + " " + m.title);
}, function(total) {
log("added movies to index (" + total + ")");
// search index
doSearch(index, store);
// done
log("done :)");
var server = require('./server.js').new(store, index);
server.start();
});
});
}, retryNotFound, resolveProgress);
});
});
});
*/