# job_monitor.py
from meter_sdk import MeterClient
import os
import time
import json
from datetime import datetime
client = MeterClient(api_key=os.getenv("METER_API_KEY"))
# Configuration
CONFIG = {
"schedule_id": "your-schedule-id", # TODO: Replace
"check_interval": 1800, # 30 minutes
"criteria": {
"keywords": ["python", "backend"],
"location": "remote",
"exclude": ["senior", "lead", "staff"]
},
"alert_email": "[email protected]" # TODO: Replace
}
JOB_DB_FILE = "known_jobs.json"
def load_known_jobs():
"""Load known job IDs"""
try:
with open(JOB_DB_FILE, 'r') as f:
return set(json.load(f))
except FileNotFoundError:
return set()
def save_known_jobs(known_jobs):
"""Save known job IDs"""
with open(JOB_DB_FILE, 'w') as f:
json.dump(list(known_jobs), f, indent=2)
def create_job_id(job):
"""Create unique job identifier"""
# TODO: Create stable ID based on your data
# return f"{job['company']}_{job['title']}_{job.get('location', '')}"
return str(hash(str(job))) # Placeholder
def matches_criteria(job, criteria):
"""Check if job matches criteria"""
# TODO: Implement matching logic
# title = job.get('title', '').lower()
# location = job.get('location', '').lower()
# Keywords match
# keyword_match = any(kw.lower() in title for kw in criteria['keywords'])
# Location match
# location_match = criteria['location'].lower() in location
# Exclude terms
# excluded = any(term.lower() in title for term in criteria['exclude'])
# return keyword_match and location_match and not excluded
return True # Placeholder
def send_alert(jobs):
"""Send alert for new jobs"""
# TODO: Implement alerting (email, Slack, etc.)
print(f"\n🚨 ALERT: {len(jobs)} new matching jobs!")
for job in jobs:
print(f" - {job}")
def monitor():
"""Main monitoring loop"""
known_jobs = load_known_jobs()
while True:
print(f"\n[{datetime.now()}] Checking for new jobs...")
changes = client.get_schedule_changes(
CONFIG['schedule_id'],
mark_seen=True
)
if changes['count'] == 0:
print("No new job postings")
else:
print(f"Processing {changes['count']} updates")
new_matching_jobs = []
for change in changes['changes']:
for job in change['results']:
job_id = create_job_id(job)
if job_id not in known_jobs:
known_jobs.add(job_id)
if matches_criteria(job, CONFIG['criteria']):
new_matching_jobs.append(job)
if len(new_matching_jobs) > 0:
send_alert(new_matching_jobs)
save_known_jobs(known_jobs)
else:
print("No new jobs matching criteria")
print(f"Waiting {CONFIG['check_interval']} seconds...")
time.sleep(CONFIG['check_interval'])
if __name__ == "__main__":
monitor()