Metadata-Version: 2.4
Name: mawaqit-alexa
Version: 1.0.4
Summary: A simple mawaqit scraper for creating Calendar events and Alexa integration.
Home-page: https://github.com/Ahmad-Said/mawaqit_alexa
Author: Ahmad SAID
Author-email: hunter.sc.dark@gmail.com
License: MIT
Keywords: mawaqit,prayer times,icalendar,alexa,mosque,salat,calendar
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: icalendar
Requires-Dist: requests
Requires-Dist: beautifulsoup4
Requires-Dist: typing_extensions
Dynamic: license-file

# Mawaqit Alexa

A Python library to scrape prayer times from [Mawaqit](https://mawaqit.net) and generate iCalendar (.ics) files for integration with calendar apps and Alexa.

## Features

- Scrape prayer times from any mosque on Mawaqit
- Generate iCalendar (.ics) files with prayer time events
- Support for both Arabic and English prayer names
- Configurable alarm notifications before prayer times
- CSV data provider for offline/exported data
- TTL-based caching to avoid excessive requests

## Installing

To install the library, you can run the following command:

```shell
pip install mawaqit_alexa
```

## Usage

### Basic Example

```python
import datetime
import os
from typing import Literal

from mawaqit_alexa.data_provider.scraping_mawaqit_provider import ScrapingMawaqitProvider
from mawaqit_alexa.util.param import Param
from mawaqit_alexa.services.calendar_generator import MawaqitCalendarGenerator

# Configure parameters
Param.ALARM_BEFORE_MINUTES = 15  # Alarm 15 minutes before prayer
Param.SUMMARY_PREFIX = ''  # Optional prefix for event summary

# Set the mawaqit mosque URL
data_url = 'https://mawaqit.net/fr/grande-mosquee-de-paris'

# Fetch prayer times
api_mawaqit_provider = ScrapingMawaqitProvider(data_url)
year_calendar = api_mawaqit_provider.get_current_year_calendar()
mosque_name = api_mawaqit_provider.masjid_endpoint
current_year = datetime.datetime.now().year

# Choose language: 'ar' for Arabic, 'en' for English
language: Literal['ar', 'en'] = 'ar'

# Set output file path
output_file = f'./data/out/{mosque_name}_{language}_{Param.ALARM_BEFORE_MINUTES}_{current_year}.ics'
output_file = os.path.join(os.getcwd(), output_file)

# Create the calendar
MawaqitCalendarGenerator.create_mawaqit_calendar(
    year_calendar=year_calendar,
    year=current_year,
    output_file=output_file,
    time_zone='Europe/Paris',
    language=language
)
```

### Using CSV Data Provider

If you have exported prayer times data from Mawaqit, you can use the CSV provider:

```python
from mawaqit_alexa.data_provider.csv_mawaqit_provider import CsvMawaqitProvider

data_folder = './data/Nantes'
csv_provider = CsvMawaqitProvider(data_folder)
year_calendar = csv_provider.get_current_year_calendar()
```

## Configuration

The `Param` class allows you to configure:

- `ALARM_BEFORE_MINUTES`: Minutes before prayer time to trigger an alarm (default: 15)
- `SUMMARY_PREFIX`: Prefix to add to calendar event summaries (default: '')

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Author

Ahmad SAID - [GitHub](https://github.com/Ahmad-Said)

