From: Seth Woodworth Date: Tue, 26 Mar 2013 17:26:41 +0000 (+0000) Subject: add additional handling for ocr-able files: pdf jpg png X-Git-Tag: release-20150131~457^2~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a6d81d993b2e2b151c77f4243dc0074a38be4abc;p=oweals%2Fkarmaworld.git add additional handling for ocr-able files: pdf jpg png --- diff --git a/karmaworld/apps/notes/gdrive.py b/karmaworld/apps/notes/gdrive.py index a12b6c9..4c4f5fb 100644 --- a/karmaworld/apps/notes/gdrive.py +++ b/karmaworld/apps/notes/gdrive.py @@ -123,9 +123,14 @@ def convert_with_google_drive(note): service, http = build_api_service(creds) + # get the file extension + filename, extension = os.path.splitext(note.note_file.path) # Upload the file - # TODO: wrap this in a try loop that does a token refresh if it fails - file_dict = service.files().insert(body=resource, media_body=media, convert=True, ocr=True).execute() + if extension.lower() in ['.pdf', '.jpg', '.png']: + # include OCR on ocr-able files + file_dict = service.files().insert(body=resource, media_body=media, convert=True, ocr=True).execute() + else: + file_dict = service.files().insert(body=resource, media_body=media, convert=True).execute() if u'exportLinks' not in file_dict: # wait some seconds