Skip to content

Instantly share code, notes, and snippets.

@patmandenver
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmandenver/7729f92b8956c7c9dffa to your computer and use it in GitHub Desktop.
Save patmandenver/7729f92b8956c7c9dffa to your computer and use it in GitHub Desktop.
Ruby code for dumping Skype logs to screen replace USERNAME and SKYPE_USERNAME with your own
#!/usr/bin/ruby
#
# DESCRIPTION:
# Simple ruby script for dumping message data from skype to screen
# easy to pipe to file and grep later
# change USERNAME and SKYPE_USERNAME to your own
#
#
# DEPENDENCIES:
# sqlite3-ruby
# os
#
#The MIT License (MIT)
#
#Copyright (c) 2015 Patrick Bailey
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#
#
require 'sqlite3'
require 'os'
username = 'USERNAME'
skype_name = 'SKYPE_USERNAME'
if OS.windows?
db_loc = "C:/Users/#{username}/AppData/Roaming/Skype/#{skype_name}/main.db"
elsif OS::Underlying.windows?
db_loc = "/cygdrive/c/Users/#{username}/AppData/Roaming/Skype/#{skype_name}/main.db"
elsif
db_loc = "/Users/#{username}/Library/Application Support/Skype/#{skype_name}/main.db"
else
abort "Exiting, Can't determine if OSX or Windows"
end
begin
db = SQLite3::Database.open db_loc
query = 'select msg.id, msg.timestamp, '\
'msg.from_dispname, con.meta_topic, '\
'msg.body_xml '\
'from messages as msg, conversations as con '\
'where msg.convo_id = con.id '\
'order by msg.id;'
stmt = db.prepare query
rs = stmt.execute
rs.each do |row|
puts row.join(":::").gsub(/\r?\n/, "\\n")
end
rescue SQLite3::Exception => e
puts "Exception occured"
puts e
ensure
stmt.close if stmt
db.close if db
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment