def handle(self, *args, **options): if len(args) == 0: return screen_name = args[0] api = get_api() print "Crowl statuses by @%s." % screen_name for p in tweepy.Cursor(api.user_timeline, screen_name=screen_name).items(): status = Status.create_from_status(p) print status
def create_from_id(cls, id): api = get_api() try: return cls.objects.get(id_str=id) except cls.DoesNotExist: pass try: status = api.get_status(id=id) return cls.create_from_status(status) except tweepy.error.TweepError as e: print >> sys.stderr , e if u"limit" in unicode(e).lower(): raise return None
def create_from_id(cls, id_str): try: instance = cls.objects.get(id_str=id_str) return instance except cls.DoesNotExist: instance = cls(id_str=id_str) api = get_api() user = api.get_user(user_id=id_str) instance.created_at = user.created_at instance.screen_name = user.screen_name instance.name = user.name instance.url = user.url or u"" instance.description = user.description or u"" instance.profile_image_url = user.profile_image_url or u"" instance.save() return instance