Yading/7digital-python/app.py
Go to the documentation of this file.
1 import pickle
2 from lib.oauth7digital import Oauth7digital
3 
4 
5 TOKEN_FILE = './access_token.pkl'
6 
8  try:
9  pkl_file = open(TOKEN_FILE, 'rb')
10  access_token = pickle.load(pkl_file)
11  pkl_file.close()
12  except:
13  access_token = None
14  if access_token:
15  print 'You have an access token: %s' % str(access_token.key)
16  else:
17  auth = Oauth7digital(CONSUMER_KEY, CONSUMER_SECRET)
18 
19  token = auth.request_token()
20  authorized = auth.authorize_request_token(token)
21  access_token = auth.request_access_token(token)
22 
23  pkl_file=open(TOKEN_FILE, 'wb')
24  pickle.dump(access_token, pkl_file)
25  pkl_file.close()
26 
27  return access_token
28 
29 def test_locker():
30  access_token = test_sevendigital()
31 
32  sevendigital = Oauth7digital(CONSUMER_KEY, CONSUMER_SECRET, access_token)
33  results = sevendigital.get_locker()
34  for i in results:
35  print "-----------------------------"
36  print i.release.title
37  print i.release.artist.name
38  for a in i.tracks:
39  print a.track.title
40  return results
41 
42 # app entry point
43 if __name__ == '__main__':
44  test_locker()
45  print 'Done.'
46 
47 
48