From 60c992580671e22b2b75132d248c682775c848b5 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Fri, 16 May 2014 21:38:20 +0200 Subject: [PATCH] add gdown.pl / update WinterMoon link to v1.2.3 --- ChangeLog | 2 ++ script.d/common.sh | 15 +++++++++-- script.d/wintermoon.sh | 2 +- tools/gdown.pl | 61 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 3 deletions(-) create mode 100755 tools/gdown.pl diff --git a/ChangeLog b/ChangeLog index 22e11bc..f8bba5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ v4.96: - wiimmfi/mkwiimm/kirbywii: minor improvements and fixups - support RVLution Wii (a NewSMB Mod) - update README.GAMEIDS +- update WinterMoon link to v1.2.3 +- added gdown.pl (google-drive downloader) by circulosmeos v4.95: - fixed storing NewSMB mods into ${PATCHIMAGE_GAME_DIR} diff --git a/script.d/common.sh b/script.d/common.sh index 99958fe..90a1fb2 100644 --- a/script.d/common.sh +++ b/script.d/common.sh @@ -40,6 +40,8 @@ setup_tools () { SZS=${PATCHIMAGE_TOOLS_DIR}/../override/linux${SUFFIX}/wszst fi + GDOWN=${PATCHIMAGE_TOOLS_DIR}/gdown.pl + } ask_game () { @@ -333,7 +335,16 @@ check_riivolution_patch () { ${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" >/dev/null || exit 63 elif [[ ${PATCHIMAGE_RIIVOLUTION_DOWNLOAD} == "TRUE" ]]; then x=4 - if [[ ${DOWNLOAD_LINK} ]]; then + if [[ ${DOWNLOAD_LINK} == *docs.google* ]]; then + if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then + x=5 + echo "*** >> downloading" + ${GDOWN} "${DOWNLOAD_LINK}" "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || exit 57 + mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" + echo "*** >> unpacking" + ${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" >/dev/null || exit 63 + fi + elif [[ ${DOWNLOAD_LINK} ]]; then if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then x=5 echo "*** >> downloading" @@ -360,7 +371,7 @@ download_covers () { for path in cover cover3D coverfull disc disccustom; do wget -O ${PATCHIMAGE_COVER_DIR}/${1}_${path}.png \ http://art.gametdb.com/wii/${path}/EN/${1}.png &>/dev/null \ - || ( echo "Cover (${path}) does not exists for gameid ${1}." && \ + || ( echo "Cover (${path}) does not exist for gameid ${1}." && \ rm ${PATCHIMAGE_COVER_DIR}/${1}_${path}.png ) done diff --git a/script.d/wintermoon.sh b/script.d/wintermoon.sh index a72e54e..9a19553 100644 --- a/script.d/wintermoon.sh +++ b/script.d/wintermoon.sh @@ -2,7 +2,7 @@ WORKDIR=nsmb.d DOL=${WORKDIR}/sys/main.dol -DOWNLOAD_LINK="https://www.dropbox.com/s/3wyc49450iiz2ok/WinterMoon.rar" +DOWNLOAD_LINK="https://docs.google.com/uc?id=0B0P-eSDZCIexTXdHZm5Xbk9HbEU&export=download" RIIVOLUTION_ZIP="WinterMoon.rar" RIIVOLUTION_DIR="WinterMoon" GAMENAME="SMMA+: Winter Moon" diff --git a/tools/gdown.pl b/tools/gdown.pl new file mode 100755 index 0000000..ae95440 --- /dev/null +++ b/tools/gdown.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl +# +# Google Drive direct download of big files +# ./gdown.pl 'gdrive file url' ['desired file name'] +# +# v1.0 by circulosmeos 04-2014. +# http://circulosmeos.wordpress.com/2014/04/12/google-drive-direct-download-of-big-files +# +use strict; + +my $TEMP='/tmp'; +my $COMMAND; +my $confirm; +my $check; +sub execute_command(); + +my $URL=shift; +die "\n./gdown.pl 'gdrive file url' [desired file name]\n\n" if $URL eq ''; +my $FILENAME=shift; +$FILENAME='gdown' if $FILENAME eq ''; + +execute_command(); + +while (-s $FILENAME < 100000) { # only if the file isn't the download yet + open fFILENAME, '<', $FILENAME; + $check=0; + foreach () { + if (/href="(\/uc\?export=download[^"]+)/) { + $URL='https://docs.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 fFILENAME; + die "Couldn't download the file :-(\n" if ($check==0); + $URL=~s/confirm=([^;&]+)/confirm=$confirm/ if $confirm ne ''; + + execute_command(); +} + +sub execute_command() { + $COMMAND="wget --load-cookie $TEMP/cookie.txt --save-cookie $TEMP/cookie.txt \"$URL\""; + $COMMAND.=" -O \"$FILENAME\"" if $FILENAME ne ''; + `$COMMAND`; + return 1; +}