Projects STRLCPY Osintgram Commits 31d6e66f
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    src/commands/mediatype/config.yaml
     1 +---
     2 +name: "mediatype"
     3 +description: "Get target's posts type (photo or video)"
     4 +commands:
     5 + - run
     6 +options:
     7 + output_limit: 0
     8 + delay: 0
  • ■ ■ ■ ■ ■ ■
    src/commands/mediatype/run.py
     1 +from prettytable import PrettyTable
     2 +from src import printcolors as pc
     3 +import sys
     4 +import time
     5 +import urllib
     6 +import os
     7 + 
     8 + 
     9 +from src.CommandFather import CommandFather
     10 + 
     11 + 
     12 +class Command(CommandFather):
     13 + 
     14 + def __init__(self, status, api):
     15 + super().__init__(status)
     16 + self.status = status
     17 + self.osintgram = api
     18 + 
     19 + def run(self):
     20 + if self.osintgram.check_private_profile():
     21 + return
     22 + 
     23 + pc.printout("Searching for " + self.osintgram.target + " captions...\n")
     24 + 
     25 + counter = 0
     26 + photo_counter = 0
     27 + video_counter = 0
     28 + 
     29 + data = []
     30 + result = self.osintgram.get_api().user_feed(str(self.osintgram.target_id))
     31 + data.extend(result.get('items', []))
     32 + 
     33 + next_max_id = result.get('next_max_id')
     34 + while next_max_id:
     35 + if(int(super().get_option('output_limit')) > 0 and len(data) > int(super().get_option('output_limit'))):
     36 + break
     37 + 
     38 + if(int(super().get_option('delay')) > 0):
     39 + time.sleep(int(super().get_option('delay')))
     40 + 
     41 + results = self.osintgram.get_api().user_feed(str(self.osintgram.target_id), max_id=next_max_id)
     42 + data.extend(results.get('items', []))
     43 + next_max_id = results.get('next_max_id')
     44 + 
     45 + for post in data:
     46 + if "media_type" in post:
     47 + if post["media_type"] == 1:
     48 + photo_counter = photo_counter + 1
     49 + elif post["media_type"] == 2:
     50 + video_counter = video_counter + 1
     51 + elif post["media_type"] == 8: # it's a carousel
     52 + for c in post['carousel_media']:
     53 + if c["media_type"] == 1:
     54 + photo_counter = photo_counter + 1
     55 + elif c["media_type"] == 2:
     56 + video_counter = video_counter + 1
     57 + counter = counter + 1
     58 + counter = counter + 1
     59 + 
     60 + if counter > 0:
     61 + data = {
     62 + "photos": photo_counter,
     63 + "videos": video_counter
     64 + }
     65 + 
     66 + self.status.print_output([data], ['Photos', 'Videos'], ['photos', 'videos'])
     67 + 
     68 + else:
     69 + pc.printout("Sorry! No results found :-(\n", pc.RED)
  • ■ ■ ■ ■ ■
    src/setup.yaml
    skipped 13 lines
    14 14   - hashtags
    15 15   - help
    16 16   - info
     17 + - mediatype
    17 18   - photos
    18 19   - propic
    19 20   - totalcomments
    skipped 3 lines
Please wait...
Page is in error, reload to recover