avoid using cover, and use compressed emoji.cache
This commit is contained in:
@@ -79,7 +79,7 @@ Note that commands involving `./android-interact.sh` are meant to be run on the
|
||||
```
|
||||
+ What you'll need in the end is a `resource` directory with the following subdir: `emoji,image2,sfs,video,voice2`.
|
||||
|
||||
+ (Optional) Download the emoji cache from [here](https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache)
|
||||
+ (Optional) Download uncompress the emoji cache from [here](https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache)
|
||||
and put it under `wechat-dump`. This will avoid downloading lots of emojis in rendering.
|
||||
|
||||
#### Run:
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
# File: emoji-cache-tool.py
|
||||
# Author: Yuxin Wu <[email protected]>
|
||||
|
||||
import cPickle as pickle
|
||||
import sys
|
||||
import os
|
||||
import imghdr
|
||||
import base64
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print """\
|
||||
Usage:
|
||||
{} unpack output-dir
|
||||
{} pack input-dir
|
||||
""".format(sys.argv[0], sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[1] == 'unpack':
|
||||
with open('emoji.cache') as f:
|
||||
dic = pickle.load(f)
|
||||
outdir = sys.argv[2]
|
||||
assert os.path.isdir(outdir)
|
||||
for md5, img in dic.iteritems():
|
||||
name = os.path.join(outdir, md5 + '.' + img[1].lower())
|
||||
print name
|
||||
with open(name, 'wb') as f:
|
||||
f.write(base64.decodestring(img[0]))
|
||||
elif sys.argv[1] == 'pack':
|
||||
ret = {}
|
||||
indir = sys.argv[2]
|
||||
files = os.listdir(indir)
|
||||
for fname in files:
|
||||
try:
|
||||
md5, format = fname.split('.')
|
||||
except:
|
||||
print "Unable to parse", fname
|
||||
continue
|
||||
with open(os.path.join(indir, fname)) as f:
|
||||
b64 = base64.encodestring(f.read())
|
||||
ret[md5] = (b64, format)
|
||||
with open('emoji.cache', 'wb') as f:
|
||||
pickle.dump(ret, f)
|
||||
+4
-3
@@ -214,9 +214,10 @@ class Resource(object):
|
||||
if f:
|
||||
return get_file_b64(f), imghdr.what(f)
|
||||
|
||||
f = try_use([k for k in candidates if k.endswith('_cover')])
|
||||
if f:
|
||||
return get_file_b64(f), imghdr.what(f)
|
||||
# don't try do use cover anymore. cover is not animated
|
||||
#f = try_use([k for k in candidates if k.endswith('_cover')])
|
||||
#if f:
|
||||
#return get_file_b64(f), imghdr.what(f)
|
||||
return None, None
|
||||
|
||||
def _get_internal_emoji(self, fname):
|
||||
|
||||
Reference in New Issue
Block a user