Last active
June 7, 2017 02:31
-
-
Save Code-Hex/5c6bbcd3f9e89fed638d23afeaf99547 to your computer and use it in GitHub Desktop.
cabocha download script for Travis-ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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/&/&/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