Beispiel #1
0
 def videos(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 25):
     my_videos_q = "SELECT vid FROM video WHERE owner = me() and created_time < " + str(untill) + "and created_time > " + str(since)
     tagged_videos_q = "SELECT vid FROM video_tag WHERE subject = me() and created_time < " + str(untill) + "and created_time > " + str(since)
     my_videos = self.fql(my_videos_q)
     tagged_videos = self.fql(tagged_videos_q)
     all_video = my_videos + tagged_videos
     return Pool(processes=5).map_async(partial(make_object, Video, self), [str(video["vid"]) for video in all_video])
Beispiel #2
0
 def analyze_thread(self, thread_id, since = int(back_dates(time.time(), days = 30)), untill = int(time.time())):
     query = "SELECT body, author_id, attachment, created_time FROM message WHERE thread_id = " + str(thread_id) + " and created_time > " + str(since) + " and created_time < " + str(untill) + " ORDER BY created_time DESC"
     messages = self.fql(query)
     print query
     if len(messages) >= 20:
         self._get_more_message(messages, thread_id, since, untill)
     return messages
Beispiel #3
0
 def get_message_new(self,  since = int(back_dates(time.time(), days = 10)), untill = int(time.time())):
     messages = self.fb.request(str(self.id))
     prova.i += 1
     messages["author"] = get_user(self.fb, messages["from"]["id"])
     messages["to"] = [get_user(self.fb, user["id"]) for user in messages["to"]["data"]]
     if "comments" in messages:
         for m in messages["comments"]["data"]:
             m["author"] = get_user(self.fb, m["from"]["id"])
         while time.mktime(time.strptime(messages["comments"]["data"][-1]["created_time"], "%Y-%m-%dT%H:%M:%S+0000")) > since:
             time.sleep(0.5)
             to_add = simple_request(messages["comments"]["paging"]["next"])
             prova.i += 1
             for m in to_add["data"]:
                 m["author"] = get_user(self.fb, m["from"]["id"])
             messages["comments"]["data"].extend(to_add["data"])
             if "paging" in to_add:
                 messages["comments"]["paging"] = to_add["paging"]
             else:
                 self.update(messages)
                 return
             print "\n"*5
             print to_add
             print "\n"*5
             print messages
             print prova.i
     else:
         messages["comments"] = []
         #self.update(messages)
         #return
     self.update(messages)
     return
Beispiel #4
0
 def get_statuses(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), fields = ["id"], limit = 25):
     statuses = self.request("me/statuses", args = {"fields" : fields,
                                                    "since" : since,
                                                    "untill" : untill,
                                                    "limit" :limit,})["data"]
     for state in statuses:
         state.update({"type" : "statuses", "created_time" : state["updated_time"]})
     return statuses
Beispiel #5
0
 def photos(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 25):
     my_photo_query = "SELECT object_id FROM photo WHERE owner = me() and created < " + str(untill) + "and created > " + str(since)
     tagged_p_query = "SELECT object_id FROM photo_tag WHERE subject = me() and created < " + str(untill) + "and created > " + str(since)
     my_photo = self.fql(my_photo_query)
     tagged_p = self.fql(tagged_p_query)
     all_photo = my_photo + tagged_p
     #return Pool(processes=5).map_async(partial(make_object, Photo, self), [str(photo["object_id"]) for photo in all_photo])
     return [Photo(self, str(photo["object_id"])) for photo in all_photo]
Beispiel #6
0
 def get_data(self,  since = int(back_dates(time.time(), days = 30)), untill = int(time.time())):
     query = "SELECT body, author_id, attachment, created_time FROM message WHERE thread_id = " + str(self.id) + " and created_time > " + str(since) + " and created_time < " + str(untill) + " ORDER BY created_time DESC"
     messages = self.fb.fql(query)
     print len(messages), query
     if len(messages) >= 10:
         self._get_more_message(messages, since, untill)
     self["comments"] = messages
     return messages
Beispiel #7
0
 def get_message(self,  since = int(back_dates(time.time(), days = 10)), untill = int(time.time())):
     query = "SELECT body, author_id, attachment, created_time FROM message WHERE thread_id = " + str(self.id) + " and created_time > " + str(since) + " and created_time < " + str(untill) + " ORDER BY created_time ASC"
     messages = self.fb.fql(query)
     for message in messages:
         message["author"] = get_user(self.fb, message["author_id"])
     if len(messages) >= 20:
         self._get_more_message(messages, since, untill)
     self["comments"] = messages
     return messages
