-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSearch.py
More file actions
executable file
·104 lines (84 loc) · 2.75 KB
/
Search.py
File metadata and controls
executable file
·104 lines (84 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 2 12:39:14 2020
@author: aditya
"""
from FlagsNArgs import look_for_arguments, look_for_flags
from Search_scrape import search_scrape
from scrap import search_game
from Game import Game
def Search(inp):
flag_list = set_search_flags((look_for_flags(inp)))
name = look_for_arguments(inp)
ans = crackninjaSearch(name,0,flag_list[0],flag_list[1],flag_list[2],flag_list[3],flag_list[4],flag_list[5])
if(ans == 1):
return 1
ans.printdetails()
return 1
def set_search_flags(flags):
flags_of_search = ["a","i","c","n","r","u"]
num_flags_of_search = 6
flag_list = [True,True,True,True,True,True]
flagset_list = [False,False,False,False,False,False]
for f in flags:
#print(f)
for i in range (num_flags_of_search):
if (f == flags_of_search[i]):
if (i%2 ==0):
flag_list[i] = True
flagset_list[i] = True
flag_list[i+1] = not(flagset_list[i] ^ flagset_list[i+1])
else:
flag_list[i] = True
flagset_list[i] = True
flag_list[i-1] = not(flagset_list[i] ^ flagset_list[i-1])
return flag_list
def crackninjaSearch(name,number =10,is_aaa = True, is_indie =True, is_cracked = True, is_notcracked = True, is_released = True, is_unreleased = True ):
#yaha pe pura scrapping vagera call hoga
if(is_aaa and is_indie):
gtype = 0
elif(is_aaa):
gtype = 1
elif(is_indie):
gtype = 2
if(is_cracked and is_notcracked):
gstatus = 0
elif(is_cracked):
gstatus = 1
elif(is_notcracked):
gstatus = 2
if(is_released and is_unreleased):
grel_d = 0
elif(is_released):
grel_d = 1
elif(is_unreleased):
grel_d = 2
ans = search_scrape(name,gstatus,grel_d,gtype)
if(ans == 1):
print("Failed to find the game")
return 1
display = {}
i = 1
for a in ans.keys():
display[i] = a
i = i+1
print("\n","---------RESULT--------")
for dk, dv in display.items():
print(dk,"-->",dv)
print("\n"," Choose the index of the Game you want OR 0 to go back: ")
valid = 0
while(not valid):
choice = input(" >>")
if(choice.isnumeric()):
if(int(choice) >= 0 and int(choice) < i):
valid = 1
else:
print(" Sorry, Please make a VALID choice !")
else:
print(" Sorry, Please make a VALID choice !")
if(int(choice) == 0):
return 1
link = ans[display[int(choice)]]
game_res = search_game(link)
return game_res