Skip to content

Commit

Permalink
uk_freeview: instate cache as default behaviour (#241)
Browse files Browse the repository at this point in the history
Web page cache was only used in debug mode: now used always.
  • Loading branch information
honir committed Aug 27, 2024
1 parent 3e1b78d commit f84e2eb
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions grab/uk_freeview/tv_grab_uk_freeview
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ XMLTV::Ask::init($opt_gui);

# ------------------------------------------------------------------ #
# Initialise the web page cache
if ($opt_debug) {
my $cachedir = get_default_cachedir();
init_cachedir($cachedir);
HTTP::Cache::Transparent::init( {
BasePath => '/tmp/.xmltv/cache',
BasePath => $cachedir,
NoUpdate => 60*60, # cache time in seconds
MaxAge => 24, # flush time in hours
Verbose => $opt_debug,
} );
}



Expand Down Expand Up @@ -319,6 +319,7 @@ if (scalar @ch_all == 0) {
}


print STDERR "using cache '$cachedir' \n" if $opt_debug;
print STDERR "using channel format '$channel_format' \n" if $opt_debug;
print STDERR "using region id '$region_id' \n" if $opt_debug;
print STDERR "using icon ch string '$icon_ch_qs' \n" if $opt_debug;
Expand Down Expand Up @@ -437,6 +438,22 @@ BEGIN {
}
}

# Get location of cache files
sub get_default_dir {
my $winhome = $ENV{HOMEDRIVE} . $ENV{HOMEPATH} if defined( $ENV{HOMEDRIVE} ) and defined( $ENV{HOMEPATH} );
my $home = $ENV{HOME} || $winhome || ".";
return $home;
}
sub get_default_cachedir {
return get_default_dir() . "/.xmltv/cache";
}
sub init_cachedir {
my $path = @_;
if ( not -d $path ) {
mkpath( $path ) or die "Failed to create cache-directory $path: $@";
}
}

# Remove bad chars from an element
sub tidy( $ ) {
return $_[0] if !defined $_[0];
Expand Down

0 comments on commit f84e2eb

Please sign in to comment.