Skip to content

Instantly share code, notes, and snippets.

@ramidem
Last active March 22, 2023 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramidem/a4510a0ae46b4b595847e97344942227 to your computer and use it in GitHub Desktop.
Save ramidem/a4510a0ae46b4b595847e97344942227 to your computer and use it in GitHub Desktop.
A script that periodically fetches the delivery status of an AP Cargo package using its airwaybill number and displays it as a notification (MacOS ONLY).
#!/usr/bin/env python3
"""
AP Cargo Tracker
A script that periodically fetches the delivery status of an AP Cargo package using its airwaybill number and displays it as a notification (MacOS ONLY).
Make the file executable
chmod +x ap_cargo.py
Usage:
./ap_cargo_tracker.py <airwaybill>
Example:
./ap_cargo_tracker.py 20921600
Created with the help of ChatGPT, a large language model trained by OpenAI.
"""
import sys
import time
import os
import requests
while True:
response = requests.get(
f"https://api.apcargo.com.ph/api/DeliveryStatus/external?airwaybill={sys.argv[1]}")
data = response.json()
latest = data['Items'][0]
status = latest['DeliveryStatus'][0]['Status']
date_string = latest['Date']
location = latest['DeliveryStatus'][0]['Location']
message = f"""Status: {status}
Date: {date_string}
Location: {location}
"""
os.system(
f"osascript -e \'display notification \"{message}\" with title \"AP Cargo Package\"\'")
time.sleep(8 * 60 * 60) # Fetch data every 8 hours
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment