Projects STRLCPY Osintgram Commits 75fb211b
🤬
  • feat.: added total likes and comments command

  • Loading...
  • Datalux committed 3 years ago
    75fb211b
    1 parent 69908e57
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    src/commands/totalcomments/config.yaml
     1 +---
     2 +name: "totalcomments"
     3 +description: "Get total comments of target's posts"
     4 +commands:
     5 + - run
     6 +options:
     7 + output_limit: 0
     8 + delay: 0
     9 +
  • ■ ■ ■ ■ ■ ■
    src/commands/totalcomments/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 + " total comments...\n")
     26 + 
     27 + comment_counter = 0
     28 + posts = 0
     29 + 
     30 + data = []
     31 + result = self.osintgram.get_api().user_feed(str(self.osintgram.target_id))
     32 + data.extend(result.get('items', []))
     33 + 
     34 + next_max_id = result.get('next_max_id')
     35 + while next_max_id:
     36 + if(int(super().get_option('output_limit')) > 0 and len(data) > int(super().get_option('output_limit'))):
     37 + break
     38 + 
     39 + if(int(super().get_option('delay')) > 0):
     40 + time.sleep(int(super().get_option('delay')))
     41 + 
     42 + results = self.osintgram.get_api().user_feed(str(self.osintgram.target_id), max_id=next_max_id)
     43 + data.extend(results.get('items', []))
     44 + next_max_id = results.get('next_max_id')
     45 + 
     46 + for post in data:
     47 + if(int(super().get_option('output_limit')) > 0 and posts == int(super().get_option('output_limit'))):
     48 + break
     49 +
     50 + comment_counter += post['comment_count']
     51 + posts += 1
     52 + 
     53 + output = {
     54 + 'comment_counter': comment_counter,
     55 + 'posts': posts
     56 + }
     57 + 
     58 + self.status.print_output([output], ['Comments', 'Posts'], ['comment_counter', 'posts'])
  • ■ ■ ■ ■ ■ ■
    src/commands/totalikes/config.yaml
     1 +---
     2 +name: "totalikes"
     3 +description: "Get total likes of target's posts"
     4 +commands:
     5 + - run
     6 +options:
     7 + output_limit: 0
     8 + delay: 0
     9 +
  • ■ ■ ■ ■ ■ ■
    src/commands/totalikes/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 + " total likes...\n")
     26 + 
     27 + like_counter = 0
     28 + posts = 0
     29 + 
     30 + data = []
     31 + result = self.osintgram.get_api().user_feed(str(self.osintgram.target_id))
     32 + data.extend(result.get('items', []))
     33 + 
     34 + next_max_id = result.get('next_max_id')
     35 + while next_max_id:
     36 + if(int(super().get_option('output_limit')) > 0 and len(data) > int(super().get_option('output_limit'))):
     37 + break
     38 + 
     39 + if(int(super().get_option('delay')) > 0):
     40 + time.sleep(int(super().get_option('delay')))
     41 + 
     42 + results = self.osintgram.get_api().user_feed(str(self.osintgram.target_id), max_id=next_max_id)
     43 + data.extend(results.get('items', []))
     44 + next_max_id = results.get('next_max_id')
     45 + 
     46 + for post in data:
     47 + if(int(super().get_option('output_limit')) > 0 and posts == int(super().get_option('output_limit'))):
     48 + break
     49 +
     50 + like_counter += post['like_count']
     51 + posts += 1
     52 + 
     53 + output = {
     54 + 'like_counter': like_counter,
     55 + 'posts': posts
     56 + }
     57 + 
     58 + self.status.print_output([output], ['Likes', 'Posts'], ['like_counter', 'posts'])
  • ■ ■ ■ ■ ■ ■
    src/setup.yaml
    skipped 15 lines
    16 16   - info
    17 17   - photos
    18 18   - propic
     19 + - totalcomments
     20 + - totalikes
  • ■ ■ ■ ■ ■
    src/utils.py
    skipped 29 lines
    30 30   t = PrettyTable(header)
    31 31   for i in header:
    32 32   t.align[i] = "l"
    33  - 
    34 33   for d in data:
    35 34   t.add_row([d[i] for i in values])
    36 35   
    skipped 56 lines
Please wait...
Page is in error, reload to recover