Skip to content

Instantly share code, notes, and snippets.

@tobiasBora
Created January 29, 2018 13:52
Show Gist options
  • Save tobiasBora/20560a360fc9fc0512f6084a39edb377 to your computer and use it in GitHub Desktop.
Save tobiasBora/20560a360fc9fc0512f6084a39edb377 to your computer and use it in GitHub Desktop.
Easy way to locally setup scribd download, firefox, selenium, geckodriver... and make sure that you don't have outdated version.
#!/usr/bin/env bash
set -e
function usage_end(){
echo "======================================"
echo "Great, you downloaded everything."
echo "Now (and later), just run the following to load the path:"
echo "$ bash set_up_local_scribd_download.sh"
echo "And then use the scribd downloader like this:"
echo "$ scribd_downloader_3.py <your url> <your output.pdf>"
echo "E.g:"
echo "$ scribd_downloader_3.py https://www.scribd.com/doc/63942746/chopin-nocturne-n-20-partition chopin.pdf"
echo "If if fails, then please report here:"
echo " https://github.com/tobiasBora/scribd-downloader-3/issues/"
echo "Enjoy !"
}
if [ -d "./download_everything" ]
then
echo "======================================"
echo "It looks like you already ran this script before."
echo "So I'll define for you all the environment variable"
cd download_everything
source venv/bin/activate
export PATH="$(pwd):$(pwd)/scribd-downloader-3:$(pwd)/firefox:$PATH"
echo "Great, now you can just run :"
echo "$ scribd_downloader_3.py <your url> <your output.pdf>"
echo "E.g:"
echo "$ scribd_downloader_3.py https://www.scribd.com/doc/63942746/chopin-nocturne-n-20-partition chopin.pdf"
echo "Enjoy !"
exit 0
fi
mkdir download_everything
cd download_everything
# Make sure virtualenv is installed and has last version
if ! which pip3 > /dev/null; then
echo "/!\ pip3 is not installed."
echo "Please, make sure to install it using something like:"
echo "sudo apt-get install python3-pip"
echo "For more details, see https://stackoverflow.com/questions/6587507/how-to-install-pip-with-python-3"
exit 1
fi
pip3 install --user virtualenv
pip3 install --upgrade virtualenv
# Create a new virtual env
virtualenv -p python3 venv
# Activate it
source venv/bin/activate
pip3 install selenium
pip3 install fpdf
pip3 install Pillow
git clone https://github.com/tobiasBora/scribd-downloader-3.git
export PATH="$(pwd)/scribd-downloader-3:$PATH"
# Detect architecture
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine="Linux";;
*) echo "Machine not supported, please report back if you have any problem."
exit 1
esac
if [ "$machine" == "Linux" ]; then
archs=`uname -m`
case "$archs" in
i?86) arch="linux32" ;;
x86_64) arch="linux64" ;;
*) arch="Architecture not supported, please report back if you have any problem." ;;
esac
fi
# Download firefox
case "${arch}" in
linux32) wget https://ftp.mozilla.org/pub/firefox/releases/58.0/linux-i686/en-GB/firefox-58.0.tar.bz2
tar jxvf firefox-58.0.tar.bz2;;
linux64) wget https://ftp.mozilla.org/pub/firefox/releases/58.0/linux-x86_64/en-GB/firefox-58.0.tar.bz2
tar jxvf firefox-58.0.tar.bz2;;
esac
export PATH="$(pwd)/firefox:$PATH"
# Download geckodriver
case "${arch}" in
linux32*) wget https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux32.tar.gz
tar zxvf geckodriver-v0.19.1-linux32.tar.gz;;
linux64*) wget https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz
tar zxvf geckodriver-v0.19.1-linux64.tar.gz;;
esac
export PATH="$(pwd):$PATH"
# Test
echo "$PATH"
usage_end
exec /bin/bash
@yaasin12
Copy link

how can i use this? help please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment