def status(self, json_obj): try: user_id = json_obj['user']['id_str'] for url_info in json_obj['entities']['urls']: url = url_info['expanded_url'] vimeo_id = vimeo_id_from_url(url) if not vimeo_id: print 'No vid link %s' % url continue LINK_COUNT.increment() if UserLinkRecord.has_linked_before(vimeo_id, user_id): print 'multiple links by %s to %s' % (user_id, url) continue timezone = json_obj['user']['time_zone'] lang = json_obj['user']['lang'] text = json_obj['text'] if english_speaking(timezone, lang, text): maybe_fetch_metadata(vimeo_id) HourSet(ENGLISH_LINKS).increment(vimeo_id) maybe_store_tweet(vimeo_id, json_obj) else: HourSet(NON_ENGLISH_LINKS).increment(vimeo_id) except Exception,e : print e
def test_english_speaking(self): self.assertTrue(english_speaking('London', None, None)) self.assertFalse(english_speaking('Paris', None, None))