/
__init__.py
323 lines (230 loc) · 10.3 KB
/
__init__.py
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#
# py-google-search Copyright (C) 2018 Javinator9889
# This program comes with ABSOLUTELY NO WARRANTY; for details add the "-h" option.
# This is free software, and you are welcome to redistribute it
# under certain conditions; type "-L" for details.
#
from pyGle.url.url_constants import __google_url_modifiers__
from .AvailableCountries import AvailableCountries
from .AvailableLanguages import AvailableLanguages
from .OptionsForPatents import *
from .OptionsForPictures import *
class TimeLimit:
def __init__(self):
self.__time_limit = None
self.__times = __google_url_modifiers__["with_time_limitation_for"]
def setDay(self):
self.__time_limit = self.__times["day"]
def setWeek(self):
self.__time_limit = self.__times["week"]
def setMonth(self):
self.__time_limit = self.__times["month"]
def setYear(self):
self.__time_limit = self.__times["year"]
def setMonths(self, time: int):
if time <= 0:
raise ValueError("Time must be greater than '0'")
else:
self.__time_limit = self.__times["month"] + str(time)
def getTimeLimit(self):
# type: () -> str
return self.__time_limit
class Rights:
def __init__(self):
self.__rights = None
self.__available_rights = __google_url_modifiers__["with_rights_types"]
def setFreeToUse(self):
self.__rights = self.__available_rights["free_to_use"]
def setFreeToUseCommerciallyAlso(self):
self.__rights = self.__available_rights["free_to_use_com"]
def setFreeToUseAndModify(self):
self.__rights = self.__available_rights["free_to_use_and_modify"]
def setFreeToUseAndModifyCommerciallyAlso(self):
self.__rights = self.__available_rights["free_to_use_and_modify_com"]
def getRights(self):
# type: () -> str
return self.__rights
class Languages:
def __init__(self):
self.__lang = None
self.__available_lang = __google_url_modifiers__["with_languages"]
def show_languages(self):
for key, value in self.__available_lang.items():
print(key)
def setLanguage(self, language: AvailableLanguages):
self.__lang = language
def getLanguage(self):
# type: () -> str
return self.__lang
class Countries:
def __init__(self):
self.__country = None
self.__available_countries = __google_url_modifiers__["with_countries"]
def show_countries(self):
for key, values in self.__available_countries.items():
print(key)
def setCountry(self, country: AvailableCountries):
self.__country = country
def getCountry(self):
# type: () -> str
return self.__country
class Dates:
def __init__(self):
self.__date_one = None
self.__date_two = None
def setFirstDate(self, day: int, month: int, year: int):
from datetime import datetime
self.__date_one = datetime(year, month, day).strftime("%d.%m.%Y")
def setSecondDate(self, day: int, month: int, year: int):
from datetime import datetime
self.__date_two = datetime(year, month, day).strftime("%d.%m.%Y")
def getDates(self):
# type: () -> list
return [self.__date_one, self.__date_two]
class GooglePages:
def __init__(self):
self.__google_page = None
self.__available_google_pages = __google_url_modifiers__["with_searching"]
def searchImage(self):
self.__google_page = self.__available_google_pages["images"]
def searchNews(self):
self.__google_page = self.__available_google_pages["news"]
def searchBooks(self):
self.__google_page = self.__available_google_pages["books"]
def searchShops(self):
self.__google_page = self.__available_google_pages["shops"]
def searchVideos(self):
self.__google_page = self.__available_google_pages["videos"]
def searchPatents(self):
self.__google_page = self.__available_google_pages["patents"]
def getGooglePage(self):
# type: () -> str
return self.__google_page
class GoogleImages:
def __init__(self):
self.__available_images_modifiers = __google_url_modifiers__["with_image_params"]
self.__image_params = {
"image_color": None,
"color_type": None,
"rights": None,
"size": None,
"type": None,
"aspect_ratio": None,
"image_format": None
}
def setColor(self, color: AvailableColors):
self.__image_params["image_color"] = color
def setColorType(self, color_type: AvailableColorsType):
self.__image_params["color_type"] = color_type
def setImageRights(self, rights: AvailableRights):
self.__image_params["rights"] = rights
def setImageSize(self, size: AvailableSizes):
self.__image_params["size"] = size
def setImageType(self, image_type: AvailableImagesTypes):
self.__image_params["type"] = image_type
def setAspectRatio(self, aspect_ratio: AvailableAspectRatios):
self.__image_params["aspect_ratio"] = aspect_ratio
def setImageFormat(self, image_format: AvailableImageFormats):
self.__image_params["image_format"] = image_format
def getImageParams(self) -> dict:
return self.__image_params
def showColors(self):
self.__print_keys_in_dict("color")
def showColorTypes(self):
self.__print_keys_in_dict("color_type")
def showImageRights(self):
self.__print_keys_in_dict("image_rights")
def showImageSizes(self):
self.__print_keys_in_dict("image_size")
def showImageTypes(self):
self.__print_keys_in_dict("image_type")
def showAspectRatios(self):
self.__print_keys_in_dict("aspect_ratio")
def showImageFormats(self):
self.__print_keys_in_dict("format")
def __print_keys_in_dict(self, source_key: str):
for key, value in self.__available_images_modifiers[source_key].items():
print(key)
class GooglePatents:
def __init__(self):
self.__available_patents_modifiers = __google_url_modifiers__["with_patents_params"]
self.__patents_params = {
"office_patents": None,
"patent_status": None,
"patent_type": None
}
def setOfficePatent(self, office_patent: OfficePatents):
self.__patents_params["office_patents"] = office_patent
def setPatentStatus(self, status: PatentStatus):
self.__patents_params["patent_status"] = status
def setPatentType(self, patent_type: AvailablePatentTypes):
self.__patents_params["patent_type"] = patent_type
def getPatentModifiers(self) -> dict:
return self.__patents_params
class GoogleShop:
def __init__(self):
self.__available_shop_modifiers = __google_url_modifiers__["with_shop_params"]
self.__shop_params = {
"sort_order": None,
"new_products": None,
"max_price": None,
"min_price": None
}
def onlyNewProducts(self):
self.__shop_params["new_products"] = self.__available_shop_modifiers["only_new_products"]
def orderByLowerToHigherPrice(self):
self.__shop_params["sort_order"] = self.__available_shop_modifiers["sort_order_less_to_high"]
def orderByHigherToLowerPrice(self):
self.__shop_params["sort_order"] = self.__available_shop_modifiers["sort_order_high_to_less"]
def orderByReviewScore(self):
self.__shop_params["sort_order"] = self.__available_shop_modifiers["sort_order_reviews"]
def withMinPrice(self, price: int):
self.__shop_params["min_price"] = self.__available_shop_modifiers["with_min_price"].format(str(price))
def withMaxPrice(self, price: int):
self.__shop_params["max_price"] = self.__available_shop_modifiers["with_max_price"].format(str(price))
def betweenTwoPrices(self, min_price: int, max_price: int):
self.__shop_params["min_price"] = self.__available_shop_modifiers["with_min_price"].format(str(min_price))
self.__shop_params["max_price"] = self.__available_shop_modifiers["with_max_price"].format(str(max_price))
def getShopModifiers(self) -> dict:
return self.__shop_params
class GoogleBooks:
def __init__(self):
self.__available_books_modifiers = __google_url_modifiers__["with_books_params"]
self.__books_params = {
"books_type": None,
"with_searching": None
}
def searchOnlyBooksWithPreview(self):
self.__books_params["books_type"] = self.__available_books_modifiers["books_with_preview"]
def searchOnlyGoogleEBooks(self):
self.__books_params["books_type"] = self.__available_books_modifiers["google_ebooks"]
def searchOnlyFreeEBooks(self):
self.__books_params["books_type"] = self.__available_books_modifiers["free_ebooks"]
def searchOnlyBooks(self):
self.__books_params["with_searching"] = self.__available_books_modifiers["with_searching_books"]
def searchOnlyNewsPapers(self):
self.__books_params["with_searching"] = self.__available_books_modifiers["with_searching_news"]
def searchOnlyMagazines(self):
self.__books_params["with_searching"] = self.__available_books_modifiers["with_searching_magazines"]
def getBooksModifiers(self) -> dict:
return self.__books_params
class GoogleVideos:
def __init__(self):
self.__available_video_modifiers = __google_url_modifiers__["with_video_params"]
self.__video_params = {
"duration": None,
"high_quality": None,
"subtitles": None
}
def withShortDuration(self):
self.__video_params["duration"] = self.__available_video_modifiers["duration"]["short"]
def withMediumDuration(self):
self.__video_params["duration"] = self.__available_video_modifiers["duration"]["medium"]
def withLongDuration(self):
self.__video_params["duration"] = self.__available_video_modifiers["duration"]["long"]
def withHighQualityVideos(self):
self.__video_params["high_quality"] = self.__available_video_modifiers["high_quality"]
def withSubtitles(self):
self.__video_params["subtitles"] = self.__available_video_modifiers["with_subtitles"]
def getVideoModifiers(self) -> dict:
return self.__video_params