Skip to content

Instantly share code, notes, and snippets.

@gideon-maina
Last active July 22, 2017 16:58
Show Gist options
  • Save gideon-maina/7edfcc17bf4c4d9b0bd977b6e978cfbf to your computer and use it in GitHub Desktop.
Save gideon-maina/7edfcc17bf4c4d9b0bd977b6e978cfbf to your computer and use it in GitHub Desktop.
Description : Generate a URL for downloading read the docs, # docs as PDF and download the doc for you. # Credits : http://natanyellin.com/2012/04/22/downloading-pdf-documentation-for-readthedocs-projects/
#!/bin/bash
# Author : Gideon Kamau Maina <[email protected]>
# Date : 21-07-2017
# Description : Generate a URL for downloading read the docs,
# docs as PDF and download the doc for you.
# Credits : http://natanyellin.com/2012/04/22/downloading-pdf-documentation-for-readthedocs-projects/
# Constants
PROMPT=">>: "
# Ask for the package name
echo "Enter the name of the package as it appears in readthedocs.org"
echo "e.g marshmallow, django-tastypie"
read -p $PROMPT PACKAGE_NAME
# Construct the URL
URL="http://media.readthedocs.org/pdf/${PACKAGE_NAME}/latest/${PACKAGE_NAME}.pdf"
# Download the pdf file to location set by user
echo "Enter where you want your doc to be downloaded e.g /folder"
echo "Note this is relative to your home folder. Default Downloads."
read -p $PROMPT DOWNLOAD_LOCATION
DOWNLOAD_LOCATION=${DOWNLOAD_LOCATION:-Downloads}
# Add the home DIR to the entered location
cd "/home/${USER}/${DOWNLOAD_LOCATION}"
curl -O $URL
# Inform User of the process
echo "Package ${PACKAGE_NAME} pdf DOC downloaded to ${DOWNLOAD_LOCATION}"
echo
echo "Thanks ;)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment