summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PKGBUILD14
-rw-r--r--habitica_api_v3.patch85
2 files changed, 96 insertions, 3 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 08489537ff4c..780754b85f6b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@
_pkgname=habitica
pkgname=python-habitica
pkgver=0.0.13
-pkgrel=1
+pkgrel=2
pkgdesc="Commandline interface to Habitica."
arch=('any')
url="https://pypi.python.org/pypi/habitica"
@@ -11,11 +11,19 @@ license=('MIT')
depends=('python' 'python-docopt' 'python-requests')
makedepends=('python-setuptools')
source=("https://pypi.python.org/packages/source/h/habitica/${_pkgname}-$pkgver.tar.gz"
- auth.cfg.sample)
+ auth.cfg.sample
+ habitica_api_v3.patch)
md5sums=('4fffa63a0f2c97a72826dbb77a603163'
- '73203917ea9a075cafaf287f9d707a15')
+ '73203917ea9a075cafaf287f9d707a15'
+ '51b8709c608ac1d6a95f6d3031cd53d6')
+prepare() {
+ cd "$srcdir/${_pkgname}-$pkgver"
+
+ patch -p0 -i $srcdir/habitica_api_v3.patch
+}
+
build() {
cd "$srcdir/${_pkgname}-$pkgver"
python setup.py build
diff --git a/habitica_api_v3.patch b/habitica_api_v3.patch
new file mode 100644
index 000000000000..66b58581e314
--- /dev/null
+++ b/habitica_api_v3.patch
@@ -0,0 +1,85 @@
+diff --git habitica/api.py habitica/api.py
+index 850d3ad..071f79c 100644
+--- habitica/api.py
++++ habitica/api.py
+@@ -13,7 +13,7 @@
+
+ import requests
+
+-API_URI_BASE = 'api/v2'
++API_URI_BASE = 'api/v3'
+ API_CONTENT_TYPE = 'application/json'
+
+
+@@ -48,19 +48,22 @@ def __call__(self, **kwargs):
+ if self.aspect:
+ aspect_id = kwargs.pop('_id', None)
+ direction = kwargs.pop('_direction', None)
++ uri = '%s/%s' % (self.auth['url'],
++ API_URI_BASE)
+ if aspect_id is not None:
+- uri = '%s/%s/%s/%s/%s' % (self.auth['url'],
+- API_URI_BASE,
+- self.resource,
+- self.aspect,
+- str(aspect_id))
++ uri = '%s/%s/%s' % (uri,
++ self.aspect,
++ str(aspect_id))
++ elif self.aspect == 'tasks':
++ uri = '%s/%s/%s' % (uri,
++ self.aspect,
++ self.resource)
+ else:
+- uri = '%s/%s/%s/%s' % (self.auth['url'],
+- API_URI_BASE,
+- self.resource,
+- self.aspect)
++ uri = '%s/%s/%s' % (uri,
++ self.resource,
++ self.aspect)
+ if direction is not None:
+- uri = '%s/%s' % (uri, direction)
++ uri = '%s/score/%s' % (uri, direction)
+ else:
+ uri = '%s/%s/%s' % (self.auth['url'],
+ API_URI_BASE,
+@@ -76,6 +79,6 @@ def __call__(self, **kwargs):
+
+ # print(res.url) # debug...
+ if res.status_code == requests.codes.ok:
+- return res.json()
++ return res.json()["data"]
+ else:
+ res.raise_for_status()
+diff --git habitica/core.py habitica/core.py
+index ffe6659..5135850 100755
+--- habitica/core.py
++++ habitica/core.py
+@@ -307,7 +307,7 @@ def cli():
+
+ # GET/POST habits
+ elif args['<command>'] == 'habits':
+- habits = hbt.user.tasks(type='habit')
++ habits = hbt.user.tasks(type='habits')
+ if 'up' in args['<args>']:
+ tids = get_task_ids(args['<args>'][1:])
+ for tid in tids:
+@@ -334,7 +334,7 @@ def cli():
+
+ # GET/PUT tasks:daily
+ elif args['<command>'] == 'dailies':
+- dailies = hbt.user.tasks(type='daily')
++ dailies = hbt.user.tasks(type='dailys')
+ if 'done' in args['<args>']:
+ tids = get_task_ids(args['<args>'][1:])
+ for tid in tids:
+@@ -357,7 +357,7 @@ def cli():
+
+ # GET tasks:todo
+ elif args['<command>'] == 'todos':
+- todos = [e for e in hbt.user.tasks(type='todo')
++ todos = [e for e in hbt.user.tasks(type='todos')
+ if not e['completed']]
+ if 'done' in args['<args>']:
+ tids = get_task_ids(args['<args>'][1:])