mirror of
https://github.com/etienne-hd/lbc-finder.git
synced 2026-04-29 20:35:35 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6dc50b436 | ||
|
|
d48349b271 | ||
|
|
31682fabbf | ||
|
|
b2d5d400da | ||
|
|
e60ad25035 | ||
|
|
f2a63ec7ff | ||
|
|
d4e76c75af | ||
|
|
af4264270b |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,3 +1,14 @@
|
||||
## v1.1.1
|
||||
|
||||
### Added
|
||||
- Automatic installation of Python libraries from `config/requirements.txt` when running the Docker container.
|
||||
|
||||
### Changed
|
||||
- Moved `config.py` to `config/__init__.py` to allow multiple configuration files in Docker.
|
||||
|
||||
### Updated
|
||||
- Discord example updated to reflect the new configuration structure.
|
||||
|
||||
## v1.1.0
|
||||
|
||||
### Added
|
||||
|
||||
@@ -3,8 +3,12 @@ FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt && rm requirements.txt
|
||||
|
||||
COPY lbc-finder /app
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["python", "main.py"]
|
||||
37
README.md
37
README.md
@@ -73,7 +73,7 @@ The easiest way is to use the prebuilt image from Docker Hub:
|
||||
|
||||
```bash
|
||||
docker pull etiennehode/lbc-finder:latest
|
||||
```
|
||||
````
|
||||
|
||||
### Build locally
|
||||
|
||||
@@ -89,29 +89,44 @@ docker build -t lbc-finder .
|
||||
docker run -d \
|
||||
--name lbc-finder \
|
||||
-v lbc_data:/app/data \
|
||||
-v $(pwd)/config.py:/app/config.py \
|
||||
-v $(pwd)/config:/app/config \
|
||||
etiennehode/lbc-finder:latest
|
||||
```
|
||||
|
||||
### Volumes
|
||||
|
||||
Two volumes are used:
|
||||
|
||||
| Volume | Description |
|
||||
| ---------------- | ----------------------------------- |
|
||||
| `/app/config.py` | Your search configuration file |
|
||||
| `/app/data` | Persistent storage for detected ads |
|
||||
| Path in container | Description |
|
||||
| ----------------- | --------------------------------------------------------------------------------------------------- |
|
||||
| `/app/config` | Your search configuration files **and optional `requirements.txt`** for additional Python libraries |
|
||||
| `/app/data` | Persistent storage for detected ads |
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
-v $(pwd)/config.py:/app/config.py
|
||||
-v $(pwd)/config:/app/config
|
||||
```
|
||||
|
||||
This mounts your local `config.py` file into the container so you can easily edit your searches without rebuilding the image.
|
||||
This mounts your local `config/` folder into the container so you can easily edit your searches.
|
||||
|
||||
> **Extra Python libraries:**
|
||||
> If your configuration requires additional Python packages, create a `requirements.txt` file inside your `config/` folder.
|
||||
> The container startup script will automatically install all listed packages before running **lbc-finder**:
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
if [ -e config/requirements.txt ]
|
||||
then
|
||||
pip install --no-cache-dir -r config/requirements.txt
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
```
|
||||
|
||||
This way, you can extend the container with any Python library you need without modifying the Docker image itself.
|
||||
|
||||
|
||||
## Configuration
|
||||
A [config.py](config.py) file is provided by default in the project, it contains a basic configuration.
|
||||
A [config](lbc-finder/config/__init__.py) file is provided by default in the project, it contains a basic configuration.
|
||||
|
||||
Inside this file, you must define a `CONFIG` variable, which is an list of `Search` objects.
|
||||
|
||||
|
||||
7
docker-entrypoint.sh
Normal file
7
docker-entrypoint.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
if [ -e config/requirements.txt ]
|
||||
then
|
||||
pip install --no-cache-dir -r config/requirements.txt
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@@ -1,12 +1,7 @@
|
||||
from model import Search, Parameters
|
||||
import lbc
|
||||
|
||||
def handle(ad: lbc.Ad, search_name: str):
|
||||
print(f"[{search_name}] New ads!")
|
||||
print(f"Title : {ad.subject}")
|
||||
print(f"Price : {ad.price} €")
|
||||
print(f"URL : {ad.url}")
|
||||
print("-" * 40)
|
||||
from .handler import handle
|
||||
|
||||
location = lbc.City(
|
||||
lat=48.85994982004764,
|
||||
@@ -13,7 +13,7 @@ def handle(ad: lbc.Ad, search_name: str) -> None:
|
||||
"embeds": [
|
||||
{
|
||||
"title": ad.title,
|
||||
"description": f"```{ad.body}```",
|
||||
"description": f"```{ad.body[:4087]}...```" if len(ad.body) >= 4090 else f"```{ad.body[:4090]}```",
|
||||
"url": ad.url,
|
||||
"color": 14381568,
|
||||
"author": {
|
||||
@@ -46,4 +46,5 @@ def handle(ad: lbc.Ad, search_name: str) -> None:
|
||||
"attachments": []
|
||||
}
|
||||
|
||||
requests.post(WEBHOOK_URL, json=payload)
|
||||
response = requests.post(WEBHOOK_URL, json=payload)
|
||||
response.raise_for_status()
|
||||
1
examples/discord/config/requirements.txt
Normal file
1
examples/discord/config/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
requests==2.32.3
|
||||
26
lbc-finder/config/__init__.py
Normal file
26
lbc-finder/config/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from model import Search, Parameters
|
||||
import lbc
|
||||
|
||||
from .handler import handle
|
||||
|
||||
location = lbc.City(
|
||||
lat=48.85994982004764,
|
||||
lng=2.33801967847424,
|
||||
radius=10_000, # 10 km
|
||||
city="Paris"
|
||||
)
|
||||
|
||||
CONFIG = [
|
||||
Search(
|
||||
name="Location Paris",
|
||||
parameters=Parameters(
|
||||
text="maison",
|
||||
locations=[location],
|
||||
category=lbc.Category.IMMOBILIER,
|
||||
square=[200, 400],
|
||||
price=[300_000, 700_000]
|
||||
),
|
||||
delay=60 * 5, # Check every 5 minutes
|
||||
handler=handle
|
||||
),
|
||||
]
|
||||
9
lbc-finder/config/handler.py
Normal file
9
lbc-finder/config/handler.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import lbc
|
||||
|
||||
def handle(ad: lbc.Ad, search_name: str):
|
||||
print(f"[{search_name}] New ads!")
|
||||
print(f"Title : {ad.subject}")
|
||||
print(f"Price : {ad.price} €")
|
||||
print(f"URL : {ad.url}")
|
||||
print("-" * 40)
|
||||
|
||||
Reference in New Issue
Block a user