Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Publish checksum for the database dump #204

Open
andreasb opened this issue Sep 2, 2013 · 1 comment
Open

Publish checksum for the database dump #204

andreasb opened this issue Sep 2, 2013 · 1 comment
Assignees
Labels

Comments

@andreasb
Copy link
Collaborator

andreasb commented Sep 2, 2013

No description provided.

@ghost ghost assigned funkatron Sep 2, 2013
@StylusEater
Copy link

With the proper edits, this might be useful when we do have support ...

#!/usr/bin/perl
## Adapted from an online example.
## Adam M Dutko - 2013
use Cwd;
use HTTP::Cookies;
use LWP::UserAgent;
use Modern::Perl '2011';
use constant BASE => "https://openrecipes.s3.amazonaws.com/";
use constant FILE => "recipeitems-latest.json.gz";
use constant MD5 => "";
## Check if file exists
if (-e getcwd() . "/" . FILE)
{
    print FILE . " exists. Right now checksum freshness checks are not supported.\n";
} else {
    ## Setup agent and cookies
    my $ua = LWP::UserAgent->new();
    my $download_cookies = HTTP::Cookies->new(
        file => "download_cookies.txt",
        autosave => 1
    );
    $ua->cookie_jar($download_cookies);
    $ua->agent("Openrecip.es Download Agent");
    ## Download file
    my $download_response = $ua->get(BASE . FILE);
    unless($download_response->is_success) 
    {
        print "ERROR: " . $download_response->status_line;
    }
    ## Write the downloaded data
    my $recipes = FILE;
    unless(open RECIPES, '>' . $recipes) 
    {
        die "ERROR: Cannot save the new recipes files.\n";
    }
    print RECIPES $download_response->decoded_content;
    close RECIPES;
    
    print "Latest recipes downloaded.\n";
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants