64 @param searchEngine name of the image search engine to be used |
64 @param searchEngine name of the image search engine to be used |
65 @type str |
65 @type str |
66 @return search query URL |
66 @return search query URL |
67 @rtype QUrl |
67 @rtype QUrl |
68 """ |
68 """ |
|
69 searchEngineUrlTemplates = { |
|
70 "google": "https://www.google.com/searchbyimage?site=search&image_url={0}", |
|
71 "yandex": "https://yandex.com/images/search?&img_url={0}&rpt=imageview", |
|
72 "tineye": "http://www.tineye.com/search?url={0}", |
|
73 } |
69 if not searchEngine: |
74 if not searchEngine: |
70 searchEngine = self.searchEngine() |
75 searchEngine = self.searchEngine() |
71 |
76 |
72 searchEngine_l = searchEngine.lower() |
77 try: |
73 if searchEngine_l == "google": # __IGNORE_WARNING_Y116__ |
|
74 return QUrl( |
78 return QUrl( |
75 "https://www.google.com/searchbyimage?" |
79 searchEngineUrlTemplates[searchEngine.lower()].format( |
76 "site=search&image_url={0}".format(imageUrl.toString()) |
80 imageUrl.toString() |
|
81 ) |
77 ) |
82 ) |
78 elif searchEngine_l == "yandex": |
83 except KeyError: |
79 return QUrl( |
|
80 "https://yandex.com/images/search?" |
|
81 "&img_url={0}&rpt=imageview".format(imageUrl.toString()) |
|
82 ) |
|
83 elif searchEngine_l == "tineye": |
|
84 return QUrl( |
|
85 "http://www.tineye.com/search?url={0}".format(imageUrl.toString()) |
|
86 ) |
|
87 else: |
|
88 return QUrl() |
84 return QUrl() |