Fixes for magnets

This commit is contained in:
DarkFeather 2017-09-19 16:38:39 -05:00
parent f0482b7a22
commit e7c96f98bb
1 changed files with 10 additions and 14 deletions

View File

@ -1,5 +1,8 @@
#!/bin/bash #!/bin/bash
## Vars ##
pullcmd='wget --timeout=5 -q -O -'
## Visual Functions ## ## Visual Functions ##
# These function creates a visual indicator that a step has happened. # These function creates a visual indicator that a step has happened.
function header () { function header () {
@ -232,8 +235,13 @@ function getmagnetlink {
fi fi
searchstring="$(echo "$1" | sed "s/ /$searchunifier/g")" searchstring="$(echo "$1" | sed "s/ /$searchunifier/g")"
searchlink="$(printf "$torrentengine" "$searchstring")" searchlink="$(printf "$torrentengine" "$searchstring")"
searchresult="$(wget --timeout=5 -q -O - "$searchlink" | bash -c "$torrentterms")" /bin/bash -c "$pullcmd "$searchlink" &>/dev/null"
magnetlink="$(wget --timeout=5 -q -O - "$searchresult" | grep 'magnet:?' | cut -f "$magnetposition" -d \"| head -n 1)" if [ $? -ne 0 ]; then
errorheader Could not pull search results.
exit 1
fi
searchresult="$(/bin/bash -c "$pullcmd $searchlink" | bash -c "$torrentterms")"
magnetlink="$(/bin/bash -c "$pullcmd $searchresult" | grep 'magnet:?' | cut -f "$magnetposition" -d \"| head -n 1)"
if [ $torrentdebugging == "true" ]; then if [ $torrentdebugging == "true" ]; then
echo '<'$searchstring'>' echo '<'$searchstring'>'
echo '<'$searchlink'>' echo '<'$searchlink'>'
@ -241,15 +249,3 @@ function getmagnetlink {
echo '<'$magnetlink'>' echo '<'$magnetlink'>'
fi fi
} }
# Download a link
function torrentlink {
if [ ! -d "$downloaddir" ]; then
errorheader "Cannot download -- downloaddir does not exist"
exit 1;
fi
if [ ! -z "$magnetlink" ]; then
/usr/bin/transmission-cli -d 1000 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
rm -Rf ~/.config/transmission/resume/*
rm -Rf ~/.config/transmission/torrents/*
fi
}