qutIM2Pidgin History Converter
, 01 May, 2010
Ending up dissatisfied with the instant messenger qutIM, I decided to switch back to the good old Pidgin. In order not to lose my qutIM message history, I dropped some Python lines, which turned into a full-grown script enabling you to convert your logs from one format into the other one.
$HOME/.config/qutim/qutim.Myself/history/ICQ.987654321/123456789.201004.json
:
[ { "datetime": "2010-04-30T13:45:08", "type": 1, "in": false, "text": "Hello!" }, { "datetime": "2010-04-30T13:45:14", "type": 1, "in": true, "text": "Hi!" }, { "datetime": "2010-04-30T13:45:30", "type": 1, "in": false, "text": "How are you?" } ]
Format qutIM 0.2.0
$HOME/.purple/logs/icq/987654321/123456789/2010-04-30.134508+0200CEST.txt
:
Conversation with 123456789 at Fri 30 Apr 2010 13:45:08 CEST on 987654321 (icq) (13:45:08) Myself: Hello! (13:45:14) Bob: Hi! (13:45:30) Myself: How are you?
Format Pidgin (cleartext)
What it does
Firstly, the script tries to find qutIM in its default path ($HOME/.config/qutIM)
and lists all present protocols giving you the chance to pick the protocol whose history you want to convert. If there is more than one profile (identity) available, chose one first. Afterwards the contactlist.ini
gets indexed so that the names can be inserted at the proper place in the Pidgin files. Having checked the determined timezone, you can finally start the actual transformation.
What it really does (Behind the Scenes)
The magic takes place while iterating over all old history files (.json). Each block between the braces { }
represents a message.
- Firstly, it extracts the partner ID (e.g. the ICQ# or Jabber-ID) from the filename and inserts it in the header of the new Pidgin file,
- likewise the date from the first
datetime
-line, type
is ignored.- If
in
is true, the message is incoming and we prefix the corresponding nickname taken from the ID to it; if false, our own nickname. text
is the message text itself which we escape (see notes)- So far we wrote the header and one line into the variable which becomes the cleartext Pidgin log file. The scripts appends new lines to it until either the input file ends or the date in the file changes.
Notes, downer
- Python required
- Tested with qutIM 0.2.0, Pidgin 2.7.0, Jabber and ICQ history
- Not checking long silence sequences in conversations of the same day, the script puts the messages in the same file (unlike Pidgin itself which creates a new file for every new conversation start).
- The start time getting inserted in the header of each log is not the moment you open the conversation tab but the time you send/receive the first message.
- The escape sequence replacing newlines and inverted commas are based on trial and error and therefore experimental. I advise you to check it (lines 137–139).
- The switch
-v
prints the files the script is currently writing to.
Use at ones own risk. Backup recommended, albeit the script does not replace files. Published 2010 under the MIT License.
Run by typing
$ python ./qutim2pidgin.py
Download
Current version: 0.1 / May, 1st 2010
↶ qutim2pidgin.py.txt (9.5KB text/plain) or
↶ qutim2pidgin.py.gz (3.5KB application/x-gzip)
Comments
Your comment:
So far...
http://krasview.ru/files/qutim2pidgin.py
Just do not understand how to run first.
Maybe, youre create this script for Windows, please?
And you also forgot to describe whether it is necessary firstly to create contacts in Pidgin manually, or your script will create them automatically.
$ python ./q2p.pyHistory-Converter qutIM->Pidgin v0.1Setting Paths:qutIM path: /home/chuckha/.config/qutimokay? [Y/n]> yHere are your protocol identities in qutIM. Choose one:[1] ICQ.40886385[2] ICQ.41548698[3] ICQ.521688761Enter your nickname that will appear in your histories: chukchaFetching Nicknames out of contactlist.ini [/home/chuckcha/.config/qutim/qutim.chuckha/ICQ.40886385/contactlist.ini]... OKYour OS reported this as the current timezone setting:-Your timezone has a DaylightSavingTime-Your local timezone without DST is: +0200CET-Your local timezone with DST is: +0300CESTDo you want to change these settings? [y/N]---START---Working in /home/chukcha/.config/qutim/qutim.chuckha/history/ICQ.40886385File 1/24 1004.201011.json...Cannot find a related nickname for this ID: 1004Look it up yourself and enter it:File 2/24 179342402.201008.json...Cannot find a related nickname for this ID: 179342402Look it up yourself and enter it:File 3/24 290862045.201008.json...Cannot find a related nickname for this ID: 290862045Look it up yourself and enter it:
etc.What??