Command line utility that parses the CSV output from indiegogo and creates printable shipping labels for perk fulfillment.
It has two modes: One for generating address labels only and one for purchasing pre-paid USPS package shipping labels using the easypost API.
The idea is that you can print address labels for all letters weighing under 1 oz (for shipping e.g. stickers). Print one stack of address labels for all international destinations and another for all national destinations. USPS sells one type of stamp that works for all national < 1 oz letters and another that works for all international < 1 oz letters, so it is easy to slap on an address label and a stamp on each letter.
For packages the postage isn't so simple so instead we use the easypost.com API to buy and print pre-paid USPS package shipping labels.
The address labels can be printed using a Brother QL570 printer and the ql570 print utility (use the narrow 29 mm label type).
To print the package shipping labels you probably want a 4x6" shipping label printer. We've used the Zebra ZPL 500 Plus and it works well.
This software is in an early (but working) state. Improvements welcome!
This code works with node v0.10.25
sudo apt-get install nodejs libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ cd gogo-labeler/ npm install
cp settings.js.example settings.js cp packages.js.example packages.js
For normal address labels you can go with the defaults. For pre-paid package shipping labels you will need to adjust these files quite a bit.
Adress labels (no pre-paid shipping)
Export the relevant CSV from indiegogo to contributions.csv and run:
mkdir labels ./index.js --labelOnly --country "united states" --local contributions.csv labels/
This will create a bunch of .png files in the labels/ directory. If you don't like how they look, or if you get errors having to do with the text being too long or there being too many lines, then you can tweak the settings.js file. Specifically the font size, lineSpacing and padding are worth a look.
The --country "united states" argument means every shipping address outside of the U.S. is ignored. You can also use --notCountry to do the opposite. The --local argument means that the country is not included on the label.
Example using notCountry:
./index.js --labelOnly --notCountry "united states" contributions.csv labels/
Specifying required fields
By default, the following fields are required:
- address (or address_2)
If --local is specified, then country is not included on the label and does not have to be specified. If the --country is "United States" then state_province is also required.
To change the defaults, use --require to add more required fields:
./index.js --labelOnly --country "mexico" --require state_province,address_2 contributions.csv labels/
You can prevent fields from being required using --ignore:
./index.js --country "singapore" --ignore city contributions.csv labels/
Sizes only matter if you're printing pre-paid package labels.
If you have sizes for e.g. T-shirts then you should specify each size of t-shirt as a separate perk in packages.js with names like "t-shirt_perk_name size" e.g. if your t-shirt perk is called "Awesome T-Shirt!" then you should have packages.json entries like "Awesome T-Shirt! medium", "Awesome T-Shirt! xl", "Awesome T-Shirt! xxl" etc.
You should have a separate CSV file which has the fields pledge_id and size. You specify this CSV using the --sizeFile argument, e.g:
./index.js --perk "Awesome T-Shirt!" --sizeFile sizes.csv contributions.csv labels/
You can also set the default size to use when no size is present:
./index.js --perk "Awesome T-Shirt!" --sizeFile sizes.csv --defaultSize medium contributions.csv labels/
If no defaultSize is specified then medium is used.
You can also filter on size using:
Printing the address labels
Make sure the ql570 command is in your PATH and do:
cd labels/ for i in *.png; do ql570 /dev/usb/lp0 n $i; done
Pre-paid package shipping labels
PLEASE NOTE: Printing packages shipping labels (that include postage) is currently limited to packages shipped from the United States. This is a limitation in easypost.
In order to use this functionality you must sign up for an easypost.com account and add a valid credit card to the account.
This program will always select the cheapest USPS shipping option available through easypost.
The command line usage is the same as for the address labels, except for the following:
- You must omit the --labelOnly
- You must specify perk with --perk "Indiegogo Perk Name"
- You must set the easypost settings in settings.js
- You must set fromAddress in settings.js
- If you are shipping internationally you must set customsInfo in settings.js
- You must add entries in packages.js for each perk. Note that the items field is only required for international shipment.
There is an example packages.js in packages.js.example.
If you're running in testing mode (no money being paid and fake shipping labels being generated) then you can use:
./index.js --perk "T-shirt" contributions.csv labels/
If you're running in production mode, where money WILL be spent, then you add --reallyPayMoney:
./index.js --reallyPayMoney --perk "T-shirt" contributions.csv labels/
In production mode, You will be prompted for each shipping label to ensure that you are really sure you want to pay for shipping, and to verify the custom information for international packages.
The filename of the label files will be the full name of the person at the destination address (stripped of special characters) followed by the USPS tracking code.
Note that all purchased shipping labels and their tracking numbers will also be viewable through the easypost web interface, so all is not lost if you loose the shipping label files.
Printing the pre-paid shipping labels
Setting up printer
Add the printer using the printer settings on your (linux-based) system. Use the Zebra ZPL Label Printer driver (assuming your printer has a model number starting with ZP). Make sure to set the Resolution to 203dpi, the Media Size to the 4.00x6.00" and the Media Tracking to the correct setting (probably Non-continuous (Web sensing)).
You'll probably want to lower the printing speed to the lowest setting to ensure that the barcodes are nice and legible.
For the Zebra ZPL 500 Plus printer there are two ways to route the label-paper through the printer. The simple straight-through way will not automatically peel the labels off the label-paper, and will require that Print Mode is set to Peel-Off. The slightly more complicated routing which is shown on the instructions on the printer will automatically peel the labels and will require that the Print Mode is set to Tear-Off.
Printing from the command line
lpstat -p -D
You will see a line like:
printer Zebra-ZP-500-Plus is idle. enabled since Thu 29 Jan 2015 05:16:39 PM PST
Now print using:
lpr -P PRINTER_NAME -o page-left=0 -o page-right=0 -o page-top=0 -o page-bottom=0 FILENAME.png
lpr -P Zebra-ZP-500-Plus -o page-left=0 -o page-right=0 -o page-top=0 -o page-bottom=0 label.png
Using this to print pre-paid shipping labels for arbitrary CSV files
If you happen to have a CSV file with just a list of addresses you can still use the pre-paid postage functionality.
Just use shipper.js:
Usage: ./shipper.js --perk "T-shirt" --out labels/ addresses.csv Where the named perk is defined in packages.js and --out specifies the dir wherein to store the shipping labels.
It will ask you which CSV fields map to which address fields.
Note that you can map multiple CSV files to the same address field, e.g. if your input CSV has the fields "first name" and "last name" you can map them both to the name field and they will simply be concatenated with a space between the first and last name.
If you get the error:
Error: Too many lines. Text does not fit on label.
Then try lowering the font.size or font.lineSpacing in settings.js
Copyright and license
Copright 2015 and 2017 Marc Juul
License: AGPLv3 (see the file COPYING)