Package: imessagedb
imessagedbReads and displays the Apple iMessage databaseInstallation$pipinstallimessagedbUsageimessagedbcan be used as a library for accessing and parsing the iMessasge chat database
stored at ~/Library/Messages/chat.db, or it can be used on the command line to display the contents.How it worksThe command line version wraps the functions provided and outputs data based on the
configuration available in the configuration file, as well as command line arguments.The way that iMessage identifies conversation particpants is by ahandle, which can be their
phone number or email address. To make it easier, you can map handles in the configuration file.You can also specify the type of output (text or html) and the time frame of the messages. At
this pointimesssagedbwill pull all messages from that person, regardless of the chat that it
is part of.If you specify html output,imessagedbwill copy your attachments so that they are accessible
to the web browser. In addition, it will convert certain types of attachments so that they
can be viewed in the browser. For instance, it will convert HEIC files to PNG so that they
browser can display it, and will convert various type of movie files to mp4 and various audio
files to mp3. If you have many attachments, this can take a long time and take a lot of space.Example OutputThis is what the default html version looks like. Note that I am hovering over one of the
links to show the image.This is the same conversation rendered in text.Command Lineimessagedb[-h][--handle[HANDLE...]|--nameNAME][-cCONFIGFILE][-oOUTPUT_DIRECTORY][--databaseDATABASE][-mME][-t{text,html}][-i][-f|--no_copy][--no_attachments][-v][--start_timeSTART_TIME][--end_timeEND_TIME]optionalarguments:-h,--helpshowthishelpmessageandexit--handle[HANDLE...]Alistofhandlestosearchagainst--nameNAMEPersontogetconversationsabout-cCONFIGFILE,--configfileCONFIGFILELocationoftheconfigurationfile-oOUTPUT_DIRECTORY,--output_directoryOUTPUT_DIRECTORYTheoutputdirectorywheretheoutputandattachmentsgo--databaseDATABASEThedatabasefiletoopen-mME,--meMEThenametousetorefertoyou-t{text,html},--output_type{text,html}Thetypeofoutput-i,--inlineShowtheattachmentsinline-f,--forceForceacopyoftheattachments--no_copyDon't copy the attachments--no_attachmentsDon't process attachments at all-v,--verboseTurnonadditionaloutput--start_timeSTART_TIMEThestarttimeofthemessages--end_timeEND_TIMETheendtimeofthemessages--split_outputSPLIT_OUTPUTSplitthehtmloutputintofileswiththismanymessagesperfile--versionShowtheversionnumberandexit--get_handlesDisplaythelistofhandlesinthedatabaseandexit--get_chatsDisplaythelistofchatsinthedatabaseandexitCommand line options-hprints a help message                                                                        |--handle [HANDLE ...]A list of handles to search against.
For instance, '--handle +12016781234john@smith.com'.--name NAMEA person to search for. The mapping of person to handle is in the configuration
file (see below)*** Note that you can only have one of --handle or --name, not both ***-c CONFIGFILE, --configfile CONFIGFILEThe location of the configuration file. If the
file does not exist, a default configuration file will be created there. If this option is
not provided, the default location is~/.conf/iMessageDB.ini.-o OUTPUT_DIRECTORY, --output_directory OUTPUT_DIRECTORYThe output directory where the
output and attachments go. If this option is not provided, the default location is your
home directory. The files will be~/NAME.htmland attachments will be in~/NAME_Attachments.--database DATABASEThe database file to open. If this option is not provided it will
default to~/Library/Messages/chat.db, which is where Apple puts it.-m ME, --me METhe name to use to refer to you in the output. If this option is not
provided it will default toMe.-t {text,html}, --output_type {text,html}The type of output, eithertextorhtml.
If this option is not provided it will default tohtml.--start_time START_TIME--end_time END_TIMEBy default, the program will process all messages. If you want
to restrict that to particular timeframe, you can specify the--start-timeand/or--end_timeoptions--split_output SPLIT_OUTPUTSplit the html output into files with this many messages
per file-i, --inlineShow the attachments inline. By default, the attachments will show as links
that you can hover over and it will pop up the attachment. With this option, it will put them
inline, which will make your output much busier and take a lot more memory in your browser.-f, --forceForce a copy of the attachments. By default, if the attachment already exists
in the destination directory, it will not re-copy the file, but this will force it to re-copy it.--no_copyDon't copy the attachments. This will make them inaccessible for
viewing--no_attachmentsDo not show the attachments at all-v, --verboseTurn on additional output--versionShows the version number and exits--get_handlesDisplay the list of handles in the database and exit--get_chatsDisplay the list of chats in the database and exitConfiguration FileThe configuration file is in configparser format. Here is the template that is created
by default:[CONTROL]# Whether or not to copy the attachments into a different directory. This is needed for two reasons:#  1) The web browser does not have access to the directory that the attachments are stored, so it cannot display them#  2) Some of the attachments need to be converted in order to be viewed in the browsercopy=True# The directory to put the output. The html file will go in {copy_directory}/{Person}.html,#   and the attachments will go in {copy_directory}/{Person}_Attachments. If you specify HOME, then#   it will put it in your home directorycopydirectory=HOME# If the file already exists in the destination directory it is not recopied, but that can be overridden by#  specifying 'force copy' as trueforcecopy=False# 'Skip attachments' ignores attachmentsskipattachments=False# Additional details show some other information on each message, including the chat id and any edits that have#  been doneadditionaldetails=False# Some extra verbosity if trueverbose=True[DISPLAY]# Output type, either html or textoutput_type=html# Number of messages in each html file. If this is 0 or not specified, it will be one large file.outputsplit=1000# Inline attachments mean that the images are in the HTML instead of loaded when hovered overinlineattachments=False# Popup location is where the attachment popup window shows up, and is either 'upper right', 'upper left' or 'floating'popuplocation=upperright# 'me' is the name to put for your text messagesme=Me# The color for the name in text output. No color is used if 'use text color' is false.#  The color can only be one of the following options:#   black, red, green, yellow, blue, magenta, cyan, white, light_grey, dark_grey,#   light_red, light_green, light_yellow, light_blue, light_magenta, light_cyanusetextcolor=Truemetextcolor=bluethemtextcolor=magentareplytextcolor=light_grey# The background color of the text messages for you and for the other person in html output# The options for colors can be found here: https://www.w3schools.com/cssref/css_colors.phpmehtmlbackgroundcolor=AliceBluethemhtmlbackgroundcolor=Lavender# The background color of the thread in repliesthreadbackground=HoneyDewmethreadbackground=AliceBluethemthreadbackground=Lavender# The color of the name in the html outputmehtmlnamecolor=Bluethemhtmlnamecolor=Purple[CONTACTS]# A person that you text with can have multiple numbers, and you may not always want to specify the full specific#  number as stored in the handle database, so you can do the mapping here, providing the name of a person,#  and a comma separated list of numbersSamantha:+18434676040,samanthasmilt@gmail.com,s12ddd2@colt.eduAbe:+16103499696Marissa:+14029490739Library Usageimportimessagedbdatabase=imessagedb.DB()TODO - More usage hereContributingInterested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.Licenseimessagedbwas created by Xev Gittler. It is licensed under the terms of the MIT license.DocumentationFull documentation available athttps://imessagedb.readthedocs.io/en/latest/