Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

TED Talks

# Filename:
# Version: 040716
# Author: robz
# A raspi script for downloading TED talks video using off peak bandwidth.
# Used as part of the interactive script or just run in a terminal.
# You may need to "apt-get install at" this will also install heirloom-mailx
# packages but these can be removed afterwards if you wish without affecting
# the operation of the "at" utility.
ted="$dwn/ted"                                      # Downloaded media here.
rss="$dwn/scripts/ted-rss.txt"                      # Feed location.
don="$dwn/scripts/ted-donelist.txt"                 # Shows already downloaded.
num="29"                                            # Number of choices in list.
# Get rss feed, refresh weekly.
if [[ ! -e "$rss" || $(find "$rss" -mtime +7) ]]; then
    echo "please wait - downloading new feed."
    wget -q -O - "" > "$rss"
# Display choices list. (suits an 80 column terminal) 
lst=$(grep "<title" "$rss" | sed -e 's/<[^>]*>//g;1,2d;s/^[ \t]*//' | \
grep -v "$(sed 's/|.*//' < "$don")")                # Make list, exclude done.
top=$(sed q <<< "$lst")                             # Extract newest not viewed.
lst=$(grep -v "$top" <<< "$lst")                    # Remove duplicate entry.
lst=$(shuf -n"$num" <<< "$lst")                     # Shuffle the rest of list.
lst=$(echo -e "$top\n$lst")                         # Put newest talk at top.
echo " Popular TED talks."
echo -e "\n$lst\n" | nl -w3 -s ') ' | cut -c -79    # Number and trim to width.
# Choose your TED talk.
read -p " Type in number - Enter, or just enter to cancel: " ans
# Reject nonsense inputs.
if [[ "$ans" -gt "$(( num+1 ))" || "$ans" -lt "1" ]]; then
    echo " Incorrect input, Hit enter."
# Parse information for donelist and download.
tlk=$(echo "$lst" | sed "${ans}q;d")
echo -n "$tlk| " >> "$don"                          # Add title to donelist.
echo -e "\n $tlk"
tlk=$(grep -A4 "$tlk" "$rss" | grep "<enclosure" | \
sed 's/<.*url=\"//;s/\".*>//;s/^[ \t]*//')          # Parse url to download.
# Set job content and time to download.
echo "wget --content-disposition -P "$ted" "$tlk"" | at 01:11 > /dev/null 2>&1
echo " $tlk" | tee -a "$don"                        # Echo url & add to done.
echo -e "$(atq)\n Pending @ 01:11"                  # Query "at" to check job.

No comments: