Skip to content

Instantly share code, notes, and snippets.

@StyleT
Created February 16, 2014 11:16
Show Gist options
  • Save StyleT/9032651 to your computer and use it in GitHub Desktop.
Save StyleT/9032651 to your computer and use it in GitHub Desktop.
LostFilm.tv downloader (Mac OS X edition)
#!/bin/bash
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
#Get current directory and 'cd' to it
BASEDIR=$(dirname $0)
cd "$BASEDIR"
#LostFilm.tv
ua="Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.9 Safari/534.30"
lfrss="http://www.lostfilm.tv/rssdd.xml"
lfshows="(Black\.Sails|Musketeers|Almost\.Human|Under\.the\.Dome|Defiance|Bates\.Motel|Newsroom|Magic\.City|Hell\.On\.Wheels|Homeland|Revolution|Continuum|Elementary|Person\.of\.Interest|Cult|Anger\.Management|Transporter|Following|Anarchy|Philadelphia|Dexter|Californication|Castle|Lie\.To\.Me|Hawaii|Boardwalk.Empire|Sherlock|Thrones|Borgias|Falling\.Skies|Killing|Haven|Terra\.Nova)[^$]+(720p|HD)\."
lfcookie="Cookie: uid=%LF_USERID%; pass=%LF_PASS_COOKIE%; usess=%LF_TORRENT_SESSION%;"
#$(): assign output of shell command to variable
lfurl=$(curl -s --connect-timeout 5 --user-agent "$ua" --header "$lfcookie" "$lfrss" | grep -o -E "download.php[^ ]+\.torrent" | grep -E "$lfshows" | grep -v -E "\.WEB")
for k in $lfurl
do
if [ ! -e $(basename $k) ]; then #if torrent file not exist: [ -e filepath ] Returns true if file exists.
curl -s -O --referer "$lfrss" --user-agent "$ua" --header "$lfcookie" "http://lostfilm.tv/$k" # Download torrent files, and save it to curr dir
let newseries=1
fi
done
if [ "$newseries" = "1" ]; then
terminal-notifier -title "LostFilm.tv" -message "Обнаружена новая серия" -open "http://www.lostfilm.tv"
afplay "/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/system/burn complete.aif"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment