<commit_before>'use strict';

var https       = require('https');
var http        = require('http');
var request     = require('request');
    request     = request.defaults({jar: true});
var exec        = require('child_process').exec;
var deferred    = require('deferred');
var config      = require('../config');

// Login to the PassThePopcorn API using the username and password supplied in the config file
/*
var host = config[config.movies];
request.post({ url: host.host + host.path + 'ajax.php?action=login', form: { username: host.username, password: <PASSWORD>, passkey: host.auth, 
                                                                             keeplogged: 1 }}, 
    function(err, httpResponse, body) { 
        console.log(body);
            
        if (err)
            console.log(err);
    }
);
*/
/* This is where the download-related 
   functions are. Search functions
   are below this sectioin          */ 

// Exported function that is called as the download endpoint for the PassThePopcorn module
function downloadMovie(options) {
    var response = deferred();

    var download = exec('wget --no-check-certificate -O "' + config[config.movies].watch_dir + options.title + '.torrent" "' + options.url + '"', 
        function processDownload(error, stdout, stderr) {
            if (error) {
                console.log(stderr);
                return;
            }

            console.log(stdout);
            response.resolve();
        }
    );

    return response.promise;
}


/* This is where the search related <commit_msg>General CSS clean-up. The TV frontend has been redone which will allow general CSS classes to be made next iteration. TV backend needs to be converted to using the 'request' library.<commit_after>'use strict';

var https       = require('https');
var http        = require('http');
var request     = require('request');
    request     = request.defaults({jar: true});
var exec        = require('child_process').exec;
var deferred    = require('deferred');
var config      = require('../config');

// Login to the PassThePopcorn API using the username and password supplied in the config file
var host = config[config.movies];
request.post({ url: host.host + host.path + 'ajax.php?action=login', form: { username: host.username, password: <PASSWORD>, passkey: host.auth, 
                                                                             keeplogged: 1 }}, 
    function(err, httpResponse, body) { 
        console.log(body);
            
        if (err)
            console.log(err);
    }
);
/* This is where the download-related 
   functions are. Search functions
   are below this sectioin          */ 

// Exported function that is called as the download endpoint for the PassThePopcorn module
function downloadMovie(options) {
    var response = deferred();

    var download = exec('wget --no-check-certificate -O "' + config[config.movies].watch_dir + options.title + '.torrent" "' + options.url + '"', 
        function processDownload(error, stdout, stderr) {
            if (error) {
                console.log(stderr);
                return;
            }

            console.log(stdout);
            response.resolve();
        }
    );

    return response.promise;
}


/* This is where the search related 
{'fraction_non_alphanumeric': 0.11430299364983369, 'fraction_numerical': 0.0006047777441790142, 'mean_word_length': 2.1777137367915467, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6855420', 'n_tokens_mistral': 878, 'n_tokens_neox': 839, 'n_words': 270}