pass 'random' as argument to post a random comic that has not been published before
This commit is contained in:
parent
ce3ddc2d0d
commit
30a0c2a273
1 changed files with 8 additions and 1 deletions
|
@ -27,6 +27,8 @@ from bs4 import BeautifulSoup
|
||||||
import os
|
import os
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
import re
|
import re
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
instance = "https://botsin.space"
|
instance = "https://botsin.space"
|
||||||
baseurl = "https://wuzzy.neocities.org"
|
baseurl = "https://wuzzy.neocities.org"
|
||||||
|
@ -36,7 +38,12 @@ seendir = os.path.join(datadir, "seen")
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) > 1 :
|
if len(sys.argv) > 1 :
|
||||||
page = request.urlopen(baseurl+"/comic/"+sys.argv[1])
|
n = sys.argv[1]
|
||||||
|
if sys.argv[1] == "random" :
|
||||||
|
# try posting a random comic
|
||||||
|
l = max([int(re.sub("[^0-9]", "", i)) for i in os.listdir(seendir)])
|
||||||
|
n = str(random.randint(1, l))
|
||||||
|
page = request.urlopen(baseurl+"/comic/"+n)
|
||||||
else:
|
else:
|
||||||
page = request.urlopen(baseurl)
|
page = request.urlopen(baseurl)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue