diff options
-rw-r--r-- | bin/import_cals.py | 6 | ||||
-rw-r--r-- | config/reddit-import.json | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/bin/import_cals.py b/bin/import_cals.py index 8b32691..ef49e89 100644 --- a/bin/import_cals.py +++ b/bin/import_cals.py @@ -29,7 +29,7 @@ def get_cal_list(): opener = urllib2.build_opener() opener.addheaders = [('User-Agent', CONFIG['user_agent'])] cal_list = json.loads(opener.open(CONFIG['reddit_url']).read()) - cal_list = cal_list[0]['data']['children'][0]['data']['selftext'] + cal_list = cal_list['data']['content_md'] with open(cache_path, 'w') as cache_file: cache_file.write(cal_list) cache_file.close() @@ -69,7 +69,7 @@ def update_calendar(cal, session): def get_imported_calendars(cells, ical_markdown): imported_calendars = [] for row in cells: - row = [r for r in row if r] + row = [r for r in row if r.strip()] if len(row) == 5: markdown_match = re.match(ical_markdown, row[2]) if markdown_match: @@ -82,7 +82,7 @@ def get_imported_calendars(cells, ical_markdown): 'uid': ical_path[0], 'url': ical_url.geturl(), 'name': row[0], - 'website': row[4], + 'website': row[4].split()[0], 'category': row[1] }) else: diff --git a/config/reddit-import.json b/config/reddit-import.json index f34d522..4bbd6ca 100644 --- a/config/reddit-import.json +++ b/config/reddit-import.json @@ -1,6 +1,6 @@ { "cache": "../cache/list.md", "cache_time": 86400, - "reddit_url": "https://www.reddit.com/r/MotorsportsCalendar/comments/45uv93/2016_calendar_list.json", + "reddit_url": "https://www.reddit.com/r/MotorsportsCalendar/wiki/calendar_list.json", "user_agent": "/u/emkael" } |