Merge branch 'master' of github.com:foxmask/wallabag_api

This commit is contained in:
FoxMaSk
2017-08-12 21:28:14 +02:00

View File

@@ -103,6 +103,10 @@ class Wallabag(object):
try: try:
json_data = responses.json() json_data = responses.json()
except: except:
# sometimes json_data does not return any json() without
# any error. This is due to the grabbing URL which "rejects"
# the URL
if 'errors' in json_data:
for error in json_data['errors']: for error in json_data['errors']:
error_json = json_data['errors'][error]['content'] error_json = json_data['errors'][error]['content']
logging.error("Wallabag: {error}".format(error=error_json)) logging.error("Wallabag: {error}".format(error=error_json))
@@ -201,8 +205,8 @@ class Wallabag(object):
""" """
params = {'access_token': self.token, 'url': url, 'title': title, params = {'access_token': self.token, 'url': url, 'title': title,
'tags': tags, 'starred': starred, 'archive': archive} 'tags': tags, 'starred': starred, 'archive': archive}
if len(tags) > 0 and isinstance(tags, list): if len(tags) > 0 and ',' in tags:
params['tags'] = ', '.join(tags) params['tags'] = tags.split(',')
path = '/api/entries.{ext}'.format(ext=self.format) path = '/api/entries.{ext}'.format(ext=self.format)
return self.query(path, "post", **params) return self.query(path, "post", **params)
@@ -367,8 +371,8 @@ class Wallabag(object):
:return result :return result
""" """
params = {'access_token': self.token, 'tags': []} params = {'access_token': self.token, 'tags': []}
if isinstance(tags, list): if len(tags) > 0 and ',' in tags:
params['tags'] = ', '.join(tags) params['tags'] = tags.split(',')
path = '/api/entries/{entry}/tags.{ext}'.format( path = '/api/entries/{entry}/tags.{ext}'.format(
entry=entry, ext=self.format) entry=entry, ext=self.format)
return self.query(path, "post", **params) return self.query(path, "post", **params)