Comments (7)
I'm very interested in adding support for ReserveCalifornia. Looks like it's quite different of a layout.
I'd be happy to start poking at this. Any recommendation @juftin for how you would want this structured?
from camply.
Oh very nice. Here's a very rough guide for implementing a new "Provider" with camply
:
- Implement a new
BaseCampingSearch
class:camply/camply/search/base_search.py
Line 44 in 7b64c22
- The
BaseCampingSearch
super class handles the high level interactions to do things like filter results to only weekends, look for consecutive nights, etc - This is an AbstractBaseClass that only requires you to define a single function:
get_all_campsites
which returns a list ofAvailableCampsite
data objects given the search parameters provided to the class - Here's an example of the Yellowstone implementation:
- Embed a
BaseProvider
into the newly created search class - this is used inside theBaseCampingSearch
instance to actually search and create thecamply.containers.AvailableCampsite
objects
- This is the class where you define how to interact with the API of the Camping provider.
- Here's an example of the Yellowstone Provider:
Hopefully this makes sense - if I were to totally rewrite camply today I might structure it differently, so maybe there's a way to do this better. I'm happy to help put things together as progress gets closer on the BaseProvider
class as well
from camply.
Another note on how I parse results from the API: I use a custom pydantic.BaseModel
class (CamplyModel
) all over camply
- it's a hashable data container class that defines core data containers like AvailableCampsite
and CampgroundFacility
but it also really helps to parse JSON responses from API's. Here's an example similar to what I'm doing in https://github.com/juftin/camply/blob/7b64c22994d4c9472317230b59b98da98eb224b9/camply/containers/api_responses.py.
import datetime
from enum import Enum
from typing import Dict
from camply.containers.base_container import CamplyModel
raw_campsite_api_response = {
"campsite_id": "12345",
"campsite_name": "example campsite",
"campsite_availabilities": {
"2022-03-05": "available",
"2022-03-06": "unavailable",
"2022-03-07": "unavailable",
"2022-03-08": "unavailable",
"2022-03-09": "available"
},
"campsite_location": "Anywhere, USA",
"_non_useful_metadata_field": "sdcsad123431"
}
class ReserveCAAvailabilityOptions(str, Enum):
available = "available"
unavailable = "unavailable"
class ReserveCACampsiteResponse(CamplyModel):
campsite_id: int
campsite_name: str
campsite_availabilities: Dict[datetime.date, ReserveCAAvailabilityOptions]
campsite_location: str
easy_to_use_response = ReserveCACampsiteResponse(**raw_campsite_api_response)
That script defined our API response schema using pydantic
, converted the raw dictionary into a data object using just the fields we defined, performed validation on the data provided and converted the string variables using python typing, and makes the data available in a way that's easy to code:
for datetime_obj, status in easy_to_use_response.campsite_availabilities.items():
if status == ReserveCAAvailabilityOptions.available:
print(f"{datetime_obj.strftime('%Y-%m-%d')} is available for camping!")
from camply.
👋 thanks for making Camply! I'm also interested in Reserve California. Any update on this?
from camply.
Here's another scraper that uses reserve_ca: https://github.com/ggydush/campsites - this is python based!
from camply.
At long last, I'm finally looking into implementing ReserveCalifornia. It's been tricky - but I've made some really amazing progress. https://github.com/ggydush/campsites has been super helpful - I ended up using a few APIs I haven't seen there or anywhere else as well. I'll have more to say here soon ✨
from camply.
ReserveCalifornia
is ready! https://juftin.com/camply/providers/#reservecalifornia
@bryanwhiting @stjohnjohnson @magic7s I'd love your thoughts once you get around to using it. I tried testing it out on a number of Rec Areas and Campgrounds - but it could definitely use some more testing to make sure it supports all of ReserveCaliforna. Happy camping ⛺!
from camply.
Related Issues (20)
- Add feature to ignore errors instead of stopping the tracking HOT 13
- cannot search on ReserveCalifornia HOT 7
- Notifications over MQTT? HOT 7
- Support for novascotia.goingtocamp.com HOT 4
- Olympic National Park doesn't appear as a WA Recreation area HOT 3
- Ability to specify # of people for a campsite HOT 1
- Reserve California doesn't work for me. HOT 12
- yaml search with ReserveCalifornia fails with TypeError: object of type 'NoneType' has no len()
- Support for manitoba.goingtocamp.com HOT 2
- Trouble using search yaml file with equipment option
- Support for reservations.ontarioparks.com (goingtocamp) HOT 4
- Filter campsites for goingtocamp HOT 3
- GoingToCamp Parks Canada does not identify available sites correctly HOT 12
- `POLLING_INTERVAL_MINIMUM` limit clarification HOT 4
- Generic webhook notification HOT 6
- Reserve California website availability not reflecting in Camply searching HOT 1
- campsite geolocation HOT 6
- Webhook crashes on utf-8 characters HOT 1
- Provider for site specific backcountry permits on nps.gov
- GoingToCamp midnrreservations.com ConnectionError HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camply.