mpo-project
v1.0.0
Published
# Google Calendar Event Generator for MPO Krakow Rubbish Retrieval Plan
Downloads
2
Readme
README.md
Google Calendar Event Generator for MPO Krakow Rubbish Retrieval Plan
This NodeJS application allows you to generate Google Calendar events for rubbish retrieval based on the schedule provided by MPO Krakow. The schedule is fetched from MPO Krakow's address search using the streetId
and houseId
parameters.
Description
The application retrieves the rubbish retrieval plan for your house from MPO Krakow and creates events in your Google Calendar. This ensures you never miss a rubbish collection day.
The retrieval plan is accessed via a POST request to the MPO Krakow API, which returns a PNG image containing the schedule. The application parses this image to extract the schedule and then creates corresponding events in your Google Calendar.
Prerequisites
- NodeJS installed on your machine.
- Google API credentials.
- MPO token, street ID, and house ID.
Configuration Files
1. credentials.json
This file contains your Google API credentials. You need to obtain this file by following these steps:
- Go to the Google Cloud Console.
- Create a new project or select an existing project.
- Navigate to the "Credentials" section.
- Click on "Create Credentials" and select "OAuth 2.0 Client IDs".
- Download the
credentials.json
file and place it in the root directory of your project.
2. token.json
This file stores the OAuth 2.0 tokens. It will be automatically generated when you authorize the application for the first time. You do not need to create this file manually.
3. mpo.json
This file contains the necessary configuration for both MPO and Google Calendar integration. Create a file named mpo.json
in the root directory of your project with the following structure:
{
"mpo": {
"token": "fill_from_website",
"streetId": "fill_your_own",
"houseId": "fill_your_own"
},
"google": {
"tokenPath": "./token.json",
"credentialsPath": "./credentials.json",
"scopes": ["https://www.googleapis.com/auth/calendar"],
"calendar": {
"name": "Prywatne",
"guests": ["[email protected]"]
}
}
}
Configuration Details:
- mpo.token: The token obtained from the MPO website.
- mpo.streetId: Your street ID.
- mpo.houseId: Your house ID.
- google.tokenPath: Path to the
token.json
file. - google.credentialsPath: Path to the
credentials.json
file. - google.scopes: Scopes required for the Google Calendar API.
- google.calendar.name: Name of the calendar.
- google.calendar.guests: List of guest email addresses to invite.
Usage
- Clone the repository and navigate to the project directory.
- Install the dependencies:
npm install
- Ensure the
credentials.json
andmpo.json
files are in the root directory. - Run the application:
node app.js
The application will guide you through the OAuth2.0 authorization process.
Example API Request
To fetch the rubbish retrieval plan, the application sends a POST request to the following endpoint:
curl 'https://kiedywywoz.pl/API/harmo_img/' \
-H 'accept: */*' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'dnt: 1' \
-H 'origin: https://harmonogram.mpo.krakow.pl' \
-H 'pragma: no-cache' \
-H 'priority: u=1, I' \
-H 'referer: https://harmonogram.mpo.krakow.pl/' \
-H 'sec-ch-ua: "Chromium";v="125", "Not.A/Brand";v="24"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: cross-site' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36' \
--data-raw 'ulica=39130&numer=684796&token=OkkxhC6b9etJBAq7WTHJ0LhIglO18sip'
Replace the placeholders in the data with your actual streetId
, houseId
, and token
from the MPO website.