示例#1
0
def comment_detail(ctx, comment_id, oo, xx, favour):
  r = start_request(COMMENT_DETAIL.format(comment_id))
  render_comment_detail(r)
  r = start_request(TUCAO_LIST.format(comment_id))
  render_tucao_list(r)
  if oo:
    #ctx.forward(post_vote, comment_id=comment_id)
    ctx.invoke(post_vote, comment_id=comment_id, vote_type='pos', data_type='comment')
    xx = False
  if xx:
    ctx.invoke(post_vote, comment_id=comment_id, vote_type='neg')
  if favour:
    _add_favour(comment_id, category='comment')
示例#2
0
def comment_list(category, page, download):
  url = COMMENT_LIST.format(category)
  if page:
    today = datetime.now().strftime('%Y%m%d')
    page_encode = b64encode(f'{today}-{page}'.encode('utf-8')).decode('utf-8')
    url = f'{url}/{page_encode}#comments'
  r = start_request(url)
  render_comment_list(r, download)
示例#3
0
def post_vote(comment_id, vote_type, data_type):
  data = {
    'comment_id': comment_id,
    'vote_type': vote_type,
    'data_type': data_type
  }
  r = start_request(JD_VOTE, headers=make_dict(HEADERS, 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'), method='post', data=data)
  print(r)
示例#4
0
def post_report(comment_id, action, typo, reason):
  data = {
    'comment_id': comment_id,
    'action': action,
    'reason': reason
  }
  if typo == 1:
    data['type'] = 1
  r = start_request(JD_REPORT, headers=make_dict(HEADERS, 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'), method='post', data=data)
  print(r)
示例#5
0
def post_comment(author, email, comment, category, post_id):
  data = {'comment': comment}
  last_user = get_userinfo(USER_CONFIG)
  data = _make_user_info(author, email, data, last_user)
  if 'author' not in data or 'email' not in data:
    output.error(f'author and email must set')
    sys.exit(0)

  if category:
    r = start_request(COMMENT_LIST.format(category))
    comment_post_ID = parse_post_id(r['text'])
  else:
    if post_id == 0:
      output.error('post_id must be an integer not equal 0', bold=True)
      sys.exit(0)
    comment_post_ID = post_id

  data['comment_post_ID'] = comment_post_ID

  r = start_request(JD_COMMENT, headers=make_dict(HEADERS, 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'), method='post', data=data)
  if isinstance(r, int):
    output.succeed(f'post comment succeed, [comment_id] {r}')
  else:
    print(r)
示例#6
0
def post_tucao(author, email, content, comment_id):
  last_user = get_userinfo(USER_CONFIG)
  data = {
    'content': content,
    'comment_id': comment_id
  }
  data = _make_user_info(author, email, data, last_user)
  if 'author' not in data or 'email' not in data:
    output.error(f'author and email must set')
    sys.exit(0)

  r = start_request(JD_TUCAO, headers=make_dict(HEADERS, 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'), method='post', data=data)
  if 'code' in r and r['code'] == 0:
    output.succeed(f'tucao {r["msg"]}, [tucao_id] {r["data"]["comment_ID"]}, [author] {r["data"]["comment_author"]}')
  else:
    print(r)
示例#7
0
def article_list(page):
  r = start_request(ARTICLE_LIST.format(page))
  render_article_list(r)
示例#8
0
def article_detail(article_id, silence, favour):
  r = start_request(ARTICLE_DETAIL.format(article_id))
  render_article_detail(r, silence)
  if favour:
    _add_favour(article_id, category='article')