diff --git a/ptgbot/bot.py b/ptgbot/bot.py index ced2434..d324d55 100644 --- a/ptgbot/bot.py +++ b/ptgbot/bot.py @@ -22,7 +22,6 @@ import irc.bot import json import logging.config import os -import requests import time import textwrap @@ -177,7 +176,7 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot): url = words[1] self.send(chan, "Loading DB from %s ..." % url) try: - self.data.import_json(requests.get(url).json()) + self.data.import_json(url) self.send(chan, "Done.") except Exception as e: self.send(chan, "Error loading DB: %s" % e) diff --git a/ptgbot/db.py b/ptgbot/db.py index eea8853..34fc725 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -19,6 +19,7 @@ import datetime import json import os import random +import requests class PTGDataBase(): @@ -45,9 +46,9 @@ class PTGDataBase(): self.save() - def import_json(self, jsondata): - # Update the DB with the data found in the provided JSON - self.data.update(jsondata) + def import_json(self, url): + # Update the DB with the JSON data found at URL + self.data.update(requests.get(url).json(object_pairs_hook=OrderedDict)) # Add tracks mentioned in configuration that are not in track list for room, bookings in self.data['schedule'].items():