<commit_before>// This is where all the fun happens. Please take a moment to read through this
// file to acquaint yourself with the functionality provided and the
// implementation thereof.

var cheerio = require("cheerio"),
    ent = require("ent"),
    filesize_parser = require("filesize-parser"),
    request = require("request"),
    url = require("url");

// Main entry point. This is the client class. It takes a single optional
// argument, being the base URL of the NyaaTorrents site you want to interact
// with. If left out, it will default to "http://www.nyaa.se/".
var NyaaTorrents = module.exports = function NyaaTorrents(options) {
  options = options || {};

  this.baseUrl = options.baseUrl || "http://www.nyaa.se/";
  this.username = options.username;
  this.password = <PASSWORD>;

  this.cookies = request.jar();
};

NyaaTorrents.prototype.login = function login(cb) {
  var uri = url.parse(this.baseUrl, true);

  uri.query.page = "login";

  var options = {
    uri: uri,
    form: {
      method: 1,
      login: this.username,
      password: <PASSWORD>,
      submit: "Submit",
    },
    jar: this.cookies,
  };

  request.post(options, function(err, res, data) {
    if (err) {
      return cb(err);
    }

    if (res.statusCode !== 303) {
      return cb(Error("invalid status code; expected 303 but got " + res.statusCode));
    }

    if (data.indexOf("Login failed!") !== -1) {
      return cb(Error("login failed; incorrect password?"));<commit_msg>fix login method<commit_after>// This is where all the fun happens. Please take a moment to read through this
// file to acquaint yourself with the functionality provided and the
// implementation thereof.

var cheerio = require("cheerio"),
    ent = require("ent"),
    filesize_parser = require("filesize-parser"),
    request = require("request"),
    url = require("url");

// Main entry point. This is the client class. It takes a single optional
// argument, being the base URL of the NyaaTorrents site you want to interact
// with. If left out, it will default to "http://www.nyaa.se/".
var NyaaTorrents = module.exports = function NyaaTorrents(options) {
  options = options || {};

  this.baseUrl = options.baseUrl || "http://www.nyaa.se/";
  this.username = options.username;
  this.password = <PASSWORD>.password;

  this.cookies = request.jar();
};

NyaaTorrents.prototype.login = function login(cb) {
  var uri = url.parse(this.baseUrl, true);

  uri.query.page = "login";

  var options = {
    uri: url.format(uri),
    form: {
      method: 1,
      login: this.username,
      password: <PASSWORD>,
      submit: "Submit",
    },
    jar: this.cookies,
  };

  request.post(options, function(err, res, data) {
    if (err) {
      return cb(err);
    }

    if (data.indexOf("Login successful") === -1) {
      return cb(Error("login was not successful"));
    }

    if (data.indexOf("Login failed!") !== -1) {
      return cb(Error("login failed; incorrect password?"));
{'fraction_non_alphanumeric': 0.13997308209959622, 'fraction_numerical': 0.0037012113055181696, 'mean_word_length': 3.1638655462184873, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3642186', 'n_tokens_mistral': 923, 'n_tokens_neox': 896, 'n_words': 284}