NAME

wordpress-upload-media - upoad files to wordpress

DESCRIPTION

If you provide a date, we check for correctness before attempt.

Motivation

This allows you to upload media files like images etc to your wordpress blog. Very helpful.

USAGE

wordpress-upload-post [OPTIONS].. [PATH|DESCRIPTION]

-d path     simple text/html file containing content description
-h          help
-t string   title !
-D string   date !
-d path     path to text or html file holding description text, or text itself !
-u string   username *
-p string   password *
-x url      proxy, xmlrpc address *
-C path     load username, password, and proxy from this config file
-k          clean description text, if any
-n          don't post, just test

* required ! experimental

USAGE EXAMPLES

Load the login info from a file: wordpress-upload-media -d ./content.txt -t 'Red House Found' -C ./conf.txt file.jpg

Login conf example file:

-u usenamejim
-p passew2t42t
-x http://jimmysite.net/xmlrpc.php

You may specify the file with content for the description (the body of the post), via -d argument. The -d argument may also be a string instead. We check for existence first, to see if it is a file path arg. (This needs to be improved, potentially you an end up setting description to look like a file path just because it's not on disk..)

clean description text flag

If you want to clean the description text, use the -k flag. This makes it so

This is another kind of 
break that happens here.

As well as this 
 one.

Gets turned to

This is another kind of break that happens here.

As well as this 
 one.

This is useful if you have as decription input file, properly formatted 80 char wide data. This prevents wordpress from inserting breaks where we don't want them. For the web, it's best to have only paragraphs, the user can set the width and.. well. You know the argument.

ABOUT EXPERIMENTAL FEATURES

I always thought it would be cool if wordpress xmlrpc.php returned the id of a media file uploaded. That way, you could maybe set description and title of media! All via the command line! How coold would that be?!?!?!

So. Brace yourself. I have a hack here that does just that. It's a HACK. For real- HACK all uppercase letters.

What we do is if you try to set date, description, or title- after we upload the file, we try to find it by *guessing*, and matching filename against title. It's really a hack- and it does test itself pretty well. But it won't work in an environment where you have many people working on the same blog- not at all. And if you upload many files with the same filename, and don't give them any titles.

It will conk out after a few tries though, and the script has propper exit code back to shell.

Here's how it works.. Imagine you have a picture of a painting (this example uses a config file for credentials, you should realize that the credentials file can be named anything)..

wordpress-upload-media -C ~/mysite.wordpress.credentials -t 'Portrait of Lao Tzu' -d 'this is lao tzu. Nobody knows what he really looked like, but.. here he is.' ./lao-tzu-portrait.jpg

If this succeeds, we print out the struct updated as YAML. If we were able to upload, but could not set the title and description etc- then we print the url of the file uploaded, but we exit with error code to the shell.

    As you know, unix exits silently if all is good, with a code if not. If not, you need to read up on unix, I suggest http://catb.org/esr/writings/taoup/, the art of unix programming by Eric Raymond. Don't make excuses for not reading this- if you're looking for command line to wordpress, you have to learn the basics- there's no going around this. And on the good side, that way you'll become a fledgeling unix hacker like me! Wwheee!!!

SEE ALSO

WordPress::XMLRPC wordpress-upload-post wordpress-info WordPress::CLI - parent package

AUTHOR

Leo Charre leocharre at cpan dot org

LICENSE

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".

DISCLAIMER

This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the "GNU General Public License" for more details.