Rebase server
This commit is contained in:
parent
9d60205841
commit
4e0d320680
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
|
import base64
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ class Helper():
|
|||||||
['inlineObjects'][id_doc]['inlineObjectProperties']
|
['inlineObjects'][id_doc]['inlineObjectProperties']
|
||||||
['embeddedObject']['imageProperties']['contentUri'])
|
['embeddedObject']['imageProperties']['contentUri'])
|
||||||
r = requests.get(link, stream=True)
|
r = requests.get(link, stream=True)
|
||||||
return r.raw
|
return base64.b64encode(r.content).decode('utf-8')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_image(cls, document):
|
def find_image(cls, document):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
|
import base64
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@ -190,23 +191,13 @@ class Helper():
|
|||||||
element += 1
|
element += 1
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_link_and_download(cls, id_doc, document):
|
|
||||||
if "inlineObjects" in document:
|
|
||||||
if id_doc in document['inlineObjects']:
|
|
||||||
link = (document
|
|
||||||
['inlineObjects'][id_doc]['inlineObjectProperties']
|
|
||||||
['embeddedObject']['imageProperties']['contentUri'])
|
|
||||||
r = requests.get(link, stream=True)
|
|
||||||
return r.raw
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_image(cls, document):
|
def find_image(cls, document):
|
||||||
for i in document['body']["content"]:
|
for i in document['body']["content"]:
|
||||||
if ("paragraph" in i) and ("elements" in i["paragraph"]):
|
if ("paragraph" in i) and ("elements" in i["paragraph"]):
|
||||||
if "inlineObjectElement" in i["paragraph"]["elements"]:
|
if "inlineObjectElement" in i["paragraph"]["elements"][0]:
|
||||||
return True, cls.get_link_and_download(
|
import base64
|
||||||
i["paragraph"]["elements"]
|
return True, base64.b64encode(open("photo.png", 'rb').read()).decode('utf-8')
|
||||||
['inlineObjectElement']['inlineObjectId'], document)
|
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user