#!/usr/bin/perl -w

my @courses_json;
my $filename = shift;
open (FILE,$filename) or die "$!";
@courses_json = <FILE>;
close FILE;

my $line_count = scalar @courses_json;
for ($i = 0; $i < $line_count; $i++)
{
  my $line = $courses_json[$i];
  if ($line =~ m:\"content\".*http.*faqs/(.*)\":)
  {
    my $file = "../".$1;
    $file =~ s:%20: :g;
    print "$file\n";
    my @stat = stat($file);
    my $size = $stat[7];
    if ($line =~ m:,:)
    {
      $leading_comma = "";
      $trailing_comma = ",";
    }
    else
    {
      $leading_comma = ",";
      $trailing_comma = "";
    }
    $line .= "$leading_comma \"content_size\":$size$trailing_comma\n";
    $courses_json[$i] = $line;
  }
}

open (FILE,">$filename") or die "$!";
print FILE @courses_json;
close FILE;
