Skip to content

Commit

Permalink
Fix issue #1
Browse files Browse the repository at this point in the history
- Add back the Accept-Encoding header (#1)
- Fix get_remaining time from starting elapsed time
  • Loading branch information
daijro authored Mar 26, 2022
1 parent c19094c commit 9f9373a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ def _make_headers():
"""
Returns a dictionary of headers to be used in requests
"""
return {
key:value for key, value in Headers(headers=True).generate().items()
if key != 'Accept-Encoding'
}
h = dict(Headers(headers=True).generate().items())
h['Accept-Encoding'] = 'deflate'
return h


class ETA_(ETA):
Expand Down Expand Up @@ -56,6 +55,7 @@ def done(self):
return super().done()

def get_elapsed(self):
now = datetime.datetime.now()
if not self._started:
self._started = now
return 0
Expand All @@ -64,12 +64,11 @@ def get_elapsed(self):
return (td.days * 86400) + td.seconds

def get_remaining(self):
now = datetime.datetime.now()
elapsed = self.get_elapsed()

td = now - self.started
elapsed_sec = (td.days * 86400) + td.seconds
return self.ave_remaining(self.last_step, elapsed_sec)
return (
self.ave_remaining(self.last_step, elapsed_sec)
if (elapsed_sec := self.get_elapsed())
else None
)


class PHASE1:
Expand Down Expand Up @@ -416,4 +415,4 @@ def run(self, debug=False):
) + [self.pdf_file_name, self.pdf_file_name]
subprocess.run(cmd_args)
except FileNotFoundError as e:
raise self.exceptions.OCRFailed from e
raise self.exceptions.OCRFailed from e

0 comments on commit 9f9373a

Please sign in to comment.