Compare commits
9 Commits
wallabag_a
...
1.2.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e30e5393f0 | ||
|
|
825efab0f7 | ||
|
|
2c269fba43 | ||
|
|
07d3840ca6 | ||
|
|
43b1602cbb | ||
|
|
c6f62a4697 | ||
|
|
63cd4e80cb | ||
|
|
b7d4abb0d1 | ||
|
|
5b3cd028a7 |
@@ -27,7 +27,7 @@ to get the project, from your virtualenv, do :
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
git clone https://github.com/foxmask/wallabag-api/
|
git clone https://github.com/push-things/wallabag_api/
|
||||||
|
|
||||||
|
|
||||||
or
|
or
|
||||||
@@ -110,7 +110,7 @@ Creating a post :
|
|||||||
|
|
||||||
this will give you something like this :
|
this will give you something like this :
|
||||||
|
|
||||||
.. image:: https://github.com/foxmask/wallabag_api/blob/master/wallabag.png
|
.. image:: https://github.com/push-things/wallabag_api/blob/master/wallabag.png
|
||||||
|
|
||||||
|
|
||||||
Testing :
|
Testing :
|
||||||
@@ -124,7 +124,7 @@ Then create a client API like explain here http://doc.wallabag.org/en/v2/develop
|
|||||||
|
|
||||||
this will give you something like this
|
this will give you something like this
|
||||||
|
|
||||||
.. image:: https://github.com/foxmask/wallabag_api/blob/master/wallabag_api_key.png
|
.. image:: https://github.com/push-things/wallabag_api/blob/master/wallabag_api_key.png
|
||||||
|
|
||||||
Then replace the client_id / client_secret / login / pass to wallabag_test.py and run
|
Then replace the client_id / client_secret / login / pass to wallabag_test.py and run
|
||||||
|
|
||||||
|
|||||||
12
setup.py
12
setup.py
@@ -2,19 +2,21 @@ from setuptools import setup, find_packages
|
|||||||
from wallabag_api import __version__ as version
|
from wallabag_api import __version__ as version
|
||||||
|
|
||||||
desc = 'Wallabag API to add every pages you want to your Wallabag account'
|
desc = 'Wallabag API to add every pages you want to your Wallabag account'
|
||||||
|
long_desc = 'Wallabag is a "read it later" service, and that Wallabag API allow you to save web pages ' \
|
||||||
|
'to your own account'
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'aiohttp==2.2.5',
|
'aiohttp',
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='wallabag_api',
|
name='wallabag_api',
|
||||||
version=version,
|
version=version,
|
||||||
description=desc,
|
description=desc,
|
||||||
|
long_description=long_desc,
|
||||||
author='FoxMaSk',
|
author='FoxMaSk',
|
||||||
author_email='foxmask@trigger-happy.eu',
|
author_email='foxmaskhome@gmail.com',
|
||||||
url='https://github.com/foxmask/wallabag_api',
|
url='https://github.com/push-things/wallabag_api',
|
||||||
download_url="https://github.com/foxmask/wallabag_api/archive/"
|
download_url="https://github.com/push-things/wallabag_api/archive/wallabag_api-" + version + ".zip",
|
||||||
"wallabag_api-" + version + ".zip",
|
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 5 - Production/Stable',
|
'Development Status :: 5 - Production/Stable',
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
VERSION = (1, 2, 0) # PEP 386
|
VERSION = (1, 2, 3) # PEP 386
|
||||||
__version__ = ".".join([str(x) for x in VERSION])
|
__version__ = ".".join([str(x) for x in VERSION])
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class Wallabag(object):
|
|||||||
client_id='',
|
client_id='',
|
||||||
client_secret='',
|
client_secret='',
|
||||||
extension='json',
|
extension='json',
|
||||||
user_agent="WallabagPython/1.3 "
|
user_agent="WallabagPython/1.2.2 "
|
||||||
"+https://github.com/foxmask/wallabag-api",
|
" +https://github.com/push-things/wallabag-api",
|
||||||
aio_sess=None):
|
aio_sess=None):
|
||||||
"""
|
"""
|
||||||
init variable
|
init variable
|
||||||
@@ -97,10 +97,13 @@ class Wallabag(object):
|
|||||||
:param responses: the json response
|
:param responses: the json response
|
||||||
:return the json data without 'root' node
|
:return the json data without 'root' node
|
||||||
"""
|
"""
|
||||||
if responses.status != 200:
|
|
||||||
raise HttpProcessingError(code=responses.status,
|
|
||||||
message=await responses.json())
|
|
||||||
json_data = {}
|
json_data = {}
|
||||||
|
if responses.status != 200:
|
||||||
|
err_msg = HttpProcessingError(code=responses.status,
|
||||||
|
message=await responses.json())
|
||||||
|
logging.error("Wallabag: aiohttp error {err_msg}".format(
|
||||||
|
err_msg=err_msg))
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
json_data = responses.json()
|
json_data = responses.json()
|
||||||
except ClientResponseError as e:
|
except ClientResponseError as e:
|
||||||
@@ -147,8 +150,6 @@ class Wallabag(object):
|
|||||||
"""
|
"""
|
||||||
# default values
|
# default values
|
||||||
params = dict({'access_token': self.token,
|
params = dict({'access_token': self.token,
|
||||||
'archive': 0,
|
|
||||||
'star': 0,
|
|
||||||
'delete': 0,
|
'delete': 0,
|
||||||
'sort': 'created',
|
'sort': 'created',
|
||||||
'order': 'desc',
|
'order': 'desc',
|
||||||
@@ -157,23 +158,14 @@ class Wallabag(object):
|
|||||||
'tags': '',
|
'tags': '',
|
||||||
'since': 0})
|
'since': 0})
|
||||||
|
|
||||||
params['archive'] = self.__get_attr(what='archive',
|
if 'archive' in kwargs and int(kwargs['archive']) in (0, 1):
|
||||||
type_attr=int,
|
params['archive'] = int(kwargs['archive'])
|
||||||
value_attr=(0, 1),
|
if 'star' in kwargs and int(kwargs['star']) in (0, 1):
|
||||||
**params)
|
params['star'] = int(kwargs['star'])
|
||||||
params['star'] = self.__get_attr(what='star',
|
if 'delete' in kwargs and int(kwargs['delete']) in (0, 1):
|
||||||
type_attr=int,
|
params['delete'] = int(kwargs['delete'])
|
||||||
value_attr=(0, 1),
|
if 'order' in kwargs and kwargs['order'] in ('asc', 'desc'):
|
||||||
**params)
|
params['order'] = kwargs['order']
|
||||||
params['delete'] = self.__get_attr(what='delete',
|
|
||||||
type_attr=int,
|
|
||||||
value_attr=(0, 1),
|
|
||||||
**params)
|
|
||||||
params['order'] = self.__get_attr(what='order',
|
|
||||||
type_attr=str,
|
|
||||||
value_attr=('asc', 'desc'),
|
|
||||||
**params)
|
|
||||||
|
|
||||||
if 'page' in kwargs and isinstance(kwargs['page'], int):
|
if 'page' in kwargs and isinstance(kwargs['page'], int):
|
||||||
params['page'] = kwargs['page']
|
params['page'] = kwargs['page']
|
||||||
if 'perPage' in kwargs and isinstance(kwargs['perPage'], int):
|
if 'perPage' in kwargs and isinstance(kwargs['perPage'], int):
|
||||||
@@ -187,7 +179,8 @@ class Wallabag(object):
|
|||||||
|
|
||||||
return await self.query(path, "get", **params)
|
return await self.query(path, "get", **params)
|
||||||
|
|
||||||
async def post_entries(self, url, title='', tags='', starred=0, archive=0):
|
async def post_entries(self, url, title='', tags='', starred=0, archive=0, content='', language='', published_at='',
|
||||||
|
authors='', public=1, original_url=''):
|
||||||
"""
|
"""
|
||||||
POST /api/entries.{_format}
|
POST /api/entries.{_format}
|
||||||
|
|
||||||
@@ -198,12 +191,20 @@ class Wallabag(object):
|
|||||||
:param tags: tag1,tag2,tag3 a comma-separated list of tags.
|
:param tags: tag1,tag2,tag3 a comma-separated list of tags.
|
||||||
:param starred entry already starred
|
:param starred entry already starred
|
||||||
:param archive entry already archived
|
:param archive entry already archived
|
||||||
|
:param content additionnal html content
|
||||||
|
:param language
|
||||||
|
:param published_at
|
||||||
|
:param authors
|
||||||
|
:param public
|
||||||
|
:param original_url
|
||||||
:return result
|
:return result
|
||||||
"""
|
"""
|
||||||
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 ',' in tags:
|
'content': content, 'language': language, 'published_at': published_at,
|
||||||
params['tags'] = tags.split(',')
|
'authors': authors, 'public': public, 'original_url': original_url}
|
||||||
|
if len(tags) > 0 and isinstance(tags, list):
|
||||||
|
params['tags'] = ', '.join(tags)
|
||||||
path = '/api/entries.{ext}'.format(ext=self.format)
|
path = '/api/entries.{ext}'.format(ext=self.format)
|
||||||
return await self.query(path, "post", **params)
|
return await self.query(path, "post", **params)
|
||||||
|
|
||||||
@@ -329,7 +330,8 @@ class Wallabag(object):
|
|||||||
|
|
||||||
:return result
|
:return result
|
||||||
"""
|
"""
|
||||||
params = {'url': url,
|
params = {'access_token': self.token,
|
||||||
|
'url': url,
|
||||||
'urls': urls}
|
'urls': urls}
|
||||||
|
|
||||||
path = '/api/entries/exists.{ext}'.format(ext=self.format)
|
path = '/api/entries/exists.{ext}'.format(ext=self.format)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
import datetime
|
||||||
import unittest
|
import unittest
|
||||||
from wallabag import Wallabag
|
from wallabag import Wallabag
|
||||||
|
|
||||||
@@ -33,17 +34,23 @@ class TestWallabag(unittest.TestCase):
|
|||||||
|
|
||||||
def create_entry(self):
|
def create_entry(self):
|
||||||
title = 'foobar title'
|
title = 'foobar title'
|
||||||
url = 'https://smcomm.trigger-happy.eu/'
|
url = 'https://somwhere.over.the.raibow.com/'
|
||||||
tags = ['foo', 'bar']
|
tags = ['foo', 'bar']
|
||||||
starred = 0
|
starred = 0
|
||||||
archive = 0
|
archive = 0
|
||||||
data = self.w.post_entries(url, title, tags, starred, archive)
|
content = '<p>Additional content</p>'
|
||||||
|
language = 'FR'
|
||||||
|
published_at = datetime.datetime.now()
|
||||||
|
authors = 'John Doe'
|
||||||
|
public = 0
|
||||||
|
original_url = 'http://localhost'
|
||||||
|
data = self.w.post_entries(url, title, tags, starred, archive, content, language, published_at, authors,
|
||||||
|
public, original_url)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def test_get_entries(self):
|
def test_get_entries(self):
|
||||||
params = {'archive': 0,
|
params = {'delete': 0,
|
||||||
'star': 0,
|
|
||||||
'delete': 0,
|
|
||||||
'sort': 'created',
|
'sort': 'created',
|
||||||
'order': 'desc',
|
'order': 'desc',
|
||||||
'page': 1,
|
'page': 1,
|
||||||
@@ -109,5 +116,6 @@ class TestWallabag(unittest.TestCase):
|
|||||||
self.assertTrue(resp, True)
|
self.assertTrue(resp, True)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user