Commit bcbcea99 authored by Nolan Darilek's avatar Nolan Darilek
Browse files

Initial commit.

# GTFS Skill
Ask [Mycroft]( about data in [General Transit Feed Specification]( format. Supported queries will include:
* "Tell me about stop 1068.": Provides a brief description of the stop and lists the next departure.
* "Which stop is on the south corner of Woodrow and Anderson?": Performs fuzzy string searches against stop descriptions. May not be accurate in all areas.
* "When is the next 323 westbound from stop 1068?": Searches static and real-time feeds for the next departure of the specified bus.
* "Alert me 10 minutes before the next 323 westbound departs stop 1068.": Trigger an alarm when the specified line is about to depart.
* "Refresh transit data.": Refreshes the locally cached GTFS static data. This also happens on a regular, daily schedule.
from os.path import dirname, exists, join
from adapt.intent import IntentBuilder
# import geopandas
from mycroft.skills.core import MycroftSkill, intent_handler
from mycroft.util.log import getLogger
import pygtfs
import requests
__author__ = 'Nolan Darilek'
# Logger: used for debug lines, like "LOGGER.debug(xyz)". These
# statements will show up in the command line when running Mycroft.
LOGGER = getLogger(__name__)
class GtfsSkill(MycroftSkill):
def __init__(self):
super(GtfsSkill, self).__init__(name="GtfsSkill")
self.schedule = pygtfs.Schedule(join(self.file_system.path, "gtfs.db"))
self.gtfs_path = join(self.file_system.path, "")
def initialize(self):
super(GtfsSkill, self).initialize()
if not exists(self.gtfs_path) and self.config.get("gtfsURL"):
self.refresh_gtfs(speak_messages = True)
def refresh_gtfs(self, speak_messages=False):
if speak_messages:
response = requests.get(self.config.get("gtfsURL"), allow_redirects=True)
gtfs ="", "w")
if speak_messages:
pygtfs.overwrite_feed(self.schedule, join(self.file_system.path,
if speak_messages:
def handle_refresh_intent(self, message):
self.refresh_gtfs(speak_messages = True)
def handle_stop_info_intent(self, message):
def stop(self):
def create_skill():
return GtfsSkill()
Import of transit data complete.
Import of transit feed complete.
Import of transit data finished.
Import of transit feed finished.
Import of transit data done.
Import of transit feed done.
Done importing transit data.
Importing transit data. This may take a while.
Refreshing transit data.
Updating transit data.
Refreshing transit details.
Updating transit details.
Refreshing transit feed.
Updating transit feed.
Please wait.
Please be patient.
Any time.
Glad to be of service.
Glad to help.
My Pleasure.
No problem.
You're welcome.
(on|for|about) (?P<Stop>.*)
"identifier": "GtfsSkill",
"name": "GTFS Transit",
"skillMetadata": {
"sections": [
"name": "Options",
"fields": [
"type": "label",
"label": "URL to the GTFS feed you wish to track"
"name": "gtfsURL",
"type": "text",
"label": "GTFS feed URL",
"value": ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment