summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCallum Brown <callum@calcuode.com>2020-12-20 11:51:59 +0000
committerCallum Brown <callum@calcuode.com>2021-01-03 11:24:15 +0000
commit33a07650114ba382e4443b1ab93480ed3b60c86d (patch)
treefff3198500e70c38c5df75dd938e31fe512aead1
parent265a69a6eda3fbad235db1c68edb21add2845a7c (diff)
'url n' prints URL of item n
-rwxr-xr-xav98.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/av98.py b/av98.py
index f74b532..8c963fc 100755
--- a/av98.py
+++ b/av98.py
@@ -1480,8 +1480,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