From a6d81d993b2e2b151c77f4243dc0074a38be4abc Mon Sep 17 00:00:00 2001 From: Seth Woodworth Date: Tue, 26 Mar 2013 17:26:41 +0000 Subject: [PATCH] add additional handling for ocr-able files: pdf jpg png --- karmaworld/apps/notes/gdrive.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.25.1