<commit_before>'use strict';

var ig     = require('instagram-node').instagram()
  , config = require('../config')
  , logger = require('../lib').logger
  , Image  = require('../models').Image
  , async  = require('async')
  , _      = require('lodash')
  ;

(function() {

  logger.info('Beginning Instagram Import');

  ig.use({
    client_id: config.instagram.key,
    client_secret: config.instagram.secret
  });

  ig.user_media_recent(config.instagram.userid, function(err, medias, pagination, limit) {
    if (medias && medias.length > 0) {

      async.each(medias, function(media, done) {
        var image = {
          instid: media.id,
          href: media.link,
          src: media.images.low_resolution.url,
          postDate: new Date(0).setUTCSeconds(media.created_time)
        }

        new Image(image).save(function(err) {

          // prevent db errors from stopping the script
          done(null);
        });
      }, function(err) {
        if (err) {
          logger.error(err);
        }

        logger.info('Instagram Import Complete');
        process.exit();
      });<commit_msg>continue using access token for instagram<commit_after>'use strict';

var ig     = require('instagram-node').instagram()
  , config = require('../config')
  , logger = require('../lib').logger
  , Image  = require('../models').Image
  , async  = require('async')
  , _      = require('lodash')
  ;

(function() {

  logger.info('Beginning Instagram Import');

  ig.use({
    // client_id: config.instagram.key,
    // client_secret: config.instagram.secret,
    access_token: config.instagram.token
  });

  ig.user_media_recent(config.instagram.userid, function(err, medias, pagination, limit) {
    if (medias && medias.length > 0) {

      async.each(medias, function(media, done) {
        var image = {
          instid: media.id,
          href: media.link,
          src: media.images.low_resolution.url,
          postDate: new Date(0).setUTCSeconds(media.created_time)
        }

        new Image(image).save(function(err) {

          // prevent db errors from stopping the script
          done(null);
        });
      }, function(err) {
        if (err) {
          logger.error(err);
        }

        logger.info('Instagram Import Complete');
        process.exit();
      });
{'fraction_non_alphanumeric': 0.14805194805194805, 'fraction_numerical': 0.0017316017316017316, 'mean_word_length': 2.3492753623188407, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6238993', 'n_tokens_mistral': 716, 'n_tokens_neox': 693, 'n_words': 135}