Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
.cookies.json
dist/
build/
.DS_Store
.idea/
.vscode/
.history/
.cookies.json
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
30 changes: 15 additions & 15 deletions rarbgcli/rarbgcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,24 @@ def solveCaptcha(threat_defence_url):

def img2txt():
try:
clk_here_button = driver.find_element_by_link_text('Click here')
clk_here_button = driver.find_element(By.LINK_TEXT, 'Click here')
clk_here_button.click()
time.sleep(10)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'solve_string')))
except Exception:
pass
finally:
element = driver.find_elements_by_css_selector('img')[1]
location = element.location
size = element.size
png = driver.get_screenshot_as_png()
x = location['x']
y = location['y']
width = location['x'] + size['width']
height = location['y'] + size['height']
im = Image.open(BytesIO(png))
im = im.crop((int(x), int(y), int(width), int(height)))
return pytesseract.image_to_string(im)

element = driver.find_elements(By.CSS_SELECTOR, 'img')[1]
location = element.location
size = element.size
png = driver.get_screenshot_as_png()
x = location['x']
y = location['y']
width = location['x'] + size['width']
height = location['y'] + size['height']
im = Image.open(BytesIO(png))
im = im.crop((int(x), int(y), int(width), int(height)))
return pytesseract.image_to_string(im)

options = Options()
options.add_argument('--no-sandbox')
Expand All @@ -129,7 +129,7 @@ def img2txt():
# chromedriver_path = get_chrome_driver.main(PROGRAM_HOME)
driver = webdriver.Chrome(
ChromeDriverManager(path=PROGRAM_HOME).install(),
chrome_options=options,
options=options,
service_log_path=('NUL' if sys.platform == 'win32' else '/dev/null'),
)
print('successfully loaded chrome driver')
Expand All @@ -147,7 +147,7 @@ def img2txt():
download_tesseract(PROGRAM_HOME)
solution = img2txt()

text_field = driver.find_element_by_id('solve_string')
text_field = driver.find_element(By.ID, 'solve_string')
text_field.send_keys(solution)
try:
text_field.send_keys(Keys.RETURN)
Expand Down
19 changes: 9 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
asyncio
beautifulsoup4==4.11.1
Pillow==9.2.0
prompt_toolkit==3.0.20
pytesseract==0.3.9
questionary==1.10.0
requests==2.27.1
selenium==3.141.0
beautifulsoup4>=4.11.1
Pillow>=9.2.0
prompt_toolkit>=3.0.20
pytesseract>=0.3.9
questionary>=1.10.0
requests>=2.27.1
selenium>=4.0.0
tqdm
webdriver-manager==3.8.3
wget==3.2
webdriver-manager>=3.8.3
wget>=3.2
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
with open('README.md', 'r') as fh:
long_description = fh.read().replace('](', '](https://raw.githubusercontent.com/FarisHijazi/rarbgcli/master/')
with open('requirements.txt', 'r') as fh:
rqeuirements = fh.readlines()
requirements = fh.readlines()

version = subprocess.Popen('git describe --abbrev=0 --tags', shell=True, stdout=subprocess.PIPE).stdout.read().decode().strip().lstrip('v')

Expand All @@ -22,7 +22,7 @@
long_description_content_type='text/markdown',
packages=setuptools.find_packages(),
python_requires='>=3.6',
install_requires=rqeuirements,
install_requires=requirements,
keywords='rarbg torrent rarbgcli rarbgapi cli api scraper rarbg-cli rarbg-api rarbg-scraper',
entry_points={
'console_scripts': [
Expand Down