import argparse from time import sleep import config from db import HumanKind from facebook import FacebookAPI from nl import LanguageIdentifier from tinder import TinderAPI def connect(): """Establish a connection to Facebook/Tinder.""" fb = FacebookAPI(config.facebook_email, config.facebook_password) fb_id = fb.get_user_id() print('[i] Facebook ID: ' + fb_id) fb_token = fb.get_tinder_token() print('[i] Tinder token: ' + fb_token) tinder = TinderAPI(fb_id, fb_token) print('[i] Tinder auth token: ' + tinder.get_auth_token()) print('[i] Remaining likes: %d' % tinder.get_remaining_likes()) wait = tinder.can_like_in() if wait == 0: print('[i] Time to like!') else: print('[i] We have to wait %d minute%s before liking...' % (wait, 's' if wait > 1 else '')) return tinder if __name__=='__main__': parser = argparse.ArgumentParser() parser.add_argument('-g', '--grab', help='Grab profiles from Tinder', action='store_true') parser.add_argument('-p', '--process', help='Process stored Tinder profiles', action='store_true') parser.add_argument('--dump-new', help='Extract newly stored Tinder profiles', action='store_true') parser.add_argument('--dump-all', help='Extract all stored Tinder profiles', action='store_true') parser.add_argument('-s', '--superlike', help='Superlike a given Tinder profile using its ID', type=str) args = parser.parse_args() db = HumanKind() if args.grab: tinder = connect() extra = 0 while True: profiles = tinder.get_recommendations(1) new = 0 for p in profiles: if not(db.has_profile_id(p)): new += 1 print(p) db.store_profile(p) if new == 0: print('[!] No new profiles to grab! Exiting...') break extra += new print('[i] Loaded ' + config.COLOR_LIKE + '%d' % extra + config.COLOR_RESET \ + ' new profile%s... Taking some rest now!' % ('s' if extra > 2 else '')) sleep(20) elif args.process: tinder = connect() lid = LanguageIdentifier() profiles = db.load_unknown_profiles() remaining = tinder.get_remaining_likes() for p in profiles: like = True age = p.compute_age() if not(age is None): if age < config.MIN_AGE or age > config.MAX_AGE: like = False if p._distance_mi > config.MAX_DISTANCE_IN_MI: like = False if like and not(p._bio is None): language = lid.detect_language(p._bio) like = (language == config.TARGET_LANGUAGE) if like and not(p._job_title is None): text = p._job_title.lower() for kwd in config.BLACK_LIST_KEYWORDS: if kwd in text: like = False break if like and not(p._bio is None): text = p._bio.lower() for kwd in config.BLACK_LIST_KEYWORDS: if kwd in text: like = False break if like: remaining -= 1 tinder.like(p._id) db.mark_profile_as_liked(p) print('[%02d] %s: ' % (remaining, p._name) + config.COLOR_LIKE + 'like!' + config.COLOR_RESET) if remaining == 0: print('[!] No more likes available. Exiting...') break else: print('[**] %s: ' % p._name + config.COLOR_PASS + 'pass' + config.COLOR_RESET) tinder.dislike(p._id) db.mark_profile_as_passed(p) sleep(5) elif args.dump_new: profiles = db.load_new_profiles() for p in profiles: print('[i] Extracting information about %s (id=%s)...' % (p._name, p._id)) p.output() db.mark_profile_as_extracted(p) elif args.dump_all: profiles = db.load_all_profiles() for p in profiles: print('[i] Extracting information about %s (id=%s)...' % (p._name, p._id)) p.output() db.mark_profile_as_extracted(p) elif args.superlike: tinder = connect() uid = args.superlike profile = db.load_profile(uid) tinder.superlike(uid) if profile: db.mark_profile_as_superliked(profile) print('[*] %s: ' % profile._name + config.COLOR_LIKE + 'superlike!' + config.COLOR_RESET) else: print('[*] ' + config.COLOR_LIKE + 'Superliked' + config.COLOR_RESET + ' ' + uid)