NAME
WWW::CDBaby - Automate interaction with cdbaby.com!
VERSION
Version 0.08
SYNOPSIS
my $cdbaby = new WWW::CDBaby( "$account_name", "$password" );
# Print the name of the first person who bought your CD
my ( @sales ) $cdbaby->get_cd_sales( $album_id );
print $sales[0]->{'name'};
METHODS
get_cd_sales( album_id )
Pass this method the URL of your album. If you can see your album at "cdbaby.com/amberg", your album_id is "amberg".
It returns an array of hashrefs containing all your physical album sales. Digital sales are tracked separately.
This method gets the text-delimited file you get if you log into members.cdbaby.com, click "Accounting", click the "$ sold" amount next to the album name, and click the "download your sales in a tab-delimited text file" link. See how much easier this method is? ;-)
use WWW::CDBaby;
my $cdbaby = new WWW::CDBaby;
my ( @sales ) = $cdbaby->get_cd_sales( $album_id );
my $total=0;
foreach $sale ( @sales ) {
$total += $sale->{'paid_to_you'};
}
print "Total profits: \$$total\n";
FIelds returned as of 1/14/08 are:
date
quantity
sell_price
wholesale
paid_to_you
name
referred_by
ship_inst
email
addr1
addr2
city
state
postalcode
country
get_dd_sales( album_id )
Pass this method the URL of your album. If you can see your album at "cdbaby.com/amberg", your album_id is "amberg".
It returns an array of hashrefs containing your digital distribution sales and plays for that album.
This method gets the HTML table you get if you Go to the "Digital" tab and click the amount next to INCOME for one of your albums. It parses the HTML into one hash for each row. The keys to the hash are taken directly from the headers at the top of the table and modified to make them program-friendly:
Leading and trailing whitespace is stripped
white space is replaced by "_"
# by itself is turned into "quantity"
caps are made lower case.
Any remaining characters that aren't letters, numbers, or _ are stripped
The current keys returned (as of 1/14/2008) are:
company
sales_date
report_date
song
price
quantity
subtotal
As these keys are taken directly from the headers at the top of the table, if rows are added or removed or the headers are changed by CD Baby, the keys to your hash will change accordingly. Note that the "#" header, however, is translated into "quantity". Prior to version 0.04, this was incorrectly translated to "no" (although documented as translating to "quantity").
Also, the dollar sign ("$") from the price fields is removed so you can do things like the example below:
use WWW::CDBaby;
my $cdbaby = new WWW::CDBaby;
my ( @sales ) = $cdbaby->get_dd_sales( $album_id );
my $total=0;
foreach $sale ( @sales ) {
$total += $sale->{'subtotal'};
}
print "Total profits: \$$total\n";
(Note: when I run this script, I get a number slightly lower than the total shown on the DD page. This is probably either CD Baby rounding the numbers (probably up :) or some floating point issue.)
AUTHOR
Grant Grueninger, <grantg at cpan.org>
BUGS
Please report any bugs or feature requests to bug-www-cdbaby at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-CDBaby. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc WWW::CDBaby
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2007 Grant Grueninger, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.