Home Automation
Other Scripts

Sat Codes with AutoIt


So here is a piece of software that I was playing with about a week ago (Jan 2008). I was sick of going to the web site(s) to get satellite codes for "my friend's" receiver and not being able to get on because 3000 other people were also trying to get "their friend's" satellite receiver running. I needed a way of being able to get the files download in the middle of the night or during the day.

So I built a piece of software that would first check to see if the web site was online and responding. So the script does a simple ping. If the site is down then it just stops the process and logs the results.



So this next section reads a configuration file to get the list of satellite receivers that it is going to get results for. I don't actually list the satellite names in the file I list the page IDs that correspond to the satellites that I am interested in. If I want to search for another receiver I just add another PID to the text file. After it reads the web page it then parses out the sub page IDs and compares these against an existing list. If there are IDs that are not in the existing list then it downloads that web page. Once it has that page then it parses again, this time it retrieves a file link out of the page "blah blah blah.zip".



The file size is retrieved and saved, then the file gets downloaded. Local file size is compared with the web site file size and if they are the same all is good, if they are different then it fails and deletes the local file. It will try again later...


Once the file has been confirmed as good. It writes the sat PID and file name to a text file. This text file is being watched by Misterhouse, so as soon as it changes the first and only line is read. Misterhouse then generates an email with the recipients for that satellite (PID) and attaches their update file. It also sends a text message to their cell phone to tell them their is an update waiting in their email.

 


Misterhouse Code

set_watch $sat_file if $Reload;

if (changed $sat_file) {
   my $satline = read_next $sat_file;
   my ($sat_number, $sat_attachment) = $satline =~ /(.+),(.+)/;
   speak 'Reading satellite file';
   set_watch $sat_file;
   my $new_attachment = "$sat_folder$sat_attachment";
   print_log "Reading satellite file - $new_attachment";
   if ($sat_number eq 93) { # PID93 Sonicview HD8000
      $email_group = $hd8000_email;
      $sat_name = 'Sonicview HD8000';
      $Save{nintythree_trigger} = 'go';
   }
   if ($sat_number eq 58) { # PID58 CNX Duo / Trio
      $email_group = $cnxtrio_email;
      $sat_name = 'Conaxsat Duo / Trio';
      $Save{fiftyeight_trigger} = 'go';
   }
   if ($sat_number eq 57) { # PID57 CNX V1
      $email_group = $cnxv1_email;
      $sat_name = 'Conaxsat V1';
      $Save{fiftyseven_trigger} = 'go';
   }
   net_mail_send(to => $email_group,
   subject => 'Your Satelitte has a new update',
   file => $new_attachment,
   text => "A new update has been downloaded for your satellite receiver
($sat_name) as of $Date_Now_Speakable at $Time_Now.

Please copy the attached file and enjoy.);
}


I am going to call this project done.




Notes:

Cron job is used to trigger the script, I do this through Misterhouse
I used Misterhouse house to send the emails because I know that it will get handled well, AutoIt does send email but doesn't support authentication
I could have used Misterhouse to do this whole task, I have an easier time programming with AutoIt, I might convert it some day, but for now it works great

Please feel free to leave a comment about this page

write a comment

smile zwinker Big Grins Confused Cool Cry Eek Evil Frown Mad Mr. Green Neutral Razz Redface Rolleyes Sad Surprised