Skip to content

Instantly share code, notes, and snippets.

@ranlix
Last active December 17, 2015 10:49
Show Gist options
  • Save ranlix/5597809 to your computer and use it in GitHub Desktop.
Save ranlix/5597809 to your computer and use it in GitHub Desktop.
# coding=utf-8
import time
from datetime import datetime
from douban_client import DoubanClient
LAST_MINUTE = 59 # when it is the last mintue in an hour,the minute is (60-1)
MINUTE_SECONDS = 60 # one minute has 60s
API_KEY = 'your api key'
API_SECRET = 'your api secret'
SCOPE = 'douban_basic_common,shuo_basic_r,shuo_basic_w'
client = DoubanClient(API_KEY, API_SECRET, 'https://douban.com', SCOPE)
print 'Go to the following link in your browser:'
print client.authorize_url
code = raw_input('Enter the verification code:')
client.auth_with_code(code)
print client.auth_with_token(client.token_code)
def main():
'''This is a main function to print bell when time is the whole point.'''
if time.localtime().tm_min == 1: # LAST_MINUTE:
# when the minute is 59, the sleep time is not 60s any more
time.sleep(MINUTE_SECONDS-time.localtime().tm_sec)
client.miniblog.new( "当!"*int(datetime.now().strftime("%I")))
else:
time.sleep(MINUTE_SECONDS)
>>> ================================ RESTART ================================
>>>
Go to the following link in your browser:
https://www.douban.com/service/auth2/auth?scope=douban_basic_****************************
Enter the verification code:**************
None
while 1:
if __name__ == '__main__':main()
@ranlix
Copy link
Author

ranlix commented May 17, 2013

好的!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment