#!/usr/bin/perl # # add_data: Augment the data in the intermediate files, so that we don't # have to redo genre searches etc. if the files are going to be used for # several slices. # # Copyright (c) Warren Toomey, wkt@tuhs.org, 2002/2003/2004 # # $Revision: 1.1.1.1 $ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 0. This software must only be used in those parts of the world which # cannot obtain a program subscription service from TiVo, Inc. # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Warren Toomey. # 4. Warren Toomey's name may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY WARREN TOOMEY ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL WARREN TOOMEY BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # use strict; # Functions used from other files # use TiVo::ConfigFiles; use TiVo::MiscUtil; use TiVo::ProgramDb; use TiVo::AugmentData; use TiVo::Ratings; use TiVo::Directors; # GLOBAL VARIABLES my ($top_level_confile); my ($chan, $snum, $enum); my ($sday, $eday); my ($cnt, $i, $result); # # MAIN PROGRAM # # Run-time flags: allow user to choose a top-level config file, and # prevent the program from updating the writable config files # i.e. numbers, episodes, programs. # $top_level_confile= ".guiderc"; if (($#ARGV>2) && ($ARGV[0] eq "-c")) { $top_level_confile=$ARGV[1]; shift; shift; } # # Check we have 3 arguments: channel, start day and end day. # if ($#ARGV!=2) { print("Usage: $0 [-c config_file] channel startday endday\n"); exit(1); } # Convert the start/end numbers to real daynums $chan= $ARGV[0]; $snum= int($ARGV[1]); $enum= int($ARGV[2]); $sday= Get_Dayname($snum); $eday= Get_Dayname($enum); # Get the configuration details to find the run-time files and other things Read_Guiderc($top_level_confile); if (!defined($ConfigVar{Extradir})) { print(STDERR "Cannot proceed because Extradir is not defined in $top_level_confile\n"); exit(1); } # Read other data sources in Read_Websources; Read_Genrelist; Read_Trimtitles; Read_Programs; Read_Ratings; Read_Directors; print("Augmenting the data in the intermediate files\n"); $result=1; # Either loop doing all the channels.. if ($chan eq "All") { $cnt=0; $i=1; foreach $chan (keys(%StationWebsrc)) { $cnt++; } foreach $chan (keys(%StationWebsrc)) { print("Augmenting data for $chan from $sday to $eday ($i/$cnt)\n"); $result &= Augment_Data($chan, $snum, $enum, 1); $i++; } } # Or do a single channel.. else { if (!defined($StationWebsrc{$chan})) { print(STDERR "Channel $chan does not exist. Choose from this list:\n"); foreach $chan (sort keys(%StationWebsrc)) { print(STDERR "$chan "); } print(STDERR "\n"); exit(1); } print("Augmenting data for $chan from $sday to $eday\n"); $result &= Augment_Data($chan, $snum, $enum, 1); } exit(1-$result);