|
@@ -1,9 +1,5 @@
|
|
# -*- coding: utf-8 -*-
|
|
# -*- coding: utf-8 -*-
|
|
-from demeter.core import *
|
|
|
|
-from datetime import *
|
|
|
|
-import uuid
|
|
|
|
-import os
|
|
|
|
-import os.path
|
|
|
|
|
|
+from .__load__ import *
|
|
|
|
|
|
class Convert(object):
|
|
class Convert(object):
|
|
|
|
|
|
@@ -155,11 +151,14 @@ class Convert(object):
|
|
if not File.exists(info['local']):
|
|
if not File.exists(info['local']):
|
|
self.download(info['file'], info['local'])
|
|
self.download(info['file'], info['local'])
|
|
|
|
|
|
- if not File.exists(info['html']):
|
|
|
|
|
|
+ #if not File.exists(info['html']):
|
|
|
|
+ if info:
|
|
handle = self.command(info)
|
|
handle = self.command(info)
|
|
Shell.popen(handle)
|
|
Shell.popen(handle)
|
|
if File.exists(info['html']):
|
|
if File.exists(info['html']):
|
|
|
|
|
|
|
|
+ # 截屏
|
|
|
|
+ self.cut(info)
|
|
#self.string_switch(info['html'], "taste", "tasting")
|
|
#self.string_switch(info['html'], "taste", "tasting")
|
|
# 获取有多少页
|
|
# 获取有多少页
|
|
page = self.total(info['path'])
|
|
page = self.total(info['path'])
|
|
@@ -175,6 +174,22 @@ class Convert(object):
|
|
update['status'] = 4
|
|
update['status'] = 4
|
|
model.update(update)
|
|
model.update(update)
|
|
|
|
|
|
|
|
+ def cut(self, info):
|
|
|
|
+ pdf = Image(filename=info['pdf'], resolution=50)
|
|
|
|
+ jpg = pdf.convert('jpg')
|
|
|
|
+ req_image = []
|
|
|
|
+ i = 0
|
|
|
|
+ for img in jpg.sequence:
|
|
|
|
+ if i == 0:
|
|
|
|
+ img_page = Image(image=img)
|
|
|
|
+ req_image.append(img_page.make_blob('jpg'))
|
|
|
|
+ i = i+1
|
|
|
|
+
|
|
|
|
+ for img in req_image:
|
|
|
|
+ ff = open(info['html'] + '.jpg','wb')
|
|
|
|
+ ff.write(img)
|
|
|
|
+ ff.close()
|
|
|
|
+
|
|
def string_switch(self, x,y,z,s=1):
|
|
def string_switch(self, x,y,z,s=1):
|
|
with open(x, "r", encoding="utf-8") as f:
|
|
with open(x, "r", encoding="utf-8") as f:
|
|
#readlines以列表的形式将文件读出
|
|
#readlines以列表的形式将文件读出
|