Skip to content

Commit 27067bf

Browse files
committed
1 parent 4b5d863 commit 27067bf

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

mtapi/mtapi.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ def serialize(self):
5656

5757

5858
_FEED_URLS = [
59-
'http://datamine.mta.info/mta_esi.php?feed_id=1', # 123456S
60-
'http://datamine.mta.info/mta_esi.php?feed_id=2', # L
61-
'http://datamine.mta.info/mta_esi.php?feed_id=16', # NRQW
62-
'http://datamine.mta.info/mta_esi.php?feed_id=21', # BDFM
63-
'http://datamine.mta.info/mta_esi.php?feed_id=26', # ACE
64-
'http://datamine.mta.info/mta_esi.php?feed_id=51', # 7
65-
'http://datamine.mta.info/mta_esi.php?feed_id=36', # JZ
66-
'http://datamine.mta.info/mta_esi.php?feed_id=31' # G
59+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs', # 123456S
60+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-l', # L
61+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-nqrw', # NRQW
62+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-bdfm', # BDFM
63+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-ace', # ACE
64+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-7', # 7
65+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-jz', # JZ
66+
'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-g' # G
6767
]
6868

6969
def __init__(self, key, stations_file, expires_seconds=60, max_trains=10, max_minutes=30, threaded=False):
@@ -77,8 +77,6 @@ def __init__(self, key, stations_file, expires_seconds=60, max_trains=10, max_mi
7777
self._routes = {}
7878
self._read_lock = threading.RLock()
7979

80-
self._FEED_URLS = self._init_feeds_key(key, self._FEED_URLS)
81-
8280
# initialize the stations database
8381
try:
8482
with open(stations_file, 'rb') as f:
@@ -97,10 +95,6 @@ def __init__(self, key, stations_file, expires_seconds=60, max_trains=10, max_mi
9795
self.threader = _MtapiThreader(self, expires_seconds)
9896
self.threader.start_timer()
9997

100-
@staticmethod
101-
def _init_feeds_key(key, urls):
102-
return list(map(lambda x: x + '&key=' + key, urls))
103-
10498
@staticmethod
10599
def _build_stops_index(stations):
106100
stops = {}
@@ -110,10 +104,11 @@ def _build_stops_index(stations):
110104

111105
return stops
112106

113-
@staticmethod
114-
def _load_mta_feed(feed_url):
107+
def _load_mta_feed(self, feed_url):
115108
try:
116-
with contextlib.closing(urllib2.urlopen(feed_url)) as r:
109+
request = urllib2.Request(feed_url)
110+
request.add_header('x-api-key', self._KEY)
111+
with contextlib.closing(urllib2.urlopen(request)) as r:
117112
data = r.read()
118113
return FeedResponse(data)
119114

0 commit comments

Comments
 (0)