Пример #1
0
def friend(request):
	from twirem.crawler import UserInfoRequester
	from twirem.crawler.db_update import update_friends, users_noactivity, update_screen_names
	u"""
	フレンド更新
	"""
	try :
		auth = auth_util.get_auth(request)
		api = auth_util.create_api(auth = auth)
		requester = UserInfoRequester(api)

		new_friends = requester.request_friend_ids(auth.user_id)
		update_friends(auth.user_id, new_friends)

		users = [str(user.user_id) for user 
				in users_noactivity(auth.user_id) if user.activity == 0]
		update_users = sorted(requester.lookup(users),
				cmp = lambda a,b:cmp(a['id'], b['id']))
		update_screen_names(update_users)

		friends = UserFriend.objects.filter()

		#ids = FollowerIds(api, user_id = auth.user_id)
		#users = FollowerUsers(api, user_id = auth.user_id)
		#values = {'user' : auth, 'ids' : ids, 'users' : users}
		values = {'user' : auth, 'friends' : friends}
		return render_to_response(
				'main/member.html',
				values,
				RequestContext(request))
	except auth_util.NotLogonError :
		return render_to_response('main/top.html')
Пример #2
0
	def crawl_user(self, user):
		"""
		ユーザを中心とした各情報をクロールする
		"""
		auth = user.authorization
		api = auth_util.create_api(auth = auth)
		requester = UserInfoRequester(api)

		self.update_followers(user, requester)
		self.update_friends(user, requester)
		self.update_bios(user, requester)

		user.update_date = time.time()
		user.save()
		user.followers_activity.update_date = 0
		user.friends_activity.update_date = 0
		user.bios_activity.update_date = 0

		user.followers_activity.save()
		user.friends_activity.save()
		user.bios_activity.save()