Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Last active June 7, 2017 02:31
Show Gist options
  • Select an option

  • Save Code-Hex/5c6bbcd3f9e89fed638d23afeaf99547 to your computer and use it in GitHub Desktop.

Select an option

Save Code-Hex/5c6bbcd3f9e89fed638d23afeaf99547 to your computer and use it in GitHub Desktop.
cabocha download script for Travis-ci
#!/usr/bin/perl
# Stolen from https://github.com/Nanolx/patchimage/blob/master/tools/gdown.pl
use strict;
use warnings;
sub execute_command();
my $confirm;
my $check = 0;
my $URL = "https://drive.google.com/uc?id=0B4y35FiV1wh7SDd1Q1dUQkZQaUU&export=download";
my $FILENAME = "cabocha-0.69.tar.bz2";
execute_command();
open my $fh, '<', $FILENAME;
foreach (<$fh>) {
if (/href="(\/uc\?export=download[^"]+)/) {
$URL = "https://drive.google.com$1";
$URL =~ s/&amp;/&/g;
$confirm = '';
$check = 1;
last;
}
if (/confirm=([^;&]+)/) {
$confirm = $1;
$check = 1;
last;
}
if (/"downloadUrl":"([^"]+)/) {
$URL = $1;
$URL=~s/\\u003d/=/g;
$URL=~s/\\u0026/&/g;
$confirm = '';
$check = 1;
last;
}
}
close $fh;
die "Couldn't download the file :-(\n" if $check == 0;
$URL=~s/confirm=([^;&]+)/confirm=$confirm/ if $confirm ne '';
execute_command();
sub execute_command() {
my $command = "wget -nv --load-cookie cookie.txt --save-cookie cookie.txt \"$URL\"";
$command .= " -O \"$FILENAME\"" if $FILENAME ne '';
`$command`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment