Compare commits
6 Commits
master
...
with-resum
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce2e31ba3e | ||
|
|
f24642d797 | ||
|
|
15557edc15 | ||
|
|
59d6899b42 | ||
|
|
3b3883746d | ||
|
|
1f8e24efb0 |
26
README.md
26
README.md
@@ -23,13 +23,37 @@ For example, to download [this video](https://drive.google.com/file/d/0B1L_hFrWJ
|
||||
|
||||
$ ./gdown.pl https://drive.google.com/file/d/0B1L_hFrWJfRhLUJZdXdSdTdfSWs/edit axolotl.mp4
|
||||
|
||||
As long as a file name is indicated (second parameter), gdown.pl **will try to resume the partially downloaded file** if an incomplete file with that name already exists.
|
||||
As long as a file name is indicated (second parameter), gdown.pl **will try to resume the partially downloaded file** if an incomplete file with that name already exists. Please note that for this to work, wget must correctly provide --spider with --server-response (-S). Wget v1.17 at least is advised.
|
||||
|
||||
Docker
|
||||
======
|
||||
|
||||
A simple Docker file is provided, to build a simple Docker image with gdown.pl.
|
||||
This has been used for pre-pulling data from a Google Drive to Kubernetes persistent volumes.
|
||||
Thanks @anton-khodak
|
||||
|
||||
Singularity
|
||||
===========
|
||||
|
||||
An example [Singularity](https://sylabs.io/guides/3.2/user-guide/quick_start.html) file is provided.
|
||||
Build the container:
|
||||
`sudo singularity build (imagename) Singularity`
|
||||
|
||||
Run the container:
|
||||
`singularity run (imagename) (gdown.pl args)`
|
||||
|
||||
Thanks to @ttbrunner
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Distributed [under GPL 3](http://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
Disclaimer
|
||||
==========
|
||||
|
||||
This software is provided "as is", without warranty of any kind, express or implied.
|
||||
|
||||
More info
|
||||
=========
|
||||
|
||||
|
||||
14
Singularity
Normal file
14
Singularity
Normal file
@@ -0,0 +1,14 @@
|
||||
BootStrap: docker
|
||||
FROM: perl
|
||||
|
||||
# This is the script that's executed when you don't call it with any script or shell to execute.
|
||||
%runscript
|
||||
exec /usr/local/bin/gdown.pl "$@"
|
||||
|
||||
%setup
|
||||
cp gdown.pl ${SINGULARITY_ROOTFS}/usr/local/bin/
|
||||
|
||||
# These commands will be executed inside of the container during building.
|
||||
%post
|
||||
apt-get update
|
||||
apt install -y wget
|
||||
45
gdown.pl
45
gdown.pl
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# v1.0 by circulosmeos 04-2014.
|
||||
# v1.1 by circulosmeos 01-2017.
|
||||
# v1.2 by circulosmeos 01-2019.
|
||||
# v1.2, 2.0 by circulosmeos 01-2019.
|
||||
# //circulosmeos.wordpress.com/2014/04/12/google-drive-direct-download-of-big-files
|
||||
# Distributed under GPL 3 (//www.gnu.org/licenses/gpl-3.0.html)
|
||||
#
|
||||
@@ -22,16 +22,19 @@ my $URL=shift;
|
||||
die "\n./gdown.pl 'gdrive file url' [desired file name]\n\n" if $URL eq '';
|
||||
|
||||
my $FILENAME=shift;
|
||||
$FILENAME='gdown.'.strftime("%Y%m%d%H%M%S", localtime) if $FILENAME eq '';
|
||||
my $TEMP_FILENAME='gdown.'.strftime("%Y%m%d%H%M%S", localtime).'.'.substr(rand,2);
|
||||
|
||||
if ($URL=~m#^https?://drive.google.com/file/d/([^/]+)#) {
|
||||
$URL="https://docs.google.com/uc?id=$1&export=download";
|
||||
}
|
||||
elsif ($URL=~m#^https?://drive.google.com/open\?id=([^/]+)#) {
|
||||
$URL="https://docs.google.com/uc?id=$1&export=download";
|
||||
}
|
||||
|
||||
execute_command();
|
||||
|
||||
while (-s $FILENAME < 100000) { # only if the file isn't the download yet
|
||||
open fFILENAME, '<', $FILENAME;
|
||||
while (-s $TEMP_FILENAME < 100000) { # only if the file isn't the download yet
|
||||
open fFILENAME, '<', $TEMP_FILENAME;
|
||||
$check=0;
|
||||
foreach (<fFILENAME>) {
|
||||
if (/href="(\/uc\?export=download[^"]+)/) {
|
||||
@@ -60,13 +63,39 @@ while (-s $FILENAME < 100000) { # only if the file isn't the download yet
|
||||
$URL=~s/confirm=([^;&]+)/confirm=$confirm/ if $confirm ne '';
|
||||
|
||||
execute_command();
|
||||
|
||||
}
|
||||
|
||||
unlink $TEMP;
|
||||
|
||||
sub execute_command() {
|
||||
$COMMAND="wget -c --no-check-certificate --load-cookie $TEMP --save-cookie $TEMP \"$URL\"";
|
||||
$COMMAND.=" -O \"$FILENAME\"" if $FILENAME ne '';
|
||||
`$COMMAND`;
|
||||
my $OUTPUT_FILENAME = $TEMP_FILENAME;
|
||||
my $CONTINUE = '';
|
||||
|
||||
# check contents before download & if a $FILENAME has been indicated resume on content download
|
||||
# please, note that for this to work, wget must correctly provide --spider with --server-response (-S)
|
||||
if ( length($FILENAME) > 0 ) {
|
||||
$COMMAND="wget -q -S --no-check-certificate --spider --load-cookie $TEMP --save-cookie $TEMP \"$URL\" 2>&1";
|
||||
my @HEADERS=`$COMMAND`;
|
||||
foreach my $header (@HEADERS) {
|
||||
if ( $header =~ /Content-Type: (.+)/ ) {
|
||||
if ( $1 !~ 'text/html' ) {
|
||||
$OUTPUT_FILENAME = $FILENAME;
|
||||
$CONTINUE = '-c';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$COMMAND="wget $CONTINUE --progress=dot:giga --no-check-certificate --load-cookie $TEMP --save-cookie $TEMP \"$URL\"";
|
||||
$COMMAND.=" -O \"$OUTPUT_FILENAME\"";
|
||||
my $OUTPUT = system( $COMMAND );
|
||||
if ( $OUTPUT == 2 ) { # do a clean exit with Ctrl+C
|
||||
unlink $TEMP;
|
||||
die "\nDownloading interrupted by user\n\n";
|
||||
} elsif ( $OUTPUT == 0 && length($CONTINUE)>0 ) { # do a clean exit with $FILENAME provided
|
||||
unlink $TEMP;
|
||||
die "\nDownloading complete\n\n";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user