Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Lottery mode clean up
Browse files Browse the repository at this point in the history
Lottery mode now uses random.shuffle() to select a random wallpaper
  • Loading branch information
cdglitch committed Dec 15, 2017
1 parent 0b73dea commit 6096034
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions wpreddit/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,14 @@ def get_links():
# takes in a list of links and attempts to find the first one that is a direct image link,
# is within the proper dimensions, and is not blacklisted
def choose_valid(links):
random.seed()

if len(links) == 0:
print("No links were returned from any of those subreddits. Are they valid?")
sys.exit(1)

nIter = 0
#for i, origlink in enumerate(links):
while (nIter < len(links)):
nIter += 1
i = random.randint(0, len(links))
if (config.lottery == True):
random.shuffle(links)

for i, origlink in enumerate(links):
origlink = links[i]
config.log("checking link # {0}: {1}".format(i, origlink))
link = origlink
Expand Down Expand Up @@ -143,4 +140,3 @@ def blacklist_current():
url = urlfile.read()
with open(config.walldir + '/blacklist.txt', 'a') as blacklist:
blacklist.write(url + '\n')

0 comments on commit 6096034

Please sign in to comment.