Thursday, October 23, 2008

Pidgin log file to Adium log converter

Because I'm a business owner, need to keep in touch with many of my clients, partners and employees with all different kinds of IMs(MSN, Yahoo, AIM, GTalk, Jabber, etc.). I have been using Pidgin(both Windows and Linux) to work as my All-in-one IM clients for many many years, and accumulated tons of log files through Pidgin's html log plugin. And those logs are invaluable asset to me and my business.

I switched to Mac in the past year and use Adium (http://www.adiumx.com/) to handle my multiple IM accounts. But I was never able to find a way to convert my Pidgin logs to Adium.

So I finally decided to write one myself. The script is written in PHP, you need to modify some configuration parameters before it is executed:

$srcDir= Where the original Pidgin log files and folders are located
$destDir= Where to save converted Adium log files to
$masterAlias=array("Li","Li Ma","马力");//List all Alias names you ever used in all different IM accounts and in history. Very important to make conversions right


Once the script is configured, you can run it by:

php adium_convert.php


A log file will also be created when error occurs.

You also need to copy converted Adium logs to where your current Adium's log folder, which is normally:

~/Library/Application\ Support/Adium\ 2.0/Users/Default/Logs/


The complete code is:



The script was designed to resolve my issues first. Since we have to convert Pidgin log from html format, which is not very well formatted all the time, this converter might not work 100% for your case. It took me many days to make it work for all my log files. So please make sure you verify the converted log files after you run the script. Also make sure you keep the origina log files just in case.

Enjoy!

Li

16 comments:

Anonymous said...

OK

cvelo said...

Thanks for the hard work!

Gabe! said...

Thank you very much for the script; no-one else seems to have anything that works. All of the other google results are bug reports. Unfortunately, it didn't work for me, probably because I have extended timestamps. I modified the script so that it would work, and the modified version is as follows:
http://pastie.org/316505
A quick changelog: I removed $chatYear and changed the first-line-of-file regex to accept buddy names with spaces in them. I also modified the time regex (line 136 in the pastie) so it'd accept my logs' timestamps. Again, thanks very much for the script.

Li Ma said...

Hi Gabe!,

Thank you very much for your comments and most importantly for your adjustment to the code.
I already copied your code over, so everybody will download the latest version from you from my link.

I'm glad you liked my work.

Thanks again!

Li

Gabe! said...

Hi again.
I rewrote the script (in ruby this time) because I got some odd results with the PHP script, especially for non-standard status messages like the ones that Gaim-Encryption throws up. If you'd like to take a look, it's on http://people.brandeis.edu/~gbw/code
Again, thank you for creating this, it's been an enormous help.

Plamen said...

Hello Li,
Thank you for the script.
Here (http://pastie.org/321353) I've made some changes:
1) Renamed the class SrcHTMLFileParse to SrcFileParser
2) Renamed the method parseFile to parseFileHTML
3) Added new method parseFileTXT
4) Changed function convert() to handle also files with txt extension
5) Added new service name - icq

Now the script converts successfully both HTML and TXT formats of Pidgin.
And I successfully migrated from Pidgin to Adium.

Thanks!

paCkeT said...

Thanks for the initial attempt in writing this script. It saved me lots of time in getting my logs imported.

I have made some modifictions to what Plamen worked on.

I have posted my changes to pastbin site: http://pastie.org/349614

Changes I have made:

/**
* Changes made by Jeffery Fernandez <jeffery@fernandez.net.au>
* @since 2008-12-27
*
* Added Jabber Service Mapping
* Fixed Yahoo Service Mapping
* Fixed Chat conversation times
* Fixed XMl validity for chat messages
* Added work around for jabber protocol aliases
* Removed unwanted new lines in XML message (breaks Adium Transcipts view)
* Fixed Service Directory name
* Fixed regex for txt chat file
*
* Converting HTML pidgin messages are a pain. Syntax doesn't always match up with
* the current regex. I used the perl script below to convert all my html messages to
* text format before importing them into Adium. You will need to have cpan to install
* certain modules to get it to work.
* @link http://search.cpan.org/src/MSCHILLI/Gaim-Log-Parser-0.14/eg/gaimlog-html2text
*/

Anonymous said...

Just wanted to say thank you for this! Worked like a charm.

Anonymous said...

Thanks a lot for your work Gabel.

Is there a way to use your script to import Trillian logs into Adium?

Thanks in advance for your reply.

Dam

Li Ma said...

Dam,

I'm glad this script can be useful to you.
Since I don't use Trillian, so I don't know if it can do any help.

Li

Noah said...

Thanks for this script! I tried both Plamen and PaCkeT's versions, and both correctly create all the Adium log files themselves, but I'm left with just an empty parent < chat > node in the resulting XML. I'm using Pidgin's HTML log format.

Any thoughts? Thanks!

Li Ma said...

Noah,

Can you send me a sample HTML file you have, so I can have a look?

Li

Noah said...

Thanks. I'd send it, but your email address isn't anywhere on your site. ;)

I think it's an issue with the regex on line 170 of paCkeT's version, and may have to do with my date format.

If you want a copy of the HTML, go to the website listed in my Blogger profile; my contact info is there.

Thanks!

Gabe! said...

Hi Li,
I'm planning to create a Ruby gem to allow for wide distribution of my version of this program, but I'd like to see how you feel since it is originally based strongly on your program. This post appears to be the best (only) way for me to contact you about this.
Thanks,
Gabe

Li Ma said...

Gabe,

Yes, any improvement is more than welcome! So feel free to post your code.

Actually since I posted this code, I never had time to refine it further.

If you or anyone could make a better script or even a GUI that can make the conversion even smoother, I would be very very happy to see.

Cheers!

Gabe! said...

Li,
Thank you. The project is at http://rubyforge.org/projects/pidgin2adium/

About Me

Li Ma
President/CEO of Ideal Technologies Inc. Ideal Technologies Inc is a US-based IT company providing professional software development services to our clients all over the world.
View my complete profile