diff --git a/lib/msg.py b/lib/msg.py index 1f218db..7b0fa27 100644 --- a/lib/msg.py +++ b/lib/msg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: msg.py -# Date: Sat Dec 20 18:38:59 2014 +0800 +# Date: Sun Dec 21 21:23:27 2014 +0800 # Author: Yuxin Wu from datetime import datetime @@ -61,6 +61,7 @@ class WeChatMsg(object): url = soup.find('url').text if not url: title = soup.find('title').text + # TODO sometimes fail to parse title if not title: print self.content from IPython import embed; embed() diff --git a/lib/render.py b/lib/render.py index c5691b8..b40f48f 100644 --- a/lib/render.py +++ b/lib/render.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: render.py -# Date: Sat Dec 20 20:15:47 2014 +0800 +# Date: Sun Dec 21 21:21:53 2014 +0800 # Author: Yuxin Wu import os @@ -90,7 +90,9 @@ class HTMLRender(object): bigimgpath = self.parser.imginfo.get(msg.msgSvrId) fnames = [k for k in [imgpath, bigimgpath] if k is not None] bigimg, smallimg = self.res.get_img(fnames) - assert smallimg + if not smallimg: + logger.warn("No image thumbnail found for {}".format(imgpath)) + return fallback() # TODO do not show fancybox when no bigimg found return template.format(sender_label=sender, small_img=smallimg, diff --git a/lib/res.py b/lib/res.py index 80a97dd..6306a27 100644 --- a/lib/res.py +++ b/lib/res.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: res.py -# Date: Sat Dec 20 20:14:40 2014 +0800 +# Date: Sun Dec 21 21:22:44 2014 +0800 # Author: Yuxin Wu import glob @@ -155,6 +155,7 @@ class Resource(object): if len(candidates) > 1: # annimation candidates = [k for k in candidates if not re.match('.*_[0-9]+$', k)] + # only one file is the gif in need, others are frames and cover assert len(candidates) == 1 fname = candidates[0] return Resource.get_file_b64(fname), imghdr.what(fname) diff --git a/lib/static/TP_EMOJI.html b/lib/static/TP_EMOJI.html new file mode 100644 index 0000000..ad8d095 --- /dev/null +++ b/lib/static/TP_EMOJI.html @@ -0,0 +1,16 @@ +
+
+ +
+
+
+
+ + + +
+
+
+
+
+