Skip to content

Commit

Permalink
Fixed error parsing time for json shifts. When it fails i now catch i…
Browse files Browse the repository at this point in the history
…t and return None
  • Loading branch information
HarryShomer committed Oct 6, 2019
1 parent 8e15679 commit dab4624
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hockey_scraper/utils/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
import warnings
import requests
import datetime
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from . import save_pages as sp
Expand Down Expand Up @@ -187,8 +188,11 @@ def convert_to_seconds(minutes):
if minutes == '-16:0-':
return '1200' # Sometimes in the html at the end of the game the time is -16:0-

import datetime
x = time.strptime(minutes.strip(' '), '%M:%S')
# If the time is junk not much i can do
try:
x = time.strptime(minutes.strip(' '), '%M:%S')
except ValueError:
return None

return datetime.timedelta(hours=x.tm_hour, minutes=x.tm_min, seconds=x.tm_sec).total_seconds()

Expand Down

0 comments on commit dab4624

Please sign in to comment.