From d31ff6a0ea2ffd9a84f2e3193f40587bfe109e2c Mon Sep 17 00:00:00 2001 From: khuxkm fbexl Date: Wed, 18 Nov 2020 00:25:17 +0000 Subject: [PATCH] Automatically retry index with trailing slash I wasn't too clear about this originally but I'd like the URLs in the orbit to come with a trailing slash. In case someone left it off, we'll try adding it back. --- molniya.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/molniya.py b/molniya.py index a222e78..4ad6589 100644 --- a/molniya.py +++ b/molniya.py @@ -21,10 +21,15 @@ CURRENT_URL_PARSED = urllib.parse.urlparse(CURRENT_URL) try: CURRENT_URL_INDEX = URLS.index(CURRENT_URL) except: - CURRENT_URL = MAIN_PAGE - # place the index somewhere random in the list - # this should alleviate the issue of what happens when someone not in the list tries to link to the list - CURRENT_URL_INDEX = random.randrange(len(URLS)) + # I wasn't clear about trailing slashes, maybe add one on? + CURRENT_URL += "/" + try: + CURRENT_URL_INDEX = URLS.index(CURRENT_URL) + except: + CURRENT_URL = MAIN_PAGE + # place the index somewhere random in the list + # this should alleviate the issue of what happens when someone not in the list tries to link to the list + CURRENT_URL_INDEX = random.randrange(len(URLS)) def next_url(): return URLS[(CURRENT_URL_INDEX+1)%len(URLS)]