Skip to content

Commit

Permalink
Add ranking demo for AppAPI, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
upbit committed Aug 6, 2016
1 parent 42c133e commit 370e33a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ class AppPixivAPI(BasePixivAPI):
# 用户收藏作品列表 (无需登录)
def user_bookmarks_illust(self, user_id, restrict='public'):

# 作品排行
# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]
# date: '2016-08-01'
# mode(r18榜单需登录): [day_r18, day_male_r18, day_female_r18, week_r18, week_r18g]
def illust_ranking(self, mode='day', date=None, offset=None):

# 关注用户的新作
# restrict: [public, private]
def illust_follow(self, restrict='public'):
Expand Down Expand Up @@ -152,6 +158,12 @@ print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))

# 2016-07-15 日的过去一周排行
json_result = aapi.illust_ranking('week', date='2016-07-15')
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))

# 关注用户的新作 (需要login)
json_result = aapi.illust_follow(req_auth=True)
print(json_result)
Expand Down
20 changes: 20 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,25 @@ def appapi_search(aapi):
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))

def appapi_ranking(aapi):
json_result = aapi.illust_ranking('day_male')
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))

# get next page
next_qs = aapi.parse_qs(json_result.next_url)
json_result = aapi.illust_ranking(**next_qs)
# print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))

# 2016-07-15 日的过去一周排行
json_result = aapi.illust_ranking('week', date='2016-07-15')
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))

def appapi_auth_api(aapi):
json_result = aapi.illust_follow(req_auth=True)
print(json_result)
Expand Down Expand Up @@ -269,6 +288,7 @@ def main():
appapi_recommend(aapi)
appapi_users(aapi)
appapi_search(aapi)
appapi_ranking(aapi)

# auth test
aapi.login(_USERNAME, _PASSWORD)
Expand Down

0 comments on commit 370e33a

Please sign in to comment.