MouseTools 2.1.2.dev2__py3-none-any.whl → 3.0.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mousetools/attractions.py DELETED
@@ -1,370 +0,0 @@
1
- """
2
- attractions module
3
- """
4
- import json
5
- from datetime import datetime, timedelta
6
- import requests
7
- import pytz
8
- from .auth import get_headers
9
- from .ids import themeparkapi_ids, WDW_ID, DLR_ID
10
-
11
-
12
-
13
- class Attraction:
14
-
15
- def __init__(self, id = None):
16
- """
17
- Constructor Function
18
- Gets all attraction data available and stores various elements into variables.
19
- """
20
-
21
- error = True
22
- self.__data = requests.get(f"https://api.wdpro.disney.go.com/global-pool-override-B/facility-service/attractions/{id}", headers=get_headers()).json()
23
- try:
24
- if self.__data['id'] is not None:
25
- error = False
26
- except:
27
- pass
28
-
29
- if error:
30
- raise ValueError('That attraction is not available. id: ' + str(id))
31
-
32
- self.__id = id
33
- self.__name = self.__data['name']
34
- self.__entityType = self.__data['type']
35
- try:
36
- self.__subType = self.__data['subType']
37
- except:
38
- self.__subType = None
39
-
40
- try:
41
- self.__anc_dest_id = self.__data['ancestorDestination']['id'].split(';')[0]
42
- except:
43
- self.__anc_dest_id = None
44
-
45
- try:
46
- self.__anc_park_id = self.__data['links']['ancestorThemePark']['href'].split('/')[-1].split('?')[0]
47
- except:
48
- try:
49
- self.__anc_park_id = self.__data['links']['ancestorWaterPark']['href'].split('/')[-1].split('?')[0]
50
- except:
51
- try:
52
- self.__anc_park_id = self.__data['ancestorThemeParkId'].split(';')[0]
53
- except:
54
- try:
55
- self.__anc_park_id = self.__data['ancestorWaterParkId'].split(';')[0]
56
- except:
57
- self.__anc_park_id = None
58
-
59
- try:
60
- self.__anc_resort_id = self.__data['links']['ancestorResort']['href'].split('/')[-1].split('?')[0]
61
- except:
62
- try:
63
- self.__anc_resort_id = self.__data['ancestorResortId'].split(';')[0]
64
- except:
65
- self.__anc_resort_id = None
66
-
67
- try:
68
- self.__anc_land_id = self.__data['links']['ancestorLand']['href'].split('/')[-1].split('?')[0]
69
- except:
70
- try:
71
- self.__anc_land_id = self.__data['ancestorLandId'].split(';')[0]
72
- except:
73
- self.__anc_land_id = None
74
-
75
- try:
76
- self.__anc_ra_id = self.__data['links']['ancestorResortArea']['href'].split('/')[-1].split('?')[0]
77
- except:
78
- try:
79
- self.__anc_ra_id = self.__data['ancestorResortAreaId'].split(';')[0]
80
- except:
81
- self.__anc_ra_id = None
82
-
83
- try:
84
- self.__anc_ev_id = self.__data['links']['ancestorEntertainmentVenue']['href'].split('/')[-1].split('?')[0]
85
- except:
86
- try:
87
- self.__anc_ev_id = self.__data['ancestorEntertainmentVenueId'].split(';')[0]
88
- except:
89
- self.__anc_ev_id = None
90
-
91
- if self.__anc_dest_id == WDW_ID:
92
- self.__time_zone = pytz.timezone('US/Eastern')
93
- elif self.__anc_dest_id == DLR_ID:
94
- self.__time_zone = pytz.timezone('US/Pacific')
95
- else:
96
- self.__time_zone = pytz.utc
97
-
98
-
99
- def get_id(self):
100
- """Return object id"""
101
- return self.__id
102
-
103
- def get_name(self):
104
- """Return object name"""
105
- return self.__name
106
-
107
- def get_entityType(self):
108
- """Return object entityType"""
109
- return self.__entityType
110
-
111
- def get_subType(self):
112
- """Return object subType"""
113
- return self.__subType
114
-
115
- def get_ancestor_destination_id(self):
116
- """Return object ancestor destination id"""
117
- return self.__anc_dest_id
118
-
119
- def get_ancestor_park_id(self):
120
- """Return object ancestor theme or water park id"""
121
- return self.__anc_park_id
122
-
123
- def get_ancestor_resort_id(self):
124
- """Return object ancestor resort id"""
125
- return self.__anc_resort_id
126
-
127
- def get_ancestor_land_id(self):
128
- """Return object land id"""
129
- return self.__anc_land_id
130
-
131
- def get_ancestor_resort_area_id(self):
132
- """Return object resort area id"""
133
- return self.__anc_ra_id
134
-
135
- def get_ancestor_entertainment_venue_id(self):
136
- """Return object entertainment venue id"""
137
- return self.__anc_ev_id
138
-
139
- def get_links(self):
140
- """Returns a dictionary of related links"""
141
- return self.__data['links']
142
-
143
- def get_time_zone(self):
144
- """Returns pytz timezone object"""
145
- return self.__time_zone
146
-
147
- def get_raw_data(self):
148
- """Returns the raw data from global-facility-service"""
149
- return self.__data
150
-
151
- def get_themeparkapi_data(self):
152
- """Returns the dictionary from the themepark api for the given id"""
153
- park = themeparkapi_ids[self.__anc_park_id]
154
- themepark_id = f"{park}_{self.__id}"
155
- all_data = requests.get(f"https://api.themeparks.wiki/preview/parks/{park}/waittime").json()
156
- for i in all_data:
157
- if i["id"] == themepark_id:
158
- return i
159
- return None
160
-
161
- def get_wait_time(self):
162
- """Return current wait time of the object. Returns None if object doesn't have a wait time or no wait currently exists (eg. closed)"""
163
- data = self.get_themeparkapi_data()
164
- if data is None:
165
- return None
166
-
167
- return data['waitTime']
168
-
169
- def get_status(self):
170
- """Return current status of the object."""
171
- data = self.get_themeparkapi_data()
172
- if data is None:
173
- return None
174
-
175
- return data['status']
176
-
177
- def fastpass_available(self):
178
- """Returns a boolean of whether this object has FastPass"""
179
- data = self.get_themeparkapi_data()
180
- if data is None:
181
- return False
182
-
183
- return data['fastPass']
184
-
185
- def get_last_update_time(self):
186
- """Returns facilities last update time as a datetime object"""
187
- facility_data = self.get_themeparkapi_data()
188
- if facility_data is None:
189
- return None
190
-
191
- update_time = datetime.strptime(facility_data['lastUpdate'], "%Y-%m-%dT%H:%M:%S.%fZ")
192
- update_time = update_time.replace(tzinfo=pytz.utc)
193
- update_time = update_time.astimezone(self.__time_zone)
194
- return update_time
195
-
196
- def get_coordinates(self):
197
- """Returns the object's latitude and longitude"""
198
- try:
199
- return self.__data['coordinates']['Guest Entrance']['gps']
200
- except:
201
- return None
202
-
203
- def get_description(self):
204
- """Returns the object's description"""
205
- facility_data = self.__data
206
- if facility_data is None:
207
- return None
208
-
209
- try:
210
- return facility_data['descriptions']['shortDescription']['sections']['body']
211
- except:
212
- return None
213
-
214
- def get_media(self):
215
- """Returns a dictionary of dictionaries of media relating to the entity"""
216
- facility_data = self.__data
217
- if facility_data is None:
218
- return None
219
-
220
- return facility_data['media']
221
-
222
- def get_facets(self):
223
- """Returns a list of dictionaries of the object's facets"""
224
- facility_data = self.__data
225
- if facility_data is None:
226
- return None
227
-
228
- try:
229
- return facility_data['facets']
230
- except:
231
- return None
232
-
233
- def get_classifications(self):
234
- """Returns a dictionary of lists of classifications related to the entity"""
235
-
236
- classifications = {}
237
-
238
- try:
239
- for i in self.__data['classifications']:
240
- id = i['id'].split("/")[-1]
241
- if id not in classifications:
242
- classifications[id] = [i['text']]
243
- else:
244
- classifications[id].append(i['text'])
245
- except:
246
- pass
247
-
248
- return classifications
249
-
250
- def admission_required(self):
251
- """Returns boolean of admission required"""
252
- return self.__data['admissionRequired']
253
-
254
- def get_hours(self, date = ""):
255
- """
256
- Gets the object's hours on a specific day and returns them as a datetime object.
257
- Returns the object's hours in the following order: operating open, operating close, Extra Magic open, Extra Magic close.
258
- Extra Magic hours will return None if there are none for today.
259
- If all hours are None then Disney has no hours for that day.
260
- date = "yyyy-mm-dd"
261
- If you don't pass a date, it will get today's hours
262
- """
263
-
264
- if date == "":
265
- DATE = datetime.today()
266
- else:
267
- year, month, day = date.split('-')
268
- DATE = datetime(int(year), int(month), int(day))
269
-
270
- s = requests.get(f"https://api.wdpro.disney.go.com/facility-service/schedules/{self.__id}?date={DATE.year}-{self.__formatDate(str(DATE.month))}-{self.__formatDate(str(DATE.day))}", headers=get_headers())
271
- data = json.loads(s.content)
272
-
273
- operating_hours_start = None
274
- operating_hours_end = None
275
- extra_hours_start = None
276
- extra_hours_end = None
277
-
278
- try:
279
- for i in range(len(data['schedules'])):
280
- if data['schedules'][i]['type'] == 'Operating':
281
- operating_hours_start = datetime(DATE.year, DATE.month, DATE.day, int(data['schedules'][i]['startTime'][0:2]), int(data['schedules'][i]['startTime'][3:5]))
282
- if int(data['schedules'][i]['endTime'][0:2]) >= 0 and int(data['schedules'][i]['endTime'][0:2]) <= 7:
283
- DATETEMP = DATE + timedelta(days=1)
284
- operating_hours_end = datetime(DATETEMP.year, DATETEMP.month, DATETEMP.day, int(data['schedules'][i]['endTime'][0:2]), int(data['schedules'][i]['endTime'][3:5]))
285
- else:
286
- operating_hours_end = datetime(DATE.year, DATE.month, DATE.day, int(data['schedules'][i]['endTime'][0:2]), int(data['schedules'][i]['endTime'][3:5]))
287
-
288
- if data['schedules'][i]['type'] == "Special Ticketed Event":
289
- extra_hours_start = datetime(DATE.year, DATE.month, DATE.day, int(data['schedules'][i]['startTime'][0:2]), int(data['schedules'][i]['startTime'][3:5]))
290
- if int(data['schedules'][i]['endTime'][0:2]) >= 0 and int(data['schedules'][i]['endTime'][0:2]) <= 7:
291
- DATETEMP = DATE + timedelta(days=1)
292
- extra_hours_end = datetime(DATETEMP.year, DATETEMP.month, DATETEMP.day, int(data['schedules'][i]['endTime'][0:2]), int(data['schedules'][i]['endTime'][3:5]))
293
- else:
294
- operating_hours_end = datetime(DATE.year, DATE.month, DATE.day, int(data['schedules'][i]['endTime'][0:2]), int(data['schedules'][i]['endTime'][3:5]))
295
-
296
- except KeyError:
297
- pass
298
- return operating_hours_start, operating_hours_end, extra_hours_start, extra_hours_end
299
-
300
- def check_associated_characters(self):
301
- """
302
- Checks if object has any associated characters
303
- """
304
- s = requests.get("https://api.wdpro.disney.go.com/global-pool-override-B/facility-service/associated-characters/{};entityType={}".format(self.__id, self.__entityType), headers=get_headers())
305
- data = json.loads(s.content)
306
-
307
- if data['total'] > 0:
308
- return True
309
- else:
310
- return False
311
-
312
- def get_number_associated_characters(self):
313
- """
314
- Gets the total number of characters associated with this object
315
- """
316
- s = requests.get("https://api.wdpro.disney.go.com/facility-service/associated-characters/{};entityType={}".format(self.__id, self.__entityType), headers=get_headers())
317
- data = json.loads(s.content)
318
-
319
- return data['total']
320
-
321
- def get_associated_characters(self):
322
- """
323
- Returns a list of associated characters Character objects
324
- """
325
- from .characters import Character
326
- chars = []
327
-
328
- s = requests.get("https://api.wdpro.disney.go.com/global-pool-override-B/facility-service/associated-characters/{};entityType={}".format(self.__id, self.__entityType), headers=get_headers())
329
- data = json.loads(s.content)
330
-
331
- for i in range(len(data['entries'])):
332
- try:
333
- chars.append(Character(data['entries'][i]['links']['self']['href'].split('/')[-1]))
334
- except:
335
- pass
336
- return chars
337
-
338
- def get_associated_character_ids(self):
339
- """
340
- Returns a list of associated characters IDs
341
- """
342
- chars = []
343
-
344
- s = requests.get("https://api.wdpro.disney.go.com/global-pool-override-B/facility-service/associated-characters/{};entityType={}".format(self.__id, self.__entityType), headers=get_headers())
345
- data = json.loads(s.content)
346
-
347
- for i in range(len(data['entries'])):
348
- try:
349
- chars.append(data['entries'][i]['links']['self']['href'].split('/')[-1])
350
- except:
351
- pass
352
-
353
- return chars
354
-
355
- def __formatDate(self, num):
356
- """
357
- Formats month and day into proper format
358
- """
359
- if len(num) < 2:
360
- num = '0'+num
361
- return num
362
-
363
- def __eq__(self, other):
364
- """
365
- Checks if objects are equal
366
- """
367
- return self.__id == other.get_id()
368
-
369
- def __str__(self):
370
- return 'Attraction object for {}'.format(self.__name)
mousetools/characters.py DELETED
@@ -1,241 +0,0 @@
1
- import requests
2
- import pytz
3
- from datetime import datetime, timedelta
4
- from .auth import get_headers
5
- from .attractions import Attraction
6
- from .entertainments import Entertainment
7
- from .facilities import Facility
8
- from .ids import WDW_ID, DLR_ID
9
-
10
-
11
-
12
- class Character(object):
13
-
14
- def __init__(self, id = None):
15
- """
16
- Constructor Function
17
- Gets all character data available and stores various elements into variables.
18
- """
19
-
20
- error = True
21
- self.__data = requests.get("https://api.wdpro.disney.go.com/facility-service/characters/{}".format(id), headers=get_headers()).json()
22
- try:
23
- if self.__data['id'] is not None:
24
- error = False
25
- except:
26
- pass
27
-
28
- if error:
29
- raise ValueError('That character is not available. id: ' + str(id))
30
-
31
- self.__id = id
32
- self.__name = self.__data['name']
33
- self.__entityType = self.__data['type']
34
- try:
35
- self.__subType = self.__data['subType']
36
- except:
37
- self.__subType = None
38
- try:
39
- self.__anc_dest_id = self.__data['ancestorDestination']['id'].split(';')[0]
40
- except:
41
- self.__anc_dest_id = None
42
-
43
- try:
44
- self.__anc_park_id = self.__data['links']['ancestorThemePark']['href'].split('/')[-1].split('?')[0]
45
- except:
46
- try:
47
- self.__anc_park_id = self.__data['links']['ancestorWaterPark']['href'].split('/')[-1].split('?')[0]
48
- except:
49
- try:
50
- self.__anc_park_id = self.__data['ancestorThemeParkId'].split(';')[0]
51
- except:
52
- try:
53
- self.__anc_park_id = self.__data['ancestorWaterParkId'].split(';')[0]
54
- except:
55
- self.__anc_park_id = None
56
-
57
- try:
58
- self.__anc_resort_id = self.__data['links']['ancestorResort']['href'].split('/')[-1].split('?')[0]
59
- except:
60
- try:
61
- self.__anc_resort_id = self.__data['ancestorResortId'].split(';')[0]
62
- except:
63
- self.__anc_resort_id = None
64
-
65
- try:
66
- self.__anc_land_id = self.__data['links']['ancestorLand']['href'].split('/')[-1].split('?')[0]
67
- except:
68
- try:
69
- self.__anc_land_id = self.__data['ancestorLandId'].split(';')[0]
70
- except:
71
- self.__anc_land_id = None
72
-
73
- try:
74
- self.__anc_ra_id = self.__data['links']['ancestorResortArea']['href'].split('/')[-1].split('?')[0]
75
- except:
76
- try:
77
- self.__anc_ra_id = self.__data['ancestorResortAreaId'].split(';')[0]
78
- except:
79
- self.__anc_ra_id = None
80
-
81
- try:
82
- self.__anc_ev_id = self.__data['links']['ancestorEntertainmentVenue']['href'].split('/')[-1].split('?')[0]
83
- except:
84
- try:
85
- self.__anc_ev_id = self.__data['ancestorEntertainmentVenueId'].split(';')[0]
86
- except:
87
- self.__anc_ev_id = None
88
-
89
- if self.__anc_dest_id == WDW_ID:
90
- self.__time_zone = pytz.timezone('US/Eastern')
91
- elif self.__anc_dest_id == DLR_ID:
92
- self.__time_zone = pytz.timezone('US/Pacific')
93
- else:
94
- self.__time_zone = pytz.utc
95
-
96
-
97
- def get_id(self):
98
- """Return object id"""
99
- return self.__id
100
-
101
- def get_name(self):
102
- """Return object name"""
103
- return self.__name
104
-
105
- def get_entityType(self):
106
- """Return object entityType"""
107
- return self.__entityType
108
-
109
- def get_subType(self):
110
- """Return object subType"""
111
- return self.__subType
112
-
113
- def get_ancestor_destination_id(self):
114
- """Return object ancestor destination id"""
115
- return self.__anc_dest_id
116
-
117
- def get_ancestor_park_id(self):
118
- """Return object ancestor theme or water park id"""
119
- return self.__anc_park_id
120
-
121
- def get_ancestor_resort_id(self):
122
- """Return object ancestor resort id"""
123
- return self.__anc_resort_id
124
-
125
- def get_ancestor_land_id(self):
126
- """Return object land id"""
127
- return self.__anc_land_id
128
-
129
- def get_ancestor_resort_area_id(self):
130
- """Return object resort area id"""
131
- return self.__anc_ra_id
132
-
133
- def get_ancestor_entertainment_venue_id(self):
134
- """Return object entertainment venue id"""
135
- return self.__anc_ev_id
136
-
137
- def get_time_zone(self):
138
- """Returns pytz timezone object"""
139
- return self.__time_zone
140
-
141
- def get_raw_data(self):
142
- """Returns the raw data from global-facility-service"""
143
- return self.__data
144
-
145
- def get_links(self):
146
- """Returns a dictionary of related links"""
147
- return self.__data['links']
148
-
149
-
150
- def check_related_locations(self):
151
- """
152
- Returns true if it has related locations, false if none
153
- """
154
- try:
155
- check = self.__data['relatedLocations']
156
- return True
157
- except:
158
- return False
159
-
160
- def get_related_locations(self):
161
- """
162
- Gets the locations the character is realted to.
163
- """
164
- locs = []
165
- try:
166
- if self.check_related_locations():
167
- for loc in self.__data['relatedLocations']['primaryLocations']:
168
- type = loc['facilityType']
169
- loc_id = loc['links']['self']['href'].split('/')[-1].split('?')[0]
170
-
171
- if type == 'Attraction':
172
- locs.append(Attraction(loc_id))
173
- elif type == 'Facility':
174
- locs.append(Facility(loc_id))
175
- else:
176
- print('no class for {} at this time'.format(type))
177
- return locs
178
- except:
179
- return locs
180
-
181
- def get_related_location_ids(self):
182
- """
183
- Gets the locations the character is realted to as a list of tuples [(id, type)]
184
- """
185
- locs = []
186
- try:
187
- if self.check_related_locations():
188
- for loc in self.__data['relatedLocations']['primaryLocations']:
189
- type = loc['facilityType']
190
- loc_id = loc['links']['self']['href'].split('/')[-1].split('?')[0]
191
-
192
- locs.append((loc_id, type))
193
-
194
- return locs
195
- except:
196
- return locs
197
-
198
- def get_associated_events(self):
199
- """
200
- Returns a list of Entertainment objects of events associated with the character.
201
- Will print an error if the ID does not exist anymore. Unfortunately Disney, lists some events that don't exist, and thus will throw the error
202
- when it tries to create the Entertainment object.
203
- """
204
- entertainments = []
205
- try:
206
- for entertainment in self.__data['associatedEvents']:
207
- try:
208
- entertainments.append(Entertainment(entertainment['links']['self']['href'].split('/')[-1].split('?')[0]))
209
- except:
210
- pass
211
- return entertainments
212
- except:
213
- return entertainments
214
-
215
- def get_associated_event_ids(self):
216
- """
217
- Returns a list of Entertainment ids of events associated with the character.
218
- Will print an error if the ID does not exist anymore. Unfortunately Disney, lists some events that don't exist, and thus will throw the error
219
- when it tries to create the Entertainment object.
220
- """
221
- entertainments = []
222
- try:
223
- for entertainment in self.__data['associatedEvents']:
224
- try:
225
- entertainments.append(entertainment['links']['self']['href'].split('/')[-1].split('?')[0])
226
- except:
227
- pass
228
- return entertainments
229
- except:
230
- return entertainments
231
-
232
- def __formatDate(self, num):
233
- """
234
- Formats month and day into proper format
235
- """
236
- if len(num) < 2:
237
- num = '0'+num
238
- return num
239
-
240
- def __str__(self):
241
- return 'Character object for {}'.format(self.__name)