diff --git a/src/config.py b/src/config.py index 37e764a..3164168 100644 --- a/src/config.py +++ b/src/config.py @@ -9,7 +9,7 @@ AUTH_URL = 'https://accounts.google.com/o/oauth2/auth?scope=%(scope)s&redirect_uri=%(redirect_uri)s&response_type=code&client_id=%(client_id)s&access_type=offline&approval_prompt=force' % {'scope' : SCOPE, 'redirect_uri' : REDIRECT_URI, 'client_id' : CLIENT_ID} TOKEN_URL = 'https://www.googleapis.com/oauth2/v3/token' -FILES_URL = 'https://www.googleapis.com/drive/v2/files?fields=items&q=mimeType%3D%22application%2Fvnd.google-apps.document%22+or+mimeType%3D%22application%2Fvnd.google-apps.spreadsheet%22' +FILES_URL = 'https://www.googleapis.com/drive/v2/files?maxResults=1000&q=mimeType%3D%22application%2Fvnd.google-apps.document%22+or+mimeType%3D%22application%2Fvnd.google-apps.spreadsheet%22+or+mimeType%3D%22application%2Fvnd.google-apps.presentation%22&fields=items' CACHE_MAX_AGE = 60*60*24*30 # cache set to 1 month diff --git a/src/drive_api.py b/src/drive_api.py index 2c29820..145436e 100644 --- a/src/drive_api.py +++ b/src/drive_api.py @@ -83,8 +83,7 @@ def get_links(cls): if 'error' in response and cls.refresh(): return cls.get_links() else: - unfiltered_list = response['items'] - return util.filter_by_file_type(unfiltered_list, ['spreadsheet', 'document']) + return response['items'] @classmethod def refresh_list(cls): @@ -216,7 +215,7 @@ def add_items(cls, links): for index, link in enumerate(links): title = link['title'] alternateLink = link['alternateLink'] - icon = link['icon'] + icon = util.find_icon(link) wf.add_item( title=title, arg=alternateLink, diff --git a/src/icons/slides.png b/src/icons/slides.png new file mode 100644 index 0000000..02a1a26 Binary files /dev/null and b/src/icons/slides.png differ diff --git a/src/util.py b/src/util.py index e0340dc..f38fb26 100644 --- a/src/util.py +++ b/src/util.py @@ -14,18 +14,11 @@ def internet_on(): except urllib2.URLError as err: pass return False -def filter_by_file_type(list, file_types): - filter_list = [] - for index, link in enumerate(list): - type = '' - try: - type = link['mimeType'].split('.')[2] - except: - pass - if type in file_types: - # refactor - icon = './icons/sheets.png' if type == 'spreadsheet' else './icons/docs.png' - link['icon'] = icon - link['type'] = type - filter_list.append(link) - return filter_list +def find_icon(link): + if link['mimeType'] == 'application/vnd.google-apps.document': + icon = './icons/docs.png' + elif link['mimeType'] == 'application/vnd.google-apps.spreadsheet': + icon = './icons/sheets.png' + elif link['mimeType'] == 'application/vnd.google-apps.presentation': + icon = './icons/slides.png' + return icon