Show HN: A Python Script to Download Thousands of Wallpapers at Once
github.com
github.com
In the choices section you use input("text") properly one place but not others. You use a couple different ways of decoding codes, and the dict way is nicer, but also consistency is nice. Also, I am not sure you handle bad input (default all?)...
Personally, I'd pull the meat out of the loops in main() into functions - GetImageList() and GetImage(). Relatively complex there so it would be easier to read and spot errors in those bits of code in isolation.
for i in range(len(imgid)):
and similar lines with: for i, img in enumerate(imgid):
would allow one to get rid of all these list accessors.Is there a simple Python equivalent to Java's .parallelStream().forEach() that would allow these calls to easily be run in parallel?
from multiprocessing import Pool
with Pool(8) as p:
p.map(function, sequence)) from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor as executor:
executor.map(function, sequence)I see that you explicitly specify 8 as the number of processes here. In Java, parallelStream() will pick a sane default for you if you haven't previously specified (based on the number of available processors, I believe). Is something like that possible in Python?
for x in $(curl -s https://alpha.wallhaven.cc/random | pcregrep -o1 "https://alpha.wallhaven.cc/wallpaper/(\d+)" | sort | uniq) ; do wget "https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-$x.jpg" ; done