mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
Added -0 flag to choose the first (0th) result
This commit is contained in:
parent
83c8289c8f
commit
323100ef59
@ -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('-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('--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('-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):
|
def local(args):
|
||||||
xml_str = ''
|
xml_str = ''
|
||||||
@ -119,16 +120,21 @@ def main():
|
|||||||
# enhanced print output with justified columns
|
# 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("+", " ") )
|
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:
|
if args.first:
|
||||||
l = raw_input("Select a link: ")
|
print "Choosing first result";
|
||||||
except KeyboardInterrupt :
|
choice = 0
|
||||||
print "\nCancelled."
|
|
||||||
exit()
|
|
||||||
|
|
||||||
try:
|
else:
|
||||||
choice = int(l)
|
try:
|
||||||
except Exception:
|
l = raw_input("Select a link: ")
|
||||||
choice = None
|
except KeyboardInterrupt :
|
||||||
|
print "\nCancelled."
|
||||||
|
exit()
|
||||||
|
|
||||||
|
try:
|
||||||
|
choice = int(l)
|
||||||
|
except Exception:
|
||||||
|
choice = None
|
||||||
|
|
||||||
if not choice == None:
|
if not choice == None:
|
||||||
url = mags[choice][0]
|
url = mags[choice][0]
|
||||||
|
Loading…
Reference in New Issue
Block a user