15
15
from grabber .instagram import InstagramGrabber
16
16
from face_recog import FaceRecog
17
17
import subprocess , json , shutil
18
- from report .report import makeReport
18
+ from report .report import makeReport , makeJSONReport
19
19
20
20
21
21
def presentResult (predictions ):
@@ -43,14 +43,17 @@ def parseInstaUsername(links):
43
43
a = l [8 :]
44
44
a = a .split ('/' )
45
45
if len (a ) >= 2 :
46
- usernames .append (a [1 ])
46
+ if len (a [1 ]) >= 4 :
47
+ usernames .append (a [1 ])
47
48
else :
48
49
console .subfailure ('Error parsing {0}' .format (l ))
49
50
return usernames
50
51
51
52
52
53
def validateInstaUser (username , num_jitters ):
53
54
images = getInstaLinks (username )
55
+ if len (images ) >= cfg .instaLimit ():
56
+ images = images [:cfg .instaLimit ()]
54
57
r = FaceRecog (username , images , num_jitters = num_jitters )
55
58
r .loadKnown (username )
56
59
profile_links , _ = r .getValidLinksAndImg (username )
@@ -60,7 +63,7 @@ def getInstaLinks(username):
60
63
instagrabber = InstagramGrabber (username )
61
64
return instagrabber .getLinks ()
62
65
63
- def main (skipFB = False , skipIR = False , skipY = False , FBUrls = []):
66
+ def main (skipFB = False , skipIR = False , skipY = False , FBUrls = [], jsonRep = None ):
64
67
if not skipFB :
65
68
# collect user input
66
69
console .prompt ('Enter the persons name to find on FB: ' )
@@ -147,6 +150,7 @@ def main(skipFB=False, skipIR=False, skipY=False, FBUrls=[]):
147
150
raider_img_list = profile_imgs
148
151
for v in validatedInstaNames :
149
152
l = getInstaLinks (v )
153
+
150
154
for li in l :
151
155
raider_img_list .append (li )
152
156
@@ -185,16 +189,22 @@ def main(skipFB=False, skipIR=False, skipY=False, FBUrls=[]):
185
189
if len (validatedInstaNames ) > 0 :
186
190
for v in validatedInstaNames :
187
191
l = getInstaLinks (v )
192
+ if len (l ) >= cfg .instaLimit ():
193
+ l = l [:cfg .instaLimit ()]
188
194
for li in l :
189
195
ageEstimator .collectAges (li )
190
196
age = ageEstimator .finish ()
191
197
else :
192
198
console .failure ('No Instagram Images to upload...' )
193
- ageEstimator .finish ()
199
+ # ageEstimator.finish()
194
200
age = "Unknown"
195
201
196
- console .section ("Creating PDF Report" )
197
- makeReport (name , rev_links , predictions , validatedInstaNames , age )
202
+ if jsonRep :
203
+ console .section ("Dumping JSON Report" )
204
+ makeJSONReport (name , rev_links , predictions , validatedInstaNames , age , jsonRep )
205
+ else :
206
+ console .section ("Creating PDF Report" )
207
+ makeReport (name , rev_links , predictions , validatedInstaNames , age )
198
208
199
209
200
210
p = os .path .join (tempfile .gettempdir (), 'imageraider' )
@@ -212,24 +222,33 @@ def main(skipFB=False, skipIR=False, skipY=False, FBUrls=[]):
212
222
parser .add_argument ('-sFB' , '--skipfb' , action = 'store_true' , help = 'Skips the Facebook Search' )
213
223
parser .add_argument ('-sIR' , '--skipir' , action = 'store_true' , help = 'Skips the ImageRaider Reverse Search' )
214
224
#parser.add_argument('-sY', '--skipyandex', action='store_true', help='Skips the Yandex Reverse Search')
225
+ parser .add_argument ('-json' , '--json' , nargs = '?' , help = 'Generates a json report. Specify a Filename' )
215
226
parser .add_argument ('-fbList' ,
216
227
'--facebookList' ,
217
228
nargs = '?' ,
218
229
help = "A file which contains Links to Facebook Profiles. '--skipfb' options must be enabled to use this" )
219
230
args = parser .parse_args ()
220
231
232
+ if args .json :
233
+ jsonRepFile = args .json
234
+ if os .path .isfile (jsonRepFile ):
235
+ console .failure ("File '{}' already exists" .format (jsonRepFile ))
236
+ sys .exit (- 1 )
237
+ else :
238
+ jsonRepFile = None
239
+
221
240
if args .facebookList and args .skipfb :
222
241
if os .path .isfile (args .facebookList ):
223
242
with open (args .facebookList , 'r' ) as f :
224
243
content = f .readlines ()
225
244
content = [x .strip () for x in content ]
226
245
#TODO: fix yandex
227
246
#main(skipFB=args.skipfb, skipIR=args.skipir, skipY=args.skipyandex, FBUrls=content)
228
- main (skipFB = args .skipfb , skipIR = args .skipir , skipY = None , FBUrls = content )
247
+ main (skipFB = args .skipfb , skipIR = args .skipir , skipY = None , FBUrls = content , jsonRep = jsonRepFile )
229
248
else :
230
249
console .failure ("File '{}' does not exist" .format (args .facebookList ))
231
250
sys .exit (- 1 )
232
251
else :
233
252
#TODO: fix yandex
234
253
#main(skipFB=args.skipfb, skipIR=args.skipir, skipY=args.skipyandex, FBUrls=[])
235
- main (skipFB = args .skipfb , skipIR = args .skipir , skipY = None , FBUrls = [])
254
+ main (skipFB = args .skipfb , skipIR = args .skipir , skipY = None , FBUrls = [], jsonRep = jsonRepFile )
0 commit comments