Browse Source

update docs

Yuxin Wu 8 years ago
parent
commit
5893e7c6e6
3 changed files with 15 additions and 10 deletions
  1. 11 6
      android-interact.sh
  2. 3 3
      count-message.sh
  3. 1 1
      list-chats.py

+ 11 - 6
android-interact.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 # File: android-interact.sh
-# Date: Fri Jun 26 10:38:07 2015 +0800
+# Date: Wed Nov 29 02:19:00 2017 -0800
 # Author: Yuxin Wu <[email protected]>
 
 PROG_NAME=`python -c "import os, sys; print(os.path.realpath(sys.argv[1]))" "$0"`
@@ -31,7 +31,7 @@ elif [[ $1 == "imei" ]]; then
 		imei=$(adb shell service call iphonesubinfo 1 | awk -F "'" '{print $2}' | sed 's/[^0-9A-F]*//g' | tr -d '\n')
 	}
 	[[ -n $imei ]] || {
-		>&2 echo "Failed to get imei. You can try other methods, or report a bug."
+		>&2 echo "Failed to get imei. You can try other methods mentioned in README, or report a bug."
 		exit 1
 	}
 	echo "Got imei: $imei"
@@ -51,12 +51,17 @@ elif [[ $1 == "db" || $1 == "res" ]]; then
 	echo "Found $numUser user(s). User chosen: $chooseUser"
 
 	if [[ $1 == "res" ]]; then
-		echo "Pulling resources... this might take a long time, because adb sucks..."
 		mkdir -p resource; cd resource
+		echo "Pulling resources... "
 		for d in avatar image2 voice2 emoji video sfs; do
-			mkdir -p $d; cd $d
-			adb pull "$RES_DIR/$chooseUser/$d"
-			cd ..
+			adb shell "cd $RES_DIR/$chooseUser &&
+								 busybox tar czf - $d 2>/dev/null | busybox base64" |
+					base64 -di | tar xzf -
+
+			# Old Slow Way:
+			# mkdir -p $d; cd $d
+			# adb pull "$RES_DIR/$chooseUser/$d"
+			# cd ..
 			[[ -d $d ]] || {
 				>&2 echo "Failed to download resource directory: $RES_DIR/$chooseUser/$d"
 				exit 1

+ 3 - 3
count-message.sh

@@ -1,6 +1,6 @@
 #!/bin/bash -e
 # File: count-message.sh
-# Date: Sun Apr 12 21:01:01 2015 +0900
+# Date: Wed Nov 29 02:32:40 2017 -0800
 # Author: Kangjing Huang <[email protected]>
 
 
@@ -11,7 +11,7 @@ then
 fi
 # TODO work on db directly
 
-echo -e "Filename\tCounts of message\tCounts of chars\tCounts of words"
+echo -e "Filename\t#Lines\t#Chars\t#Words"
 
 SAVEIFS=$IFS
 IFS=$(echo -en "\n\b")
@@ -23,6 +23,6 @@ do
     CHARCOUNT=$(cat "$i"| sed 's/.*:[0-9][0-9]:\(.*\)/\1/g'  | sed 's/\[.*\]//g'  | grep  -v img | wc -m)
     WORDCOUNT=$(cat "$i"| sed 's/.*:[0-9][0-9]:\(.*\)/\1/g'  | sed 's/\[.*\]//g'  | grep  -v img | wc -w)
     echo -e "$LINECOUNT\t$CHARCOUNT\t$WORDCOUNT"
-done
+done | sort -t $'\t' -k 2 -n | column -t -s $'\t'
 
 IFS=$SAVEIFS

+ 1 - 1
list-chats.py

@@ -14,4 +14,4 @@ db_file = sys.argv[1]
 parser = WeChatDBParser(db_file)
 chats = parser.msgs_by_chat.keys()
 for k in chats:
-    print parser.contacts[k],  '\t', k
+    print parser.contacts[k], '\t', k