Metadata-Version: 2.4
Name: krogoco-calendar
Version: 1.0.0
Summary: Scrapes Krog & Co's calendar pages and turns them into iCalendar (ICS) files
Author-email: Jonny Bergdahl <github@bergdahl.it>
License-Expression: MIT
Project-URL: Github, https://github.com/jonnybergdahl/Python-krogoco-calendar
Project-URL: Documentation, https://jonnybergdahl.github.io/krogoco-calendar/
Keywords: krogoco,krog & co,calendar,ics,icalendar,scraper
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: Swedish
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Topic :: Office/Business :: Scheduling
Classifier: Topic :: Utilities
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4
Requires-Dist: icalendar
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: responses; extra == "dev"
Requires-Dist: sphinx>=7; extra == "dev"
Requires-Dist: sphinx-rtd-theme>=2; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine>=6.1; extra == "dev"
Requires-Dist: trove-classifiers; extra == "dev"
Dynamic: license-file

# krogoco-calendar

[![PyPI version](https://badge.fury.io/py/krogoco-calendar.svg)](https://badge.fury.io/py/krogoco-calendar)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/krogoco-calendar.svg)](https://pypi.python.org/pypi/krogoco-calendar/)
[![PyPI license](https://img.shields.io/pypi/l/krogoco-calendar.svg)](https://pypi.python.org/pypi/krogoco-calendar/)

A Python library that scrapes [Krog&Co](https://krogoco.se/) calendar pages
and converts them to iCalendar (ICS) files.

Full documentation: https://jonnybergdahl.github.io/krogoco-calendar/

## Installation

```bash
pip install krogoco-calendar
```

Python 3.10 or newer is required.

For development, clone the repository and install locally:

```bash
git clone https://github.com/jonnybergdahl/Python-krogoco-calendar.git
cd Python-krogoco-calendar
pip install -e ".[dev]"
```

## Usage

```python
from krogoco_calendar import KrogocoIcs

scraper = KrogocoIcs(
    url="https://krogoco.se/jonkoping/kalender/",
    months=2,
)

# Get ICS as a string
ics_data = scraper.get_ics()

# Or write directly to a file
scraper.write_ics("krogoco.ics")
```

### Blacklist

You can filter out events by providing a blacklist of keywords.
Events whose title contains any of the keywords (case-insensitive) will
be excluded:

```python
scraper = KrogocoIcs(
    url="https://krogoco.se/jonkoping/kalender/",
    months=2,
    blacklist=["HV71", "SHL", "match"],
)
```

### Supported locations

The library works with any Krog & Co location that uses the same calendar
page structure:

- `https://krogoco.se/jonkoping/kalender/`
- `https://krogoco.se/halmstad/kalender/`

## Time format handling

Event times are extracted automatically from Swedish title formats:

| Format | Example | Parsed as |
|---|---|---|
| Full range | `12.00-16.00` | 12:00 - 16:00 |
| Short range | `Kl.12-17` | 12:00 - 17:00 |
| Bare hour range | `Sliver nattklubb 22-03` | 22:00 - 03:00 (next day) |
| Single time | `Kl.17.00` or `Från 21:00` | 17:00 / 21:00 |
| Time with hint | `Kl.22.00, 23+` | 22:00 - 23:00 |
| No time | `Studentfest` | All-day event |

## Running tests

```bash
pytest
```

## Publishing

`build.sh` runs the tests, builds the docs and pushes them to
[jonnybergdahl.github.io](https://jonnybergdahl.github.io/krogoco-calendar/),
then builds the package and uploads it to PyPI. Bump `__version__` in
`src/krogoco_calendar/__init__.py` first.

## License

MIT
