Coupon, v1.2
Posted on

Utility for a getting and a formatting of coupons from the admitad service.
A generation of a beautiful link, an output of a promocode in coupons, a removing of expired coupons (directly or via the single utility) and the utility for a removing of coupons from a database.
Change Log
- filtering of a coupon list:
- skip expired and expiring coupons (with a customizable gap before an end time of a coupon);
- outputting a coupon list:
- generate a beautiful link by a resolving of a redirection of a coupon link;
- save an end date of a coupon into its filename;
- output a promocode in the rich example of a coupon template;
- utilities:
- for a removing of expired and expiring coupons (with a customizable gap before an end time of a coupon);
- for a removing of coupons from a database and files simultaneously.
Features
- log in an admitad account;
- getting of a coupon list for a specific website;
- filter a coupon list:
- filter by a script in the microlanguage;
- disable a filtering for specified campaigns;
- via a remembering in an SQLite database:
- limit a frequency of coupons with same campaigns;
- skip coupons that were previously processed;
- skip expired and expiring coupons (with a customizable gap before an end time of a coupon);
- output a coupon list:
- generate a beautiful link by a resolving of a redirection of a coupon link;
- format an output:
- format an output with an Jinja2 template;
- Jinja2 template extensions:
- format a timestamp;
- flatten a text (replace line breaks with a specific string);
- extract a cut (first sentence) with a specific cut mark;
- split a text to paragraphs with a specific paragraph format (optionally skip a specific cut mark);
- output target may be:
- separate files:
- save an end date of a coupon into its filename;
- stdout;
- separate files:
- utilities:
- for a removing of expired and expiring coupons (with a customizable gap before an end time of a coupon);
- for a removing of coupons from a database and files simultaneously.
Usage
$ coupon
Environment variables:
COUPON_ADMITAD_ID— ID of the Admitad app;COUPON_ADMITAD_SECRET— secret of the Admitad app;COUPON_SITE_ID— ID of the site;COUPON_OUTPUT_PATH— path for output coupons (default:./coupons/);COUPON_TEMPLATE— path to the coupon template (default:./docs/rich_coupon_template.example.html);COUPON_LOCALE— locale for timestamp formatting (default:ru_RU);COUPON_SCRIPT— path to the filter script (default:./docs/coupon_script.example.00.coupon);COUPON_OUTPUT_MODE— mode of output coupons (default:FILES|STDOUT);COUPON_CAMPAIGNS— comma-separated list of disabled campaigns (default:Domino's Pizza, Связной, Юлмарт);COUPON_DATABASE— path to the SQLite database (default:./coupon.db);COUPON_NUMBER— allowed count of coupons with same campaigns (default:1);COUPON_INTERVAL— time window for restriction of coupons with same campaigns (default:86400);COUPON_TIMESTAMP_GAP— gap before an end time of a coupon for skipping of expiring coupons (default:0).
Environment variables can be specified in a .env config in the format:
NAME_1=value_1
NAME_2=value_2
...
See details about the format: https://github.com/motdotla/dotenv#rules.
A .env config will never modify any environment variables that have already been set.
Repository
Link: https://github.com/thewizardplusplus/coupon/tree/v1.2.
Content: code.
License: MIT.
Screenshots
Usage of the utility for a removing of expired coupons

Usage of the utility for a removing of coupons from a database
