diff --git a/uoftscrapers/scrapers/dates/__init__.py b/uoftscrapers/scrapers/dates/__init__.py index f434b7a..9432e1a 100644 --- a/uoftscrapers/scrapers/dates/__init__.py +++ b/uoftscrapers/scrapers/dates/__init__.py @@ -1,11 +1,33 @@ from ..utils import Scraper from .utsg import UTSGDates +from .utm import UTMDates + +from collections import OrderedDict class Dates: @staticmethod - def scrape(location='.'): + def scrape(location='.', year=None): Scraper.logger.info('Dates initialized.') - UTSGDates.scrape(location) + + docs = OrderedDict() + + for campus in UTSGDates, UTMDates: + dates = campus.scrape(location, year=year, save=False) + + if dates is None: + continue + + for date, doc in dates.items(): + if date not in docs: + docs[date] = OrderedDict([ + ('date', date), + ('events', []) + ]) + docs[date]['events'].extend(doc['events']) + + for date, doc in docs.items(): + Scraper.save_json(doc, location, date) + Scraper.logger.info('Dates completed.')