Projects STRLCPY Osintgram Commits 62b9b17b
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    src/commands/fwersubset/config.yaml
     1 +---
     2 +name: "fwersubset"
     3 +description: "Get the list of users who follow both target1 and target2"
     4 +commands:
     5 + - run
     6 +options:
     7 + output_limit: 0
     8 + delay: 0
     9 +
  • ■ ■ ■ ■ ■ ■
    src/commands/fwersubset/run.py
     1 +import yaml
     2 +import readline
     3 +import signal
     4 +from prettytable import PrettyTable
     5 +from src import printcolors as pc
     6 +from src import utils as utils
     7 +import json
     8 +import sys
     9 +import time
     10 + 
     11 +from src.CommandFather import CommandFather
     12 + 
     13 + 
     14 +class Command(CommandFather):
     15 + 
     16 + def __init__(self, status, api):
     17 + super().__init__(status)
     18 + self.status = status
     19 + self.osintgram = api
     20 + 
     21 + def run(self):
     22 + if self.osintgram.check_private_profile():
     23 + return
     24 + 
     25 + pc.printout("Searching for " + self.osintgram.target + " followers...\n")
     26 + 
     27 + target_1 = self.osintgram.target
     28 + _followers_target_1 = []
     29 + _followers_target_2 = []
     30 + followers_subset = []
     31 + 
     32 + rank_token = self.osintgram.generate_uuid()
     33 + data = self.osintgram.get_api().user_followers(str(self.osintgram.target_id), rank_token=rank_token)
     34 + 
     35 + _followers_target_1.extend(data.get('users', []))
     36 + 
     37 + next_max_id = data.get('next_max_id')
     38 + while next_max_id:
     39 + if(int(super().get_option('output_limit')) > 0 and len(_followers_target_1) > int(super().get_option('output_limit'))):
     40 + break
     41 + 
     42 + if(int(super().get_option('delay')) > 0):
     43 + time.sleep(int(super().get_option('delay')))
     44 + 
     45 + sys.stdout.write("\rCatched %i followers" % len(_followers_target_1))
     46 + sys.stdout.flush()
     47 + results = self.osintgram.get_api().user_followers(str(self.osintgram.target_id), rank_token=rank_token, max_id=next_max_id)
     48 + _followers_target_1.extend(results.get('users', []))
     49 + next_max_id = results.get('next_max_id')
     50 + sys.stdout.write("\rCatched %i followers\n" % len(_followers_target_1))
     51 + sys.stdout.flush()
     52 + 
     53 + print("\n")
     54 + 
     55 + pc.printout("Insert target two username: ", pc.YELLOW)
     56 + line = input()
     57 + self.osintgram.setTarget(line, False)
     58 + target_2 = self.osintgram.target
     59 + if self.osintgram.check_private_profile():
     60 + return
     61 + 
     62 + 
     63 + pc.printout("Searching for " + self.osintgram.target + " followers...\n")
     64 + 
     65 + rank_token = self.osintgram.generate_uuid()
     66 + data = self.osintgram.get_api().user_following(str(self.osintgram.target_id), rank_token=rank_token)
     67 + 
     68 + _followers_target_2.extend(data.get('users', []))
     69 + 
     70 + next_max_id = data.get('next_max_id')
     71 + while next_max_id:
     72 + if(int(super().get_option('output_limit')) > 0 and len(_followers_target_2) > int(super().get_option('output_limit'))):
     73 + break
     74 + 
     75 + if(int(super().get_option('delay')) > 0):
     76 + time.sleep(int(super().get_option('delay')))
     77 + 
     78 + sys.stdout.write("\rCatched %i followers" % len(_followers_target_2))
     79 + sys.stdout.flush()
     80 + results = self.osintgram.get_api().user_following(str(self.osintgram.target_id), rank_token=rank_token, max_id=next_max_id)
     81 + _followers_target_2.extend(results.get('users', []))
     82 + next_max_id = results.get('next_max_id')
     83 + sys.stdout.write("\rCatched %i followers\n" % len(_followers_target_2))
     84 + sys.stdout.flush()
     85 + 
     86 + print("\n")
     87 +
     88 + for user in _followers_target_1:
     89 + ff = list(filter(lambda x: x['pk'] == user['pk'], _followers_target_2))
     90 + if(len(ff) > 0):
     91 + f = {
     92 + 'id': ff[0]['pk'],
     93 + 'username': ff[0]['username'],
     94 + 'full_name': ff[0]['full_name']
     95 + }
     96 + followers_subset.append(f)
     97 + 
     98 + t = PrettyTable(['ID', 'Username', 'Full Name'])
     99 + t.align["ID"] = "l"
     100 + t.align["Username"] = "l"
     101 + t.align["Full Name"] = "l"
     102 + 
     103 + json_data = {}
     104 + followers_subset_list = []
     105 + 
     106 + for node in followers_subset:
     107 + if(int(super().get_option('output_limit')) > 0 and len(followers_subset_list) > int(super().get_option('output_limit'))):
     108 + break
     109 + follow = {
     110 + 'id': node['id'],
     111 + 'username': node['username'],
     112 + 'full_name': node['full_name']
     113 + }
     114 + followers_subset_list.append(follow)
     115 + 
     116 + self.status.print_output(followers_subset_list, ['ID', 'Username', 'Full Name'], ['id', 'username', 'full_name'])
     117 + 
     118 + pc.printout("Founded " + str(len(followers_subset)) + " users!\n", pc.GREEN)
  • ■ ■ ■ ■ ■
    src/setup.yaml
    skipped 11 lines
    12 12   - exit
    13 13   - followers
    14 14   - followings
     15 + - fwersubset
    15 16   - fwingsubset
    16 17   - hashtags
    17 18   - help
    skipped 9 lines
Please wait...
Page is in error, reload to recover