Flights by route Spice Instant Answer

**What does your Instant Answer do?**
Allows users to search for real-time flight information by airline, source city, and destination city (this IA returns flight information for a 24-hour window starting six hours before the current time).

**What problem does your Instant Answer solve (Why is it better than organic links)?**
Organic links do not generally show real-time information about flights, even if they do link to the appropriate pages.

**What is the data source for your Instant Answer? (Provide a link if possible)**
Flightstats (http://www.flightstats.com)
The airlines and cities data files were scraped using the Flightstats API; I also included the scraping script (written in Python) in the shared directory.

**Why did you choose this data source?**
This is the same service that DDG currently uses for its Airlines IA.

**Are there any other alternative (better) data sources?**
Not that I know of/tried.

**What are some example queries that trigger this Instant Answer?**
"Jetblue Boston to Los Angeles", "Aer Lingus Boston to Paris"

**Which communities will this Instant Answer be especially useful for? (gamers, book lovers, etc)**
Travelers

**Is this Instant Answer connected to a DuckDuckHack [Instant Answer idea](https://duck.co/ideas)?**
Yes--this IA was developed in response to https://duck.co/ideas/idea/3931/list-of-flights-and-status-by-location

**Which existing Instant Answers will this one supersede/overlap with?**
Complements the Airlines Spice IA, which returns information by flight code. Much of the code for this IA is based on the Airlines Spice.

**Are you having any problems? Do you need our help with anything?**
No problems on my end, but I would appreciate all comments and feedback on how to make the answer run more efficiently on your servers, given the large trigger list (as well as any code improvements/suggestions in general!). Also, it would be great to know if it is possible to insert a regex  into the spice test file (I could not find a way to do it, but left a comment about what such a test might look like).

**What are the terms of use for the API? Will DuckDuckGo need specific authorization (e.g. an API key)? Are there any costs associated with API usage?**
Yes; DDG should already have an API app ID and key with FlightStats because of the Airlines Spice.

**What does the Instant Answer look like? (Provide a screenshot for new or updated Instant Answers)**
![screen shot 2014-10-22 at 2 41 51 am](https://cloud.githubusercontent.com/assets/5326740/4732215/def23e34-59b8-11e4-90f6-7564eeeaa8c9.png)
![screen shot 2014-10-22 at 2 42 22 am](https://cloud.githubusercontent.com/assets/5326740/4732216/e1248e1e-59b8-11e4-9820-9ec119671d36.png)


## Checklist
Please place an 'X' where appropriate.

```
[X] Added metadata and attribution information
[X] Wrote test file and added to t/ directory
[X] Verified that instant answer adheres to design guidelines (https://duck.co/duckduckhack/design_styleguide)
[X] Verified that instant answer adheres to code styleguide (https://duck.co/duckduckhack/code_styleguide)
[] Tested cross-browser compatibility

    Please let us know which browsers/devices you've tested on:
    - Windows 8
        [] Google Chrome
        [] Firefox
        [] Opera
        [] IE 10

    - Windows 7
        [] Google Chrome
        [] Firefox
        [] Opera
        [] IE 8
        [] IE 9
        [] IE 10

    - Windows XP
        [] IE 7
        [] IE 8

    - Mac OSX
        [] Google Chrome
        [X] Firefox
        [] Opera
        [X] Safari

    - iOS (iPhone)
        [] Safari Mobile
        [] Google Chrome
        [] Opera

    - iOS (iPad)
        [] Safari Mobile
        [] Google Chrome
        [] Opera

    - Android
        [] Firefox
        [] Native Browser
        [] Google Chrome
        [] Opera
```

This can be simplified:

- All of these have one thing in common. They look for the pattern `A to B` in our query string. That's super easy to detect with a simple regex. If that doesn't match we immediately know we likely don't have "To" and "From" locations so we can bail.

- Once we have those two things we can check them both to see if they exist in our hashes of city names and airport codes. If they both don't exist bail.
- Now that we have both we can strip them (and the word "to") from the query which should just leave one other phrase of 1+ words. Check if that exists in our hashes (we can even try and clean it up by removing common words like "Airport" if we want) to make the trigger a little more relaxed. If it doesn't exist bail.
- If we made it this far we should have everything we need to pass along to the API