From d3734a9a261d92ba853091f6aac18ec266e37661 Mon Sep 17 00:00:00 2001 From: Callum Brown Date: Sun, 20 Dec 2020 11:51:59 +0000 Subject: [PATCH] 'url n' prints URL of item n --- av98.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/av98.py b/av98.py index cf9493e..8327776 100755 --- a/av98.py +++ b/av98.py @@ -1482,8 +1482,25 @@ Use 'ls -l' to see URLs.""" @needs_gi def do_url(self, *args): - """Print URL of most recently visited item.""" - print(self.gi.url) + """Print the URL of an item. +'url' prints the URL of the most recently visited item. +'url n' prints the URL of item n.""" + # If no argument print current URL + if args[0] == '': + print(self.gi.url) + return + # If there is a valid integer argument print url of that item. + try: + n = int(args[0]) + except ValueError: + print("Invalid item number.") + return + try: + gi = self.lookup[n-1] + except IndexError: + print ("Index too high!") + return + print(gi.url) ### Bookmarking stuff @restricted