Projects STRLCPY Osintgram Commits 40cd43d8
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    src/commands/captions/config.yaml
     1 +---
     2 +name: "captions"
     3 +description: "Get target's photos captions"
     4 +commands:
     5 + - run
     6 +options:
     7 + output_limit: 0
     8 + delay: 0
     9 +
  • ■ ■ ■ ■ ■ ■
    src/commands/captions/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 + " captions...\n")
     26 + 
     27 + captions = []
     28 + 
     29 + posts = []
     30 + rank_token = self.osintgram.generate_uuid()
     31 + data = self.osintgram.get_api().user_feed(str(self.osintgram.target_id), rank_token=rank_token)
     32 + posts.extend(data.get('items', []))
     33 + 
     34 + next_max_id = data.get('next_max_id')
     35 + while next_max_id:
     36 + if(int(super().get_option('output_limit')) > 0 and len(posts) > 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 + sys.stdout.write("\rCatched %i posts" % len(posts))
     43 + sys.stdout.flush()
     44 + results = self.osintgram.get_api().user_feed(str(self.osintgram.target_id), max_id=next_max_id, rank_token=rank_token)
     45 + posts.extend(results.get('items', []))
     46 + next_max_id = results.get('next_max_id')
     47 + sys.stdout.write("\rCatched %i posts\n" % len(posts))
     48 + sys.stdout.flush()
     49 +
     50 + counter = 1
     51 + 
     52 + try:
     53 + for item in posts:
     54 + if(int(super().get_option('output_limit')) > 0 and len(captions) > int(super().get_option('output_limit'))):
     55 + break
     56 + 
     57 + if "caption" in item:
     58 + if item["caption"] is not None:
     59 + text = item["caption"]["text"]
     60 + captions.append({
     61 + 'item': counter,
     62 + 'caption': text
     63 + })
     64 + sys.stdout.write("\rFound %i" % counter)
     65 + sys.stdout.flush()
     66 + counter = counter + 1
     67 + 
     68 + except AttributeError:
     69 + pass
     70 + 
     71 + except KeyError:
     72 + pass
     73 + 
     74 + 
     75 + if len(captions):
     76 + pc.printout("\nWoohoo! We found " + str(len(captions)) + " captions\n", pc.GREEN)
     77 + self.status.print_output(captions, ['Caption', 'Text'], ['item', 'caption'])
     78 + 
     79 + else:
     80 + pc.printout("Sorry! No results found :-(\n", pc.RED)
  • ■ ■ ■ ■ ■
    src/setup.yaml
    skipped 5 lines
    6 6   - json
    7 7   
    8 8  commands:
     9 + - captions
    9 10   - comments
    10 11   - exit
    11 12   - followers
    skipped 5 lines
Please wait...
Page is in error, reload to recover