Guest User

Untitled

a guest
Jun 9th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.22 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. LOGDIR="~/skype"
  5. US="ourskypeid"
  6.  
  7. if [ -e ${LOGDIR}/.skype2pidid ]; then
  8.     LASTID=$(cat ${LOGDIR}/.skype2pidid);
  9. else
  10.     LASTID=0;
  11. fi
  12.  
  13. printf "Last synced id is %s.\n" "${LASTID}";
  14.  
  15. db=$(mktemp)
  16.  
  17. cp /home/claudius/.Skype-home/.Skype/ourskypeid/main.db ${db}
  18.  
  19. printf "${db}\n";
  20. for i in $(sqlite3 ${db} "select id from Messages where id > ${LASTID} and type = 61 order by timestamp;"); do
  21.     remote=$(sqlite3 ${db} "select dialog_partner from Messages where id = ${i}")
  22.     if [ -z "${remote}" ]; then
  23.     convid=$(sqlite3 ${db} "select convo_id from Messages where id = ${i}")
  24.     remote=$(sqlite3 ${db} "select dialog_partner from Messages where convo_id = ${convid} and dialog_partner != '' LIMIT 1")
  25.     fi
  26.     content=$(sqlite3 ${db} "select body_xml from Messages where id = ${i};")
  27.     author=$(sqlite3 ${db} "select author from Messages where id = ${i}")
  28.     time=$(sqlite3 ${db} "select timestamp from Messages where id = ${i}")
  29.     printf "Got id %s (%s from/to %s).\n" "${i}" "${content}" "${remote}"
  30.     if [ "${remote}" = "" ]; then
  31.     remote=${author}
  32.     fi
  33.     mkdir -p ${LOGDIR}/${remote}
  34.     if [ ! -e ${LOGDIR}/${remote}/$(date -d "@${time}" +%Y-%m-%d)*SKYP* ]; then
  35.         cfile="${LOGDIR}/${remote}/$(date -d "@${time}" +%Y-%m-%d.%H%M%S+0000SKYP.html)"
  36.         printf "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><title>Skype Conversation with %s at %s on %s</title></head><body><h3>Skype Conversation with %s at %s on %s</h3>\n" "${remote}" "$(date -d "@${time}")" "${US}" "${remote}" "$(date -d "@${time}")" "${US}" >> "${cfile}"
  37.     else
  38.         cfile=$(ls ${LOGDIR}/${remote}/$(date -d "@${time}" +%Y-%m-%d)*SKYP*)
  39.     fi
  40.     if [ ${author} = "${US}" ]; then
  41.         printf "<font color=\"#16569E\"><font size=\"2\">(%s)</font> <b>%s:</b></font> %s<br />\n" "$(date -d "@${time}" "+%Y-%m-%d %H:%M:%S")" "${US}" "${content}" >> "${cfile}"
  42.     else
  43.         printf "<font color=\"#A82F2F\"><font size=\"2\">(%s)</font> <b>%s:</b></font> %s<br />\n" "$(date -d "@${time}" "+%Y-%m-%d %H:%M:%S")" "${remote}" "${content}" >> "${cfile}"
  44.     fi
  45.     LASTID=${i}
  46. done
  47.  
  48. printf "%s" ${LASTID} > ${LOGDIR}/.skype2pidid
  49.  
  50. printf "Last synced id is %s.\n" "${LASTID}";
  51. rm ${db}
Advertisement
Add Comment
Please, Sign In to add comment