■ ■ ■ ■ ■ ■
src/commands/followers/run.py
| skipped 8 lines |
9 | 9 | | import sys |
10 | 10 | | import time |
11 | 11 | | |
12 | | - | from src import CommandFather as CommandFather |
| 12 | + | from src.CommandFather import CommandFather |
13 | 13 | | |
14 | 14 | | |
15 | | - | class Command(): |
| 15 | + | class Command(CommandFather): |
16 | 16 | | |
17 | 17 | | def __init__(self, status, api): |
18 | | - | # super().__init__(status, api) |
19 | | - | self.commands = [] |
20 | | - | self.path = status.get_path() |
| 18 | + | super().__init__(status) |
21 | 19 | | self.status = status |
22 | | - | stream = open(self.path, 'r') |
23 | | - | self.config = yaml.safe_load(stream) |
24 | | - | self.options_values = self.config['options'] |
| 20 | + | stream = open(status.get_path(), 'r') |
25 | 21 | | self.osintgram = api |
26 | 22 | | |
27 | | - | def get_options(self): |
28 | | - | return self.config['options'] |
29 | | - | |
30 | | - | def options(self): |
31 | | - | t = PrettyTable(['Option', 'Value']) |
32 | | - | for key, value in self.options_values.items(): |
33 | | - | t.add_row([key, str(value)]) |
34 | | - | print(t) |
35 | | - | |
36 | | - | def set(self): |
37 | | - | i = 1 |
38 | | - | for key, value in self.options_values.items(): |
39 | | - | print(str(i) + ". " + key) |
40 | | - | i = i + 1 |
41 | | - | try: |
42 | | - | index = input("Choose option: ") |
43 | | - | key = list(self.options_values.keys())[int(index) - 1] |
44 | | - | v = input("[" + key + "] Choose a value: ") |
45 | | - | self.options_values[key] = v |
46 | | - | print(self.options_values) |
47 | | - | |
48 | | - | except ValueError: |
49 | | - | utils.print_error("Not a number") |
50 | | - | |
51 | | - | except IndexError: |
52 | | - | utils.print_error("Value not in range (1-" + str(i-1) + ")") |
53 | | - | |
54 | 23 | | def run(self): |
55 | 24 | | if self.osintgram.check_private_profile(): |
56 | 25 | | return |
| skipped 9 lines |
66 | 35 | | |
67 | 36 | | next_max_id = data.get('next_max_id') |
68 | 37 | | while next_max_id: |
69 | | - | if(int(self.options_values['output_limit']) > 0 and len(followers) > int(self.options_values['output_limit'])): |
| 38 | + | if(int(super().get_option('output_limit')) > 0 and len(followers) > int(super().get_option('output_limit'))): |
70 | 39 | | break |
71 | 40 | | |
72 | | - | if(int(self.options_values['delay']) > 0): |
73 | | - | time.sleep(int(self.options_values['delay'])) |
| 41 | + | if(int(super().get_option('delay')) > 0): |
| 42 | + | time.sleep(int(super().get_option('delay'))) |
74 | 43 | | |
75 | 44 | | sys.stdout.write("\rCatched %i followers" % len(followers)) |
76 | 45 | | sys.stdout.flush() |
77 | 46 | | results = self.osintgram.get_api().user_followers(str(self.osintgram.target_id), rank_token=rank_token, max_id=next_max_id) |
78 | 47 | | followers.extend(results.get('users', [])) |
79 | 48 | | next_max_id = results.get('next_max_id') |
80 | | - | sys.stdout.write("\rCatched %i followers" % len(followers)) |
| 49 | + | sys.stdout.write("\rCatched %i followers\n" % len(followers)) |
81 | 50 | | sys.stdout.flush() |
82 | 51 | | |
83 | 52 | | data = [] |
| skipped 5 lines |
89 | 58 | | } |
90 | 59 | | data.append(u) |
91 | 60 | | |
92 | | - | # utils.print_in_table(data, ['ID', 'Username', 'Full Name'], ['id', 'username', 'full_name']) |
93 | 61 | | self.status.print_output(data, ['ID', 'Username', 'Full Name'], ['id', 'username', 'full_name']) |
94 | 62 | | |