1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-09 09:59:51 +01:00

Merge pull request #6 from gausie/small_changes

Added -0 flag to choose the first (0th) result
This commit is contained in:
Viktor Stanchev 2014-01-31 16:27:08 -08:00
commit 72692228bb
3 changed files with 25 additions and 16 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
pirate-get-*

View File

@ -1,22 +1,24 @@
#!/usr/bin/env sh
if [ "$UID" -ne 0 ]
then echo "Please run as root"
exit
fi
TMP=`mktemp pirate-get-XXX`
if [ `which python2.7` ]
TMP=$(mktemp pirate-get-XXX)
if [ $(which python2.7) ]
then
echo "#!/usr/bin/env python2.7" > $TMP
echo "#!/usr/bin/env python2.7" > "$TMP"
elif [ `which python2` ]
then
echo "#!/usr/bin/env python2" > $TMP
echo "#!/usr/bin/env python2" > "$TMP"
else
echo "#!/usr/bin/env python" > $TMP
echo "#!/usr/bin/env python" > "$TMP"
fi
sed 1d `dirname $0`/pirate-get.py >> $TMP
sed 1d $(dirname $0)/pirate-get.py >> "$TMP"
cp $TMP /usr/bin/pirate-get
cp "$TMP" /usr/bin/pirate-get
chmod +x /usr/bin/pirate-get
chmod 755 /usr/bin/pirate-get
rm "$TMP"

View File

@ -44,6 +44,7 @@ def main():
parser.add_argument('-t',dest='transmission',action='store_true', help="call transmission-remote to start the download", default=False)
parser.add_argument('--local', dest='database', help="An xml file containing the Pirate Bay database")
parser.add_argument('-p', dest='pages', help="The number of pages to fetch (doesn't work with --local)", default=1)
parser.add_argument('-0', dest='first', action='store_true', help="choose the top result", default=False)
def local(args):
xml_str = ''
@ -119,16 +120,21 @@ def main():
# enhanced print output with justified columns
print "%-5s %-6s %-6s %5.1f %-11s %-11s %s" % (m, magnet[1], magnet[2], ratio ,sizes[m], uploaded[m],urllib.unquote(name.group(1).encode('ascii')).decode('utf-8').replace("+", " ") )
try:
l = raw_input("Select a link: ")
except KeyboardInterrupt :
print "\nCancelled."
exit()
if args.first:
print "Choosing first result";
choice = 0
try:
choice = int(l)
except Exception:
choice = None
else:
try:
l = raw_input("Select a link: ")
except KeyboardInterrupt :
print "\nCancelled."
exit()
try:
choice = int(l)
except Exception:
choice = None
if not choice == None:
url = mags[choice][0]