Simple book downloader for e-libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import wget, os
print ("pyElibDownloader")
promptprefix = ("Enter prefix of download URL (default [http://elib.shpl.ru/pages/]): ")
prefix = input (promptprefix)
if prefix == "":
prefix = ("http://elib.shpl.ru/pages/")
promptpostfix = ("Enter postfix of download URL (default [/zooms/7]): ")
postfix = input (promptpostfix)
if postfix == "":
postfix = ("/zooms/7")
promptextension = ("Enter files extension (default [jpg]): ")
extension = input (promptextension)
if extension == "":
extension = ("jpg")
promptdir = ("Enter directory name: ")
dir = ""
while dir == "":
dir = input (promptdir)
promptfirstindex = ("Enter first index: ")
firstindex = ""
while firstindex == "":
firstindex = input (promptfirstindex)
promptlastindex = ("Enter last index: ")
lastindex = ""
while lastindex == "":
lastindex = input (promptlastindex)
print ("Starting donwload...")
try:
os.stat(dir)
except:
os.mkdir(dir)
os.chdir(dir)
index = int(firstindex)
lastindex = int(lastindex)
while index <= lastindex:
filename = str(index) + "." + extension
url = prefix + str(index) + postfix
try:
wget.download(url,out=filename)
except:
print ("...skipped...")
index = index + 1
print ("Donwload finished.")