2016-07-20 17:22:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# Simple slideshare downloader
|
|
|
|
# By Daniil Gentili (https://daniil.it)
|
|
|
|
# Licensed under GPLv3
|
|
|
|
# Copyright 2016 Daniil Gentili
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
echo "Simple slideshare downloader Copyright (C) 2016 Daniil Gentili.
|
|
|
|
This program comes with ABSOLUTELY NO WARRANTY; for details see
|
2016-09-26 15:54:14 +02:00
|
|
|
https://github.com/danog/simple-slideshare-downloader/blob/master/LICENSE.
|
2016-07-20 17:22:45 +02:00
|
|
|
This is free software, and you are welcome to redistribute it
|
|
|
|
under certain conditions: see https://github.com/danog/simple-slideshare-downloader/blob/master/LICENSE.
|
|
|
|
"
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "Usage: $0 URL"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
[ -z "$*" ] && usage
|
2016-08-26 02:33:17 +02:00
|
|
|
|
2016-07-20 17:22:45 +02:00
|
|
|
for f in $*;do
|
2016-08-26 02:33:17 +02:00
|
|
|
TOCONV=""
|
2016-07-20 17:22:45 +02:00
|
|
|
echo "Downloading $f..."
|
|
|
|
PAGE="$(curl -s "$f")"
|
2016-08-20 19:57:46 +02:00
|
|
|
URLS=$(echo "$PAGE" | sed '/data-normal/!d;s/.*data-normal="//;s/\s.*//g' | tr -s '\n' ' ')
|
|
|
|
TITLE=$(echo "$PAGE" | sed '/[<]title[>]/!d;s/.*[<]title[>]//g;s/[<]\/title[>].*//g')
|
2016-08-20 20:08:15 +02:00
|
|
|
SAFETITLE="${TITLE//[^a-zA-Z0-9 ]/}"
|
|
|
|
SAFETITLE=$(echo "$SAFETITLE" | sed 's/^\s*//g;s/\s*$//g')
|
|
|
|
SAFETITLE="${SAFETITLE// /_}"
|
|
|
|
mkdir "$SAFETITLE"
|
2016-08-20 19:57:46 +02:00
|
|
|
for URL in $URLS;do
|
2016-08-20 20:08:15 +02:00
|
|
|
FNAME="$SAFETITLE/"$(echo "$URL" | sed 's/\?.*//g;s/.*\///g')
|
2016-08-20 19:57:46 +02:00
|
|
|
curl -sL "$URL" -o "$FNAME"
|
|
|
|
TOCONV="$TOCONV $FNAME"
|
2016-07-20 17:22:45 +02:00
|
|
|
done
|
2016-08-20 19:57:46 +02:00
|
|
|
convert $TOCONV -gravity South -annotate 0 '%f' "$TITLE".pdf
|
2016-08-20 20:08:15 +02:00
|
|
|
mv "$SAFETITLE" "$TITLE"
|
2016-08-20 19:57:46 +02:00
|
|
|
echo "Saved in $TITLE.pdf, source images are in $TITLE/."
|
2016-07-20 17:22:45 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "Bye!"
|
|
|
|
exit
|