Skip to content

Commit

Permalink
Merge pull request alexgand#36 from chaosAD/master
Browse files Browse the repository at this point in the history
 Fixed problem of downloading PDF file twice
alexgand authored Apr 23, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 24bdaae + 13d9823 commit 1213cda
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ pip install -r requirements.txt
python main.py
```

### Virtual environment on Windows (Python 2.x):
### Virtual environment on Windows (Python 2.7.x):
```
python -m virtualenv .venv
cd .venv/Scripts
12 changes: 6 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -45,10 +45,10 @@
output_file = os.path.join(new_folder, final)

if not os.path.exists(output_file.encode('utf-8')):
with requests.get(new_url, stream=True) as r:
with requests.get(new_url, stream=True) as req:
try:
with open(output_file.encode('utf-8'), 'wb') as f:
shutil.copyfileobj(r.raw, f)
with open(output_file.encode('utf-8'), 'wb') as out_file:
shutil.copyfileobj(req.raw, out_file)
except OSError:
print("Error: PDF filename appears incorrect.")

@@ -67,10 +67,10 @@

request = requests.get(new_url)
if request.status_code == 200:
with requests.get(new_url, stream=True) as r:
with requests.get(new_url, stream=True) as req:
try:
with open(output_file.encode('utf-8'), 'wb') as f:
shutil.copyfileobj(r.raw, f)
with open(output_file.encode('utf-8'), 'wb') as out_file:
shutil.copyfileobj(req.raw, out_file)
except OSError:
print("Error: EPUB filename appears incorrect.")

0 comments on commit 1213cda

Please sign in to comment.