Skip to content

Commit

Permalink
New papi.users_works instead of sapi.get_member
Browse files Browse the repository at this point in the history
  • Loading branch information
upbit committed May 17, 2015
1 parent fb6a0bb commit f881e5a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ class Pixiv_PAPI(object):
# 我的订阅
def me_feeds(self, show_r18=1):

# 用户作品
# publicity: public, private
def users_works(self, author_id, page=1, per_page=30, publicity='public'):

# 用户收藏
def users_favorite_works(self, author_id, page=1, per_page=30):
# publicity: public, private
def users_favorite_works(self, author_id, page=1, per_page=30, publicity='public'):

# 排行榜/过去排行榜
# mode:
Expand All @@ -77,10 +82,7 @@ class Pixiv_PAPI(object):
# r18g
# page: 1-n
# date: '2015-04-01' (仅过去排行榜)
def ranking_all(self, mode='daily', page=1, per_page=50, date=None,
image_sizes=['px_128x128', 'px_480mw', 'large'],
profile_image_sizes=['px_170x170', 'px_50x50'],
include_stats=True, include_sanity_level=True):
def ranking_all(self, mode='daily', page=1, per_page=50, date=None):
~~~~~

### SAPI
Expand Down Expand Up @@ -113,8 +115,9 @@ class Pixiv_SAPI(object):
@deprecated
def get_illust(self, illust_id, require_auth=False):

# 用户作品列表
# 用户作品列表 (新版客户端已使用 PAPI/users_works 代替)
# id: author id
@deprecated
def get_member(self, id, p=1):

# [需鉴权]用户收藏 (新版客户端已使用 PAPI/users/favorite_works 代替)
Expand Down
43 changes: 34 additions & 9 deletions pixivpy2/papi.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def me_feeds(self, show_r18=1):
url = 'https://public-api.secure.pixiv.net/v1/me/feeds.json'
headers = {
'Authorization': 'Bearer %s' % self.api.access_token,
'Cookie': 'PHPSESSID=%s' % self.api.session,
}
params = {
'relation': 'all',
Expand All @@ -83,23 +82,50 @@ def me_feeds(self, show_r18=1):
r = self.api._requests_call('GET', url, headers=headers, params=params)
return self.parse_result(r)

# 用户作品列表
# publicity: public, private
def users_works(self, author_id, page=1, per_page=30, publicity='public',
image_sizes=['px_128x128', 'px_480mw', 'large'],
profile_image_sizes=['px_170x170', 'px_50x50'],
include_stats=True, include_sanity_level=True):
self.api._require_auth()

url = 'https://public-api.secure.pixiv.net/v1/users/%d/works.json' % (author_id)
headers = {
'Authorization': 'Bearer %s' % self.api.access_token,
}
params = {
'page': page,
'per_page': per_page,
'publicity': publicity,
'include_stats': include_stats,
'include_sanity_level': include_sanity_level,
'image_sizes': ','.join(image_sizes),
'profile_image_sizes': ','.join(profile_image_sizes),
}
r = self.api._requests_call('GET', url, headers=headers, params=params)
return self.parse_result(r)

# 用户收藏
def users_favorite_works(self, author_id, page=1, per_page=30):
# publicity: public, private
def users_favorite_works(self, author_id, page=1, per_page=30, publicity='public',
image_sizes=['px_128x128', 'px_480mw', 'large'],
profile_image_sizes=['px_170x170', 'px_50x50'],
include_stats=True, include_sanity_level=True):
self.api._require_auth()

url = 'https://public-api.secure.pixiv.net/v1/users/%d/favorite_works.json' % (author_id)
headers = {
'Authorization': 'Bearer %s' % self.api.access_token,
'Cookie': 'PHPSESSID=%s' % self.api.session,
}
params = {
'page': page,
'per_page': per_page,
'publicity': 'public', # public or private
'include_work': 'true',
'include_stats': 'true',
'image_sizes': 'px_128x128,small,medium,large,px_480mw',
'profile_image_sizes': 'px_170x170,px_50x50',
'publicity': publicity,
'include_stats': include_stats,
'include_sanity_level': include_sanity_level,
'image_sizes': ','.join(image_sizes),
'profile_image_sizes': ','.join(profile_image_sizes),
}

r = self.api._requests_call('GET', url, headers=headers, params=params)
Expand All @@ -118,7 +144,6 @@ def ranking_all(self, mode='daily', page=1, per_page=50, date=None,
url = 'https://public-api.secure.pixiv.net/v1/ranking/all'
headers = {
'Authorization': 'Bearer %s' % self.api.access_token,
'Cookie': 'PHPSESSID=%s' % self.api.session,
}
params = {
'mode': mode,
Expand Down

0 comments on commit f881e5a

Please sign in to comment.