<commit_before>"use strict";

var Twit = require('twit'),
  when = require('when'),
  request = require('request'),
  _ = require('lodash');


function argObj(args, argNames, defaultArgs) {
  var result;

  if (typeof args[0] === 'object' && args.length === 1) {
    result = args[0];
  } else {
    result = _.zipObject(argNames, [].slice.call(args));
  }

  return _.defaults(result, defaultArgs);
}


function promiseCallback(promise) {
  return function (err, reply) {
    if (err)
      promise.reject(err);
    else
      promise.resolve(reply);
  }
}

function processTweets(tweets) {
  return when(_.map(tweets.statuses, processTweet));
}

function processTweet(tweet) {
  var vineUrlMatch = /https?:\/\/t\.co\/[A-Za-z0-9]+/.exec(tweet.text); // Vine URL match
  var result = when.defer(); // result promise
  var t = {}; // the return object

  if (!vineUrlMatch) {
    console.error("Could not find the vine URL");
    return result.reject(new Error("Could not find "));
  }

  t.user = tweet.user.screen_name;
  t.id = tweet.id_str;
  t.text = tweet.text;
  t.vineUrl = vineUrlMatch[0];
  t.vidUrl = '';
  t.thumbUrl = '';

  request(t.vineUrl, function (err, response, body) {
    if (err) {
      console.error("Url Invalid");
      result.reject(err);
    }

    var videoMatch = /<meta.*?property="twitter:player:stream".*?content="(.*?)"/.exec(body);
    var thumbnailMatch = /<meta.*?property="og:image".*?content="(.*?)"/.exec(body);

    if (videoMatch && thumbnailMatch && response.statusCode == 200) {
      t.vidUrl = videoMatch[1];
      t.thumbUrl = thumbnailMatch[1];
      result.resolve(t);
    }
    else {
      console.error("Could not scrape vine page: ", t.vineUrl);
      result.reject(new Error("Error while scraping vine page for tweet " + t.text));
    }
  });

  return result.promise;
}

module.exports = {

  config: {
    twitterCredentials: {
      consumer_key: 'gA11sspNJdtdCL2gWDQqFA',
      consumer_secret: '<KEY>',
      access_token: '<KEY>',
      access_token_secret: '<KEY>'
    },
    defaults: {
      query: "",
      retweets: false,
      count: 10,
      resultType: "recent",
      maxId: 0,
      maxRetries: 3
    }
  },<commit_msg>use your own goddamn twitter info<commit_after>"use strict";

var Twit = require('twit'),
  when = require('when'),
  request = require('request'),
  _ = require('lodash');


function argObj(args, argNames, defaultArgs) {
  var result;

  if (typeof args[0] === 'object' && args.length === 1) {
    result = args[0];
  } else {
    result = _.zipObject(argNames, [].slice.call(args));
  }

  return _.defaults(result, defaultArgs);
}


function promiseCallback(promise) {
  return function (err, reply) {
    if (err)
      promise.reject(err);
    else
      promise.resolve(reply);
  }
}

function processTweets(tweets) {
  return when(_.map(tweets.statuses, processTweet));
}

function processTweet(tweet) {
  var vineUrlMatch = /https?:\/\/t\.co\/[A-Za-z0-9]+/.exec(tweet.text); // Vine URL match
  var result = when.defer(); // result promise
  var t = {}; // the return object

  if (!vineUrlMatch) {
    console.error("Could not find the vine URL");
    return result.reject(new Error("Could not find "));
  }

  t.user = tweet.user.screen_name;
  t.id = tweet.id_str;
  t.text = tweet.text;
  t.vineUrl = vineUrlMatch[0];
  t.vidUrl = '';
  t.thumbUrl = '';

  request(t.vineUrl, function (err, response, body) {
    if (err) {
      console.error("Url Invalid");
      result.reject(err);
    }

    var videoMatch = /<meta.*?property="twitter:player:stream".*?content="(.*?)"/.exec(body);
    var thumbnailMatch = /<meta.*?property="og:image".*?content="(.*?)"/.exec(body);

    if (videoMatch && thumbnailMatch && response.statusCode == 200) {
      t.vidUrl = videoMatch[1];
      t.thumbUrl = thumbnailMatch[1];
      result.resolve(t);
    }
    else {
      console.error("Could not scrape vine page: ", t.vineUrl);
      result.reject(new Error("Error while scraping vine page for tweet " + t.text));
    }
  });

  return result.promise;
}

module.exports = {

  config: {
    twitterCredentials: {
      consumer_key: '',
      consumer_secret: '',
      access_token: '',
      access_token_secret: ''
    },
    defaults: {
      query: "",
      retweets: false,
      count: 10,
      resultType: "recent",
      maxId: 0,
      maxRetries: 3
    }
  },
{'fraction_non_alphanumeric': 0.16991069384016488, 'fraction_numerical': 0.007556675062972292, 'mean_word_length': 2.9637023593466423, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3990410', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1481, 'n_words': 311}