mmspulautin.pl
Summary
mmspulautin.pl is your solution for moblogging (mobile blogging) with Blosxom. It takes email messages or multimedia messages (MMSes) sent to email addresses as input, and outputs a Blosxom entry with thumbnails and content that has been converted to various formats.
Current version is 0.3 (2005-09-18). Changelog
mmspulautin.pl was written by Antti Vähä-Sipilä <avs@iki.fi>.
If you link here, use http://www.iki.fi/avs/mmspulautin.
Word of warning
This is an early alpha release, and the script probably contains more bugs that I can count. Use at your own risk: I take no responsibility for anything that happens, or does not happen, when using this software. Please report all bugs. Also, the code makes your eyes hurt, probably I will clean that up in later versions as well. See known bugs.
Requirements
First of all, you need some basic knowledge of Unix-style machines, Perl, and compiling things. I may have more time to write more detailed install instructions here in the future, but for the time being, you need to be adventurous.
- You need a Blosxom-based blog (for details on how to set one up, see Blosxom home page)
- You need a shell account with capability of running Perl scripts (and of course, web space)
- You need Procmail
- You need the following software:
- cjpeg, djpeg, jpegtran (Debian: libjpeg-progs package)
- jhead (Debian: jhead package)
- ppmscale (Debian: netpbm package)
- MIME::Parser (available from CPAN, install using normal Perl module install scheme, or search Debian packages)
- MIME::Words (CPAN)
- Locale::Recode (CPAN)
- Text::WikiFormat (CPAN)
- ffmpeg newest CVS snapshot, compiled with 3GPP codecs (see below). This version does not work with earlier versions than 0.4.9-pre1.
Installation
First, make sure you got a working Blosxom setup. Then, take mmspulautin.pl and stick it to some directory that you can run it from. Take a look at the configuration items in the start of mmspulautin.pl. The meaning of configuration items is explained there.
Having configured the script, you now need to make sure you have a proper support of codecs in ffmpeg. Type "ffmpeg -formats" and see if the amr codec is present. If not, you need to compile ffmpeg with AMR support. At the time of writing, this involves obtaining AMR source from 3GPP. See libavcodec/amr.c in the ffmpeg distribution for details. The URL given in the amr.c file has probably changed because 3GPP keeps releasing new versions of the AMR codec. Also note that if you are compiling on non-Intel platform, the AMR codec source typedefs need to be fixed. If you want MP3 support, you also need to compile ffmpeg with lame.
Now that everything is set, you need to send yourself some test MMS or email messages. Save them to files from your mail client (with full headers; an 'mbox' style file with one message is what I mean) and run mmspulautin.pl by piping the mail message to it. Be sure to set $reporting to get debug output. Note: I was told that the MIME decoding module that I am using uses your environment variable LC_CTYPE for something and fails if it contains something exotic. Therefore, just stick to the 'C' locale when doing the tests (or unset LC_CTYPE). When you run the script through Procmail, this is unlikely to matter. And: never ever skip this command line testing part. Use some dummy directories and check that the script actually creates the files as it's supposed to. Only after you've satisfied with the script on the command line, put it in real use.
When you have determined that everything works, you can put the necessary recipe in your .procmailrc to pipe mails to mmspulautin.pl. This looks something like this:
:0
* ^TOyour@blog.address
| /home/youracct/bin/mmspulautin.pl
Now, send a test message to yourself and it should appear in the blog.
Help me to test this thing
After you have made it this far, please send me an MMS from your phone. I use those MMSes to debug this script and to find out whether there are any mystical problems with some MMSCs that need special attention. Please send your MMS to avs+mms@iki.fi, and include some multimedia content (image, video, audio) and some text, preferably using weird letters (like, if you have an Arabic character set in your phone, send me some Arabic).
Please include the following information in your message: your phone make and model, your operator, and if possible, your email address.
Noteworthy items (and hints on usage)
- Remember to escape @ signs in email addresses in regexps.
- When run from command line, some LC_CTYPE environment variable contents are poisonous. Unset them.
- You need to put the password either on Subject: line or at the start of one of the text segments of the message (text/plain body parts). If it is the subject, the rest of the subject is interpreted as the blog entry subject. If the rest of the subject is empty, you will get an empty subject for the blog entry. If you put the password in the text/plain body part, the subject is treated as the blog entry subject.
- You can rename your image by starting it with "90", "180" or "270". If the image starts with these strings, it will be rotated this many degrees before posting to blog. As an example, 90foobar.jpg will be rotated 90 degrees counter-clockwise. If your image contains Exif orientation data, that will be automatically used. So you should be able to just copy images from your digicam to an email and send it to mmspulautin. However, you can override this manually by specifying the rotation as described here.
- At the start of the message, you can add an arbitrary number of Blosxom Meta plugin control lines (starting with "meta-"). These will be appended to the blog entry so that the Blosxom Meta plugin will make the contents available in $meta namespace. As an example, "meta-foo: bar" will result in "bar" being the content of $meta::foo. You must install the Blosxom Meta plugin for this to work. Hint: I use this for Technorati tags; edit your RSS/Atom feeds to include the tag.
- If you're unhappy with the variety of conversions that are offered (video clips end up as 3GPP, MPEG and AVI streams, audio clips as AMR, WAV and MP3), you can change the code to suit yourself.
- HTML body parts are not used. This is because we would have to parse them and extract the body to be included in the blog entry. Because any half-decent email client (and my MMSC) generate alternative text/plain body parts, I don't see this a very big problem.
- The textual content that you write should be in Wiki format. Here is an example tutorial. Basically, it's text, links are created with square brackets [like this] and you can use asterisks to create lists. Not every fancy thing might be supported.
- If your message contains several images, video clips, or audio clips, they will all be put to the blog entry. Text parts will be concatenated in a pseudo-random order (for example, if I send a two-page MMS from my phone, the second page seems to end up first in the resulting e-mail).
- If you attach several images with Exif (digital camera header) data, your Blosxom entry will get a date from one of these (again in the abovementioned pseudo-random fashion). If just one, your story date will be set to match the Exif data. File name still reflects the date when mmspulautin was run, but Blosxom uses the file date to actually sort the entries.
- "mmspulautin" can be roughly translated as "MMS belcher". Actually the word I'm searching for is the thing you do to small babies after they've eaten (they vomit small things on your shoulder, I've been told -- luckily I don't have any kids).
All .3g2 and .awb files are stored as .3gp and .amr, respectively. This should not cause any problems as web browsers detect the right plugin by MIME type anyway, and these are the same (video/3gpp and audio/3gpp) for all of these file types.
Security
The script should not be using any user-supplied data in dangerous ways. All content is renamed before writing to the filesystem. However, as the script relies on other software, any security holes in those packages may expose vulnerabilities.
The authentication of the messages depends only on the password. As email is not secure, you should be using a disposable password that you do not use elsewhere.
If you encounter any security vulnerabilities in this software, please let me know immediately: avs@iki.fi.
- 0.3: Tested with Nokia 9500 Communicator and Nokia 6630. Added support for
meta tags for Blosxom Meta plugin.
Added support for .awb and
.3g2 files (AMR wideband audio). Ffmpeg command lines fixed to work with current releases. This needs at least ffmpeg
0.4.9-pre1. Fixed MPEG frame rate. Realplayer support removed,
replaced with AVI. (Realplayer nowadays natively supports 3GPP and new
Realplayer versions seem to barf on the old audio codec that ffmpeg
uses.) Added changing image orientation automatically if
specified in Exif data (manual orientation change will still
override). The script now gets the timestamp for Blosxom story from
Exif header of JPEG image, if included in the entry. Author and
copyright info are now added to JPEG images. Report email subjects now
state "FAIL" or "SUCCESS".
- 0.2: Tested with Motorola E365 on Orange (thanks Paul). Workaround for broken Nokia 6600 email MIME types. Fixed still image thumbnailing. Fixed XHTML incompatibility. Fixed MIME decoding in subjects. Fixed email signature deletion. Added weeding out MMSC subjects.
- 0.1.2: Documentation changes only.
- 0.1.1: Documentation changes. Fixed chmod of target text file. (JA)
- 0.1: Initial release.
License
Copyright (C) 2003-2005 Antti Vähä-Sipilä
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
See GNU GPL here.