Beispiel #8
0
 def posts(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 1000):
     posts = self.request("me/posts", args = {"untill" : untill,
                                              "since" : since,
                                              "limit" : limit,
                                              "fields" : ["id", "type", "object_id"]})["data"]
     def make_real(post):
         if "object_id" in post:
             return Post(self.copy(), str(post["object_id"]), post["type"]).get_real()
         return Post(self.copy(), str(post["id"]), post["type"]).get_real()
     return [make_real(post) for post in posts]
Beispiel #9
0
 def get_posts_id(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), fields=[], limit = 250, to_filter=True):
     fields = fields + ["id", "type"]
     posts = self.request("me/posts", args = {"untill" : untill,
                                              "since" : since,
                                              "limit" : limit,
                                              "fields" : fields})
     
     if to_filter:
         return [x for x in posts["data"] if self.filter_status(x)]
     else:
         return posts["data"]
Beispiel #10
0
 def get_status_you_likes(self, ids, since=int(back_dates(time.time(), days = 30)), untill=int(time.time())):
     to_query = str(ids)
     to_query = list(to_query)
     to_query[0] = "("
     to_query[-1] = ")"
     to_query = "".join(to_query)
     status = self.fql("select status_id from status where status_id in " + to_query + "and time < " + str(untill) + " and time > " + str(since))
     for x in status:
         x["id"] = str(x["status_id"])
         x["type"] = "status_like"
     return status
Beispiel #11
0
 def likes(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 25):
     object_types = {"post" : Status, "link" : Link, "video" : Video, "status" : Status, "photo" : Photo, "album" : Album, "wallpost" : Status}
     likes_query = "select object_id, object_type from like where user_id = me()"
     likes = self.fql(likes_query)
     def f(l):
         print l
         try:
             return object_types[l["object_type"]](self.copy(), l["object_id"])
         except:
             return 
     likes = [f(l) for l in likes]
     return likes
Beispiel #12
0
 def links(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 25):
     links_query = "SELECT link_id FROM link WHERE owner = me() and created_time < " + str(untill) + "and created_time > " + str(since)
     links = self.fql(links_query)
     #return [spawn(partial(make_object, Link, self), str(link["link_id"])) for link in links]
     #return Pool(processes=5).map_async(partial(make_object, Link, self), [str(link["link_id"]) for link in links])
     return [Link(self, str(link["link_id"])) for link in links]
Beispiel #13
0
 def status(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 25):
     status_query = "SELECT status_id FROM status WHERE uid = me() and time < " + str(untill) + " and time > " + str(since)
     status = self.fql(status_query)
     #return Pool(processes=5).map_async(partial(make_object, Status, self), [str(statu["status_id"]) for statu in status])
     return [Status(self, str(statu["status_id"])) for statu in status]
Beispiel #14
0
 def threads(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 25):
     threads_query = "SELECT thread_id, updated_time FROM thread WHERE folder_id = 0 OR folder_id = 1 OR folder_id = 2 OR folder_id = 3 OR folder_id = 4 AND updated_time < " + str(untill) + "and updated_time > " + str(since)
     threads = self.fql(threads_query)
     #return Pool(processes=5).map_async(partial(make_object, Fb_Thread, self), [str(thread["thread_id"]) for thread in threads])
     return [Fb_Thread(self, str(thread["thread_id"]), thread) for thread in threads]
Beispiel #15
0
 def get_threads_id(self, since = int(back_dates(time.time(), days = 30)), untill = int(time.time())):
     ids = self.fql("SELECT thread_id FROM thread WHERE (folder_id = 0 or folder_id = 1 or folder_id = 4 or folder_id = 3) and updated_time < " + str(untill) + " and updated_time > " + str(since))        
     total_id = set([x['thread_id'] for x in ids])
     return total_id
Beispiel #16
0
 def new_friends(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 1000):
     from friendship import Friendship
     posts = self.request("me/posts", args = {"untill" : untill,
                                              "since" : since,
                                              "limit" : limit,
                                              "fields" : ["id", "status_type"]})["data"]
Beispiel #17
0
 def albums(self, since=int(back_dates(time.time(), days = 30)), untill=int(time.time()), limit = 25):
     albums_query = "SELECT object_id FROM album WHERE owner = me() and created < " + str(untill) + "and created > " + str(since)
     albums = self.fql(albums_query)
     #return Pool(processes=5).map_async(partial(make_object, Album, self), [str(album["object_id"]) for album in albums])
     return [Album(self, str(album["object_id"])) for album in albums]