<commit_before>var async = require('async');
var request = require('request');
var cheerio = require('cheerio');

module.exports = {

  index: function(req, res, next) {
    if (!req.isAuthenticated()) return res.render('index');

    var videos = [];
    var yt_channel_startLink = 'https://www.youtube.com/user/';
    var yt_channel_endLink = '/videos?view=0';

    async.each(req.user.subscriptions, function(user, callback) {
      var link = yt_channel_startLink + user + yt_channel_endLink;
      request(link, function(err, response, body) {
        if (err || response.statusCode !== 200) return callback();
        var $ = cheerio.load(body);
        var content = $('.channels-content-item').map(function(i, el) {
          return {
            img: 'http:' + $(this).find('img').attr('src'),
            link: 'https://www.youtube.com' + $(this).find('a').attr('href').split('&')[0],
            time: $(this).find('.video-time').text(),
            title: $(this).find('.yt-lockup-content a').text(),
            author: user,
            viewCount: $(this).find('.yt-lockup-meta ul li').first().text(),
            publishedAt: $(this).find('.yt-lockup-deemphasized-text').text()
          };
        }).get();
        videos = videos.concat(content);
        callback();
      });
    }, function(err) {
      if (err) return next(err);

      var timeFrame = { 'second': [], 'minute': [], 'hour': [], 'day': [], 'week': [] };
      var len = videos.length;
      var timeArray = Object.keys(timeFrame);
      var timeLen = timeArray.length; 
      var re = /[0-9]{1,2}/;
      
      function timeInsertion(time, content) {
        if (content.publishedAt.indexOf(time) >= 0) {
          if (time === 'week' && Number(content.publishedAt.match(re)[0]) > 2) return;
          timeFrame[time].push(content);<commit_msg>Secure img link<commit_after>var async = require('async');
var request = require('request');
var cheerio = require('cheerio');

module.exports = {

  index: function(req, res, next) {
    if (!req.isAuthenticated()) return res.render('index');

    var videos = [];
    var yt_channel_startLink = 'https://www.youtube.com/user/';
    var yt_channel_endLink = '/videos?view=0';

    async.each(req.user.subscriptions, function(user, callback) {
      var link = yt_channel_startLink + user + yt_channel_endLink;
      request(link, function(err, response, body) {
        if (err || response.statusCode !== 200) return callback();
        var $ = cheerio.load(body);
        var content = $('.channels-content-item').map(function(i, el) {
          return {
            img: 'https:' + $(this).find('img').attr('src'),
            link: 'https://www.youtube.com' + $(this).find('a').attr('href').split('&')[0],
            time: $(this).find('.video-time').text(),
            title: $(this).find('.yt-lockup-content a').text(),
            author: user,
            viewCount: $(this).find('.yt-lockup-meta ul li').first().text(),
            publishedAt: $(this).find('.yt-lockup-deemphasized-text').text()
          };
        }).get();
        videos = videos.concat(content);
        callback();
      });
    }, function(err) {
      if (err) return next(err);

      var timeFrame = { 'second': [], 'minute': [], 'hour': [], 'day': [], 'week': [] };
      var len = videos.length;
      var timeArray = Object.keys(timeFrame);
      var timeLen = timeArray.length; 
      var re = /[0-9]{1,2}/;
      
      function timeInsertion(time, content) {
        if (content.publishedAt.indexOf(time) >= 0) {
          if (time === 'week' && Number(content.publishedAt.match(re)[0]) > 2) return;
          timeFrame[time].push(content);
{'fraction_non_alphanumeric': 0.19416416689391874, 'fraction_numerical': 0.00654485955822198, 'mean_word_length': 2.6716716716716715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, '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': '4719286', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1125, 'n_words': 223}