Skip to content

Commit

Permalink
Delete cookie file gdown.cookie.temp only if it doesn't exist when sc…
Browse files Browse the repository at this point in the history
…ript starts
  • Loading branch information
circulosmeos committed May 12, 2023
1 parent 3248b1d commit ff169dc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gdown.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
my $FILENAME=shift;
my $TEMP_FILENAME='gdown.'.strftime("%Y%m%d%H%M%S", localtime).'.'.substr(rand,2);

my $TEMP_exists = 0;
if (-e $TEMP) {
$TEMP_exists = 1;
}

if ($URL=~m#^https?://drive.google.com/file/d/([^/]+)#) {
$URL="https://docs.google.com/uc?id=$1&export=download";
}
Expand Down Expand Up @@ -68,7 +73,7 @@

}

unlink $TEMP;
unlink $TEMP if !$TEMP_exists;

sub execute_command() {
my $OUTPUT_FILENAME = $TEMP_FILENAME;
Expand All @@ -94,10 +99,10 @@ ()
$COMMAND.=" -O \"$OUTPUT_FILENAME\"";
my $OUTPUT = system( $COMMAND );
if ( $OUTPUT == 2 ) { # do a clean exit with Ctrl+C
unlink $TEMP;
unlink $TEMP if !$TEMP_exists;
die "\nDownloading interrupted by user\n\n";
} elsif ( $OUTPUT == 0 && length($CONTINUE)>0 ) { # do a clean exit with $FILENAME provided
unlink $TEMP;
unlink $TEMP if !$TEMP_exists;
die "\nDownloading complete\n\n";
}
return 1;
Expand Down

0 comments on commit ff169dc

Please sign in to comment.