Refactor core logic and add visualization tools

Moved database and scraping logic to utils/scrap.py for modularity. Added utils/visualizer.py for channel-level ad break analysis and plotting. Introduced .env.example for webhook configuration and updated main.py to support webhook heartbeats and improved logging. Updated README with new usage and visualization instructions. Added matplotlib and python-dotenv as dependencies.
This commit is contained in:
√(noham)²
2025-11-30 14:45:43 +01:00
parent 898edc0758
commit 4d4c470410
9 changed files with 1309 additions and 188 deletions

View File

@@ -5,7 +5,7 @@ OqeeAdWatch is a small watcher that periodically polls the Oqee anti-adskipping
### Getting started
```bash
cd content/posts/ads
git clone https://github.com/NohamR/OqeeAdWatch && cd OqeeAdWatch
uv sync
```
@@ -32,4 +32,26 @@ The database lives next to the script and contains a single `ads` table:
| end_ts | INTEGER | UNIX timestamp for the end of ad |
| ad_date | TEXT | Convenience YYYY-MM-DD string |
The primary key `(channel_id, start_ts, end_ts)` prevents duplicates when the API returns the same break multiple times.
The primary key `(channel_id, start_ts, end_ts)` prevents duplicates when the API returns the same break multiple times.
### Visualizing collected ads
The helper `visualizer.py` script prints a quick summary for a single channel:
```bash
uv run python utils/visualizer.py <channel-id>
```
You will see totals, min/max dates, longest breaks, and a per-day breakdown for that channel based on the ads already stored in `ads.sqlite3`. Matplotlib windows display:
- A 24h profile (bars = average ad minutes per day, line = average break count).
- A minute-vs-hour heatmap (white to red) showing how much of each minute is covered by ads on average.
Add `--no-plot` if you only want the textual summary.
### Webhook heartbeat
OqeeAdWatch can send a heartbeat notification every 24 hours to confirm the scraper is still running. To enable it:
1. Copy `.env.example` to `.env`
2. Set `WEBHOOK_URL` to your webhook endpoint (Discord, Slack, etc.)