Add compatibility for DLCs#10
Conversation
shaunikm
commented
Jun 28, 2022
- Pull data from https://botw-compendium.herokuapp.com/api/v2/master_mode in addition to the base URL
|
Fixed syntax issue |
| """ | ||
|
|
||
| def __init__(self, base_url: str="https://botw-compendium.herokuapp.com/api/v2", default_timeout: Union[int, float, None]=None): | ||
| def __init__(self, base_url: str="https://botw-compendium.herokuapp.com/api/v2", default_timeout: Union[int, float, None]=None, master_mode: bool = False): |
There was a problem hiding this comment.
I think master_mode should be passed into the functions rather than to the class, because we do not want to create another object for master_mode data.
There was a problem hiding this comment.
I feel that having master_mode passed when the class is initialized would remove the need for a redundant parameter in every function of the class.
| if not timeout: | ||
| timeout = self.default_timeout | ||
|
|
||
| res: dict = self.api.request(f"/entry/{entry}", timeout) |
There was a problem hiding this comment.
I plan on adding a dlc field to entry data in v3. Until then, is there a better way of determining if it is master_mode or not without two requests?
There was a problem hiding this comment.
Other than using local data, I don’t see any way to determine if an entry is from master_mode without two requests.
| res: dict = self.api.request(f"/entry/{entry}", timeout) | ||
| if res: return False | ||
|
|
||
| res = self.master_api.request(f"/entry/{entry}", timeout) |
There was a problem hiding this comment.
Again, I don’t see a way to minimize the number of requests we have here other than using local data.
- Can also override class parameter `master_mode`
…` with `master_mode`
Reduce number of requests when calling function