|
38 | 38 | "arriving on time": "Package On Time",
|
39 | 39 | "accepted at usps origin facility": "Accepted",
|
40 | 40 | "accepted at usps destination facility": "Accepted",
|
| 41 | + "acceptance": "Accepted", |
41 | 42 | "package acceptance pending": "Arrived",
|
42 | 43 | "in/at mailbox": "Delivered",
|
43 | 44 | "garage / other door / other location at address": "Delivered",
|
44 | 45 | "left with individual": "Delivered",
|
| 46 | + "front door/porch": "Delivered", |
45 | 47 | "redelivery scheduled for next business day": "Rescheduled",
|
46 | 48 | "available for pickup": "Available",
|
47 | 49 | "reminder to schedule redelivery of your item": "Reminder",
|
48 |
| - "arriving late": "Arriving Late" |
| 50 | + "arriving late": "Arriving Late", |
| 51 | + "processed through facility": "Processed", |
| 52 | + "processed through usps facility": "Processed", |
| 53 | + "origin post is preparing shipment": "Preparing" |
49 | 54 | }
|
50 | 55 |
|
51 | 56 | # Main class
|
@@ -120,14 +125,18 @@ def track_package(cls, tracking_number: str) -> Package:
|
120 | 125 | if details.lower() == "reminder to schedule redelivery of your item":
|
121 | 126 | location = "SCHEDULE REDELIVERY"
|
122 | 127 |
|
| 128 | + detail_mapping = details.split(", ")[-1].lower() |
| 129 | + if detail_mapping not in USPS_STEP_DETAIL_MAPPING: |
| 130 | + print(f"Missing step mapping! Post this on GitHub: \"{detail_mapping}\" / \"{details}\"") |
| 131 | + |
123 | 132 | steps.append(Step(
|
124 |
| - USPS_STEP_DETAIL_MAPPING.get(details.split(", ")[-1].lower(), "Unknown") |
125 |
| - if "expected delivery" not in details.lower() else "Delivering", |
| 133 | + USPS_STEP_DETAIL_MAPPING.get(detail_mapping, "Unknown") |
| 134 | + if "expected delivery" not in detail_mapping.lower() else "Delivering", |
126 | 135 | location or "",
|
127 | 136 | datetime.strptime(
|
128 | 137 | time,
|
129 | 138 | "%B %d, %Y, %I:%M %p" if ":" in time else "%B %d, %Y"
|
130 |
| - ) |
| 139 | + ) if time.strip() else None |
131 | 140 | ))
|
132 | 141 |
|
133 | 142 | postal_product = tree.css_first(".product_info > li:first-child")
|
|
0 commit comments