Skip to content

Commit

Permalink
Merge pull request #667 from bropines/dev
Browse files Browse the repository at this point in the history
update proxy
  • Loading branch information
dmMaze authored Dec 1, 2024
2 parents 2d72206 + 374218d commit 34a467f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
13 changes: 2 additions & 11 deletions modules/ocr/ocr_google_lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import List

import httpx
from httpx_socks import SyncProxyTransport
from PIL import Image
import io
import json5
Expand Down Expand Up @@ -35,16 +34,8 @@ def __init__(self, proxy=None):

def _send_request(self, url, headers, files):
try:
if self.proxy:
if self.proxy.startswith('socks5://') or self.proxy.startswith('socks4://'):
transport = SyncProxyTransport.from_url(self.proxy)
client = httpx.Client(transport=transport)
response = client.post(url, headers=headers, files=files)
else:
response = httpx.post(url, headers=headers, files=files, proxies=self.proxy)
else:
response = httpx.post(url, headers=headers, files=files)

client = httpx.Client(proxies=self.proxy) if self.proxy else httpx.Client()
response = client.post(url, headers=headers, files=files)
if response.status_code != 200:
raise Exception(f"Failed to upload image. Status code: {response.status_code}")
return response
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ httpx[socks,brotli]
langdetect
translators
json5
httpx-socks
pywin32; sys_platform == 'win32'
winsdk; sys_platform == 'win32'
brotlicffi; sys_platform == 'win32'
pyobjc-core; sys_platform == 'darwin'
pyobjc-framework-cocoa; sys_platform == 'darwin'
pyobjc-framework-coreml; sys_platform == 'darwin'
pyobjc-framework-quartz; sys_platform == 'darwin'
pyobjc-framework-vision; sys_platform == 'darwin'
pyobjc-framework-vision; sys_platform == 'darwin'

0 comments on commit 34a467f

Please sign in to comment.