X-SC-Record-Id and X-SC-Alarm fields
authorTim Pope <code@tpope.net>
Fri, 27 Aug 2004 21:58:53 +0000 (21:58 +0000)
committerTim Pope <code@tpope.net>
Fri, 27 Aug 2004 21:58:53 +0000 (21:58 +0000)
perl/sctweb

index 2cbedd6a2675ec0a6d3a5964b1c42ce149dbac13..da66f4b44a336096fbbf3b12cd6dbe54f1de5df7 100755 (executable)
@@ -207,7 +207,8 @@ sub do_mhc_schedule {
            map { s/\xa0//g; s/\n/-/g; $_} @$row;
            $row->[0] =~ s/.*launchWebCT\("([^"]*)"\).*/$1/s;
            $row->[0] =~ s/(.*) <BR>//g;
-           my $id=generate_id($1);
+           my $classid=$1;
+           my $id=generate_id($classid);
            $row->[0] = capitalize($row->[0]);
            $row->[1] =~ s/([MTWRFS])/ $days{$1}/g;
            $row->[1] =~ s/^ //;
@@ -233,12 +234,14 @@ sub do_mhc_schedule {
            print "\n";
            print "# $id\n";
            print "X-SC-Subject: ", $row->[0], "\n";
+           print "X-SC-Location: ", $row->[4], "\n";
            print "X-SC-Category: School\n";
            print "X-SC-Cond: ", $row->[1], "\n";
            print "X-SC-Time: ", $row->[2], "\n";
            print "X-SC-Duration: ", $row->[3], "\n";
-           print("X-SC-Day: ", "@day", "\n") if(exists $day[0]);
-           print "X-SC-Location: ", $row->[4], "\n";
+           print("X-SC-Day: @day\n") if(exists $day[0]);
+           print "X-SC-Alarm: 20 minutes\n";
+           print "X-SC-Record-Id: <$classid\@from.sctweb>\n"
        }
     }
 }
@@ -313,22 +316,25 @@ sub do_html_grades {
 sub do_transcripts {
     $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN&tserve_trans_config=rtranscr.cfg&CareerReqNum=1");
     foreach (split /\n/, $response->content) {
-       next unless s/^\&nbsp;//;
+       next unless s/^\&nbsp;|<pre>// || s/\&nbsp;/ /;
        s/<\/?[Hh]\d>//g;
        print "$_\n";
     }
 }
 
-if (defined($ARGV[0]) && $ARGV[0] eq "-g") {
+my $arg = "";
+$arg = shift if (defined($ARGV[0]) && $ARGV[0] =~ /^-\w$/);
+
+if ($arg eq "-g") {
     shift;
     do_html_grades;
-} elsif (defined($ARGV[0]) && $ARGV[0] eq "-s") {
+} elsif ($arg eq "-s") {
     shift;
     do_html_schedule;
-} elsif (defined($ARGV[0]) && $ARGV[0] eq "-m") {
+} elsif ($arg eq "-m") {
     shift;
     do_mhc_schedule(@ARGV);
-} elsif (defined($ARGV[0]) && $ARGV[0] eq "-t") {
+} elsif ($arg eq "-t") {
     do_transcripts;
 }