Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getFolderContents(dir) {
- fs.readdir(dir, function(err, items) {
- for (var i = 0; i < items.length; i++) {
- if ( fs.lstatSync(dir + items[i]).isDirectory() ) {
- // The item is a dir, so check the contents of it.
- getFolderContents(dir + items[i] + '/');
- } else {
- // The item isn't a dir, but a file. We don't want to deal with it here, so send it over to getFileInfo()
- getFileInfo(dir + items[i], items[i]);
- }
- }
- });
- }
- function getFileInfo(dir, file) {
- if ( (file.indexOf('.srt')) >= 0 || (file.indexOf('.jpg')) >= 0 || (file.indexOf('.xml')) >= 0 || (file.indexOf('.png')) >= 0 || (file.indexOf('.nfo')) >= 0 || (file.indexOf('.sfv')) >= 0 ) {
- // Ignore anything that contains these in the filename (ugly formatting and temporary)
- } else {
- <snipped code>
- setTimeout(Testing, delay, dir, file);
- }
- }
- function Testing(dir, title) {
- metadata.getId(title, null, function(err, id) { // FIXME: Limit how often this is called, as we're probably hitting the API too hard.
- if(err) {
- return console.error(err + ' DEBUG ' + title);
- } else if (!id) {
- return console.error('No movies found.');
- } else {
- // Now that we have the ID for the movie, we can proceed.
- <snipped code>
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement