Skip to content

Commit

Permalink
Merge pull request #20 from kggx/kggx/issue8
Browse files Browse the repository at this point in the history
Added feature: Seatmap handler
  • Loading branch information
kggx authored May 26, 2024
2 parents d252c30 + c372c0c commit 0ec19ed
Show file tree
Hide file tree
Showing 17 changed files with 723 additions and 4,942 deletions.
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,31 @@ pip install pyventim

### Quick start

#### Public API
To find attractions we can use the exploration endpoint:

```python
# Import the module
from pyventim.public import EventimExploration

# Returns attractions found by the explorer api given the search term.
explorer: EventimExploration = EventimExploration()
result = explorer.explore_attractions(
search_term="Stage Theater im Hafen Hamburg",
sort="DateAsc",
)
import pyventim

# Create the Eventim class
eventim = pyventim.Eventim()

# Returns an iterator that fetches all pages off the search endpoint.
attractions = eventim.explore_attractions(search_term="Landmvrks")

# We can loop over each attraction. The module handles fetching pages automatically.
for attraction in attractions:
print(attraction["attractionId"], attraction["name"])
```

Next we use the product group endpoint to fetch events for our attraction and get the events of the html endpoint.

```python

# We loop over each product group and fetch the events automatically.
for product_group in eventim.explore_product_groups(search_term="Landmvrks"):
product_group_id = product_group["productGroupId"]
for event in eventim.get_product_group_events_from_calendar(product_group_id):
print(event["title"], event["eventDate"], event["price"], event["ticketAvailable"], sep=" | ")
```

For a more detailed information please refer to the [documentation](https://kggx.github.io/pyventim/pyventim.html).
Expand Down
3 changes: 3 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<hr>

# Examples
9 changes: 0 additions & 9 deletions docs/getting_started.md

This file was deleted.

105 changes: 105 additions & 0 deletions docs/seatmap_endpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
## Seatmap Endpoint

This endpoint can be used to get seatmap data of specific attraction.

Functionality can break without notice because this is parsed via HTML.

### get_event_seatmap_information

This function can return data about the seatmap if found in the HTML of the event page. If no seat map is found then None will be returned.

```python
# This will fetch the html for the given event. Note the url must match the structure in the example!
result = eventim.get_event_seatmap_information("/event/disneys-der-koenig-der-loewen-stage-theater-im-hafen-hamburg-18500464/")
```

A sample for the seatmap information can be found here (Note this is truncated.):

```json
{
"fansale": { <- ... -> },
"seatmapOptions": { <- ... -> },
"seatmapIsDefault": false,
"packageData": { <- ... -> },
"price": { <- ... -> },
"maxAmountForEvent": 10,
"minAmountForEvent": 1,
"maxAmountForPromo": 0,
"preselectedPcId": 0,
"showBackLink": false,
"backLink": "/event/disneys-der-koenig-der-loewen-stage-theater-im-hafen-hamburg-16828914/",
"eventName": "Disneys DER K\u00d6NIG DER L\u00d6WEN",
"restrictions": { <- ... -> },
"cartData": { <- ... -> },
"panoramaOptions": { <- ... -> },
"imageviewerOptions": { <- ... -> },
"ccEnabled": true,
"initialRequestPath": "/api/shoppingCart/?affiliate=EVE&token=518ACD577869FB764ED195DF569D347C",
"captchaActive": false,
"captchaAPIPath": "//www.google.com/recaptcha/api.js?hl=de",
"captchaSiteKey": "",
"pcFlyoutExpanded": true,
"pcUpgradeActiveClass": "js-pc-upgrade-active",
"pricePlaceholder": "#PRICE#",
"hasPriceDisclaimerHint": false,
"hasCorporateBenefits": false,
"hasCombinedTicketTypes": false,
"hasAllCategoriesToggleText": true,
"reducedAvailabilityWidgetLink": "",
"hasOptionsFilter": false,
"ticketTypeFilterMap": { <- ... -> },
"api": "/api/corporate/benefit/limits/?affiliate=EVE",
"useParis24Styles": false,
"messages": { <- ... -> }
}
```

### get_event_seatmap

This function returns seatmap data with avialible seats and their pricing data. This could be used to generate a seatmap image or make yield analytics.

```python
# This will fetch the html for the given event. Note the url must match the structure in the example!
result = eventim.get_event_seatmap_information("/event/disneys-der-koenig-der-loewen-stage-theater-im-hafen-hamburg-18500464/")
seatmap = eventim.get_event_seatmap(result["seatmapOptions"])
```

A sample for the seatmap information can be found here (Note this is fictional data):

```json
{
"seatmap_key": "web_1_16828914_0_EVE_0",
"seatmap_timestamp": 1716717879990,
"seatmap_individual_seats": 2051,
"seatmap_dimension_x": 8192,
"seatmap_dimension_y": 8192,
"seatmap_seat_size": 59,
"blocks": [
{
"block_id": "b1",
"block_name": "Parkett links",
"block_description": "Parkett links",
"block_rows": [
{
"row_code": "r4",
"row_seats": [
{
"seat_code": "s515",
"seat_price_category_index": 1,
"seat_coordinate_x": 3846,
"seat_coordinate_y": 1699
}
]
}
]
}
],
"price_categories": [
{
"price_category_id": "p32919041",
"price_category_name": "Kat. 1 Premium",
"price_category_color": "#f1075e"
}
]
}
```
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ black >= 24.4.0
pdoc >= 14.4.0
twine >= 5.1.0
build >= 1.2.1
Pillow
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let
pdoc
twine
build
pillow
]
);

Expand Down
3 changes: 2 additions & 1 deletion src/pyventim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
.. include:: ../../README.md
.. include:: ../../docs/getting_started.md
.. include:: ../../docs/examples.md
.. include:: ../../docs/exploration_endpoint.md
.. include:: ../../docs/component_endpoint.md
.. include:: ../../docs/seatmap_endpoint.md
"""

from .eventim import Eventim
Expand Down
Loading

0 comments on commit 0ec19ed

Please sign in to comment.