Skip to content

Commit

Permalink
Change shuttle -> shuttles & use seconds for time
Browse files Browse the repository at this point in the history
  • Loading branch information
qasim committed Apr 28, 2016
1 parent b6f01f6 commit d0783d3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'uoftscrapers.scrapers.exams',
'uoftscrapers.scrapers.athletics',
'uoftscrapers.scrapers.parking',
'uoftscrapers.scrapers.shuttle',
'uoftscrapers.scrapers.shuttles',
'uoftscrapers.scrapers.events',
'uoftscrapers.scrapers.libraries'
],
Expand Down
2 changes: 1 addition & 1 deletion uoftscrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from .scrapers.parking import Parking

from .scrapers.shuttle import Shuttle
from .scrapers.shuttles import Shuttles

from .scrapers.events import Events

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import time


class Shuttle:
class Shuttles:
"""A scraper for UofT's shuttle bus schedule.
The schedule is located at https://m.utm.utoronto.ca/shuttle.php.
The schedule is located at https://m.utm.utoronto.ca/Shuttles.php.
"""

host = 'https://m.utm.utoronto.ca/shuttleByDate.php?year=%s&month=%s&day=%s'
Expand All @@ -36,8 +36,8 @@ def scrape(location='.', month=None):
'Fetching schedules for {0}-{1}-01 to {0}-{1}-{2}.'.format(year, month, days))

for day in range(1, days + 1):
html = Scraper.get(Shuttle.host % (year, month, day))
schedule = Shuttle.parse_schedule_html(html)
html = Scraper.get(Shuttles.host % (year, month, day))
schedule = Shuttles.parse_schedule_html(html)

Scraper.save_json(schedule, location, schedule['date'])

Expand Down Expand Up @@ -73,18 +73,20 @@ def parse_schedule_html(html):
time_rush_hour = 'rush hour' in _route_time_text
time_no_overload = 'no overload' in _route_time_text

military_time = time.strftime('%H:%M %p',
time.strptime(_route_time_clean, '%I:%M %p'))[:-3]
military_time = [int(x) for x in military_time.split(':')]

seconds = military_time[0] * 3600 + military_time[1] * 60

times.append(OrderedDict([
('time', '%sT%s:00-04:00' % (
date,
time.strftime('%H:%M %p', time.strptime(
_route_time_clean, '%I:%M %p'))[:-3]
)),
('time', seconds),
('rush_hour', time_rush_hour),
('no_overload', time_no_overload)
]))

# TODO: fetch this dynamically
route_building_id = Shuttle.building_ids[route_location] if route_location in Shuttle.building_ids else ''
route_building_id = Shuttles.building_ids[route_location] if route_location in Shuttles.building_ids else ''

route_stops = OrderedDict([
('location', route_location),
Expand Down

0 comments on commit d0783d3

Please sign in to comment.