Closed kyngs closed 2 years ago
Only "Download type: slow direct download (without CAPTCHA)" is still working.
Same for me. Slow direct downloads without captcha are working, but anything else.
Hotpatching site-packages/requests/models.py
PreparedRequest.prepare_url()
with the following hack just to see if it is the only thing required:
if url.startswith('https:https://'):
url = url[6:]
Makes it work.
This also makes it work: https://github.com/setnicka/ulozto-downloader/pull/83
Thanks for the quick fix LGTM tested and worked fine. I this repository still maintained? Could we get this fix into the pip repository? Maybe @hroncok we can use your fork
for quick file edit, this is where the file is located on MacOS if installed with pip and pyenv
/Users/<username>/.pyenv/versions/3.7.10/lib/python3.7/site-packages/ulozto_downloader/page.py
Hotpatching
site-packages/requests/models.py
PreparedRequest.prepare_url()
with the following hack just to see if it is the only thing required:if url.startswith('https:https://'): url = url[6:]
Makes it work.
For me it also works. Thank you:)
Hotpatching
site-packages/requests/models.py
PreparedRequest.prepare_url()
with the following hack just to see if it is the only thing required:if url.startswith('https:https://'): url = url[6:]
Makes it work.
Thank you. Myself, I didn't want to touch models.py
so I hacked a similar fix into captcha.py
: I added the line img_url = img_url[6:]
before every occurence of u = requests.get(img_url)
. Please don't do this yourself, I am a beginner in Python and may have created an instability in the code...
@hroncok thank you for the PR, I merged it into master. Later today (after reviving other changes) I will publish a new version to the pip repository.
This project is in a low-maintenance state, especially during the summer when I have almost zero time for it. So sorry for delay (applies also to other issues and PR... I will process them today).
thanks a milion guys, but I am amateur. I would need some kinda tutorial how use this fix. or I will wait. Solving captcha is always faster than slow download.
I am amateur. I would need some kinda tutorial how use this fix.
You need to modify the specified file in your Python*\Lib
directory. In a noob-friendly way:
ulozto-downloader uses some external packages that are written in the scripting language called Python. Python is an interpreted language, which means that you don't compile source code into an executable but instead a program called interpreter will decode instructions on the fly. The Python interpreter is installed on your system and can either be fed .py
files or manually typed commands. Python scripts import pre-written modules/libraries/packages to perform more complicated tasks, like opening a GUI window, manipulating images or making web requests. Due to clashes between Python 2 and 3, there may be multiple Python versions on your system so you better find out which is the "default" one - that is, what gets run when you call python
on the command line. (Assuming you are using Windows, just substitute "/" for "\" in paths and "terminal" for "command line" etc. on Unix-based systems.) We will now open up the Python CLI and ask it where it is installed. So open Command Prompt (Win+R, cmd, Enter) and type python
. You are now in the Python CLI, as indicated by >>>
at the start. Now we import the "sys" package so that we can access system information: use the command import sys
. Then, use print(sys.exec_prefix)
to get the location of your Python directory printed in the command line.
Now navigate to that folder and proceed to subfolders \Lib\site-packages\requests\
. Open the file models.py
in Notepad (or a better alternative like Notepad++, especially if using Windows <10 because of CRLF/LF clash). The error, as you have seen on the command line, is that URL starting with https:https://
is not valid and some code in models.py
cannot handle that. The double-prepending of https:
happens likely elsewhere but we will apply a quick and dirty fix by modifying the request-handling module to fix the URL if it erroneously begins with https:https://
.
Go to line 410. This is where the definition of the function PreparedRequest.prepare_url
begins. Add the aforementioned lines to the beginning of its code. Keep the eight/twelve spaces at their beginning, as whitespace is crucial in Python scripts! So now, lines 411 and 412 should read:
if url.startswith('https:https://'): url = url[6:]
The code checks the url
variable for the erroneous prefix: if it starts with https:https://
, then the second line removes the first 6 characters. That's it. Save and close.
When downloading any file, the script errors out with the following error:
A few hours ago it still worked. Perhaps a change of API from uloz.to?