UltimaScraper icon indicating copy to clipboard operation
UltimaScraper copied to clipboard

Download Failed

Open BabyRdx opened this issue 5 years ago • 13 comments

When scraping content I am having an issue where some files will not download. The error reported to the terminal is: "Download Failed: X" where X denotes the URL of the file. It seems to be specific to these files as re-scraping the content creator will throw the same error with the same files.

The URL is valid as I am able to browse to the resource with a browser using a valid session. My scrapping settings are set to default other (other than file naming format) than max threads which has been limited to 1. I was also having this issue when max threads was set to -1 but found a support thread that recommended limiting the number of worker threads.

Was having this issue with a previous version but did a fresh install using the latest version (currently v7.2) hoping it would resolve the issue,

I have figured out that I can resolve this issue by changing the file naming format to the default from: {date} - {text}#{media_id}.{ext}

I was wondering if there is anyway that I can keep the file naming format {date} - {text}#{media_id}.{ext} but able to download the actual files. Perhaps there is a verbose flag I can set that will output more data about the reason why these files cause the download to fail?

BabyRdx avatar May 18 '21 15:05 BabyRdx

What is the username and are you using proxies?

UltimaHoarder avatar May 18 '21 15:05 UltimaHoarder

Exactly similar thing happening with me. yes im using vpn and the model was https://onlyfans.com/himandherukprem/

It works completely fine if i leave the config as it is. the moment im changing it, its getting failed with the same file.

freakish804 avatar May 18 '21 16:05 freakish804

Exactly similar thing happening with me. yes im using vpn and the model was https://onlyfans.com/himandherukprem/

It works completely fine if i leave the config as it is. the im changing it, its getting failed with the same file.

Which proxy are you using?

UltimaHoarder avatar May 18 '21 16:05 UltimaHoarder

Im using expressvpn

freakish804 avatar May 18 '21 16:05 freakish804

Another user said that VPN no longer works with OnlyFans. Nordvpn and IPVanish work.

UltimaHoarder avatar May 18 '21 17:05 UltimaHoarder

Dont know about others but its working fine with VPN from day one. Btw, Im using VPN because have to. Onlyfans is blocked here

freakish804 avatar May 18 '21 17:05 freakish804

Exactly similar thing happening with me. yes im using vpn and the model was https://onlyfans.com/himandherukprem/

It works completely fine if i leave the config as it is. the moment im changing it, its getting failed with the same file.

Using a VPN here but it is not one of the well known ones (Nord, Express, SurfShark etc) and I think it is unrelated to the issue. My reason that I believe it is unrelated because like freakish804, it's only when I change the file naming config (I assume that is also what freakish804 is changing in the config). Furthermore, if VPN was an issue I believe it wouldn't work via the browser. After all, the scraper is using the same user-agent as the browser.

From looking at the Download Failed, it partially downloads but does not complete.

Same issue happens with multiple content creators so I believe it is independent from that.

BabyRdx avatar May 19 '21 01:05 BabyRdx

Was able to find a test case for you with a free content creator. Please remove the & symbols from the UN listed below.

Running Python 3.9.5. Content Creator (Free): in&diefo&xxx Setting "filename_format": "{filename}.{ext}" downloads all 9 images as intended. Deleting .sites and changing filename_format to "{text}.{ext}" produces the error on one of the 9 images.

If I delete .sites to perform a fresh scrape the same error is reproduced on the same image.

BabyRdx avatar May 19 '21 03:05 BabyRdx

I had the same (or a similar issue). The problem was definitely with the filename

Explanation: The text_length limitation is enforced on a character level, but (at least on linux) file/path-length restrictions are in bytes. In unicode certain characters can be multiple bytes. Should a model create a text with a ton of unicode characters (e.g. 𝐓𝐡𝐞𝐬𝐞 𝐚𝐫𝐞 𝐭𝐡𝐞 𝐟𝗼𝐫 𝐲𝗼𝐮 or other fun "fake fonts") this means the file name won't be cut enough to be a valid filename

Here's the fix: helpers/main_helper.py, Line 347ff:

Replace

if has_text:
       filtered_text = text[:text_length]

with:

if has_text:
       #https://stackoverflow.com/a/43848928
       def utf8_lead_byte(b):
            '''A UTF-8 intermediate byte starts with the bits 10xxxxxx.'''
            return (b & 0xC0) != 0x80

       def utf8_byte_truncate(text, max_bytes):
            '''If text[max_bytes] is not a lead byte, back up until a lead byte is
            found and truncate before that character.'''
            utf8 = text.encode('utf8')
            if len(utf8) <= max_bytes:
                return utf8
            i = max_bytes
            while i > 0 and not utf8_lead_byte(utf8[i]):
                i -= 1
            return utf8[:i]

        filtered_text = utf8_byte_truncate(text,text_length).decode('utf8')

this is a bit hackish and I don't have the time right now to send a PR, but it resolves the issue for all the posts affected.

kr33g33 avatar May 19 '21 09:05 kr33g33

@kr33g33 thanks. Patched code locally and confirmed issue was resolved.

BabyRdx avatar May 19 '21 10:05 BabyRdx

Whilst this issue is resolved there is something further going on with the filename text with the specific files that are processed with unicode. It may be isolated to Windows but I have noticed that some (but not all) programs have issues opening the files. One big example of this is VLC media player although I did find at least one other program that had issues resolving the path.

The files that were not previously affected are still not affected but any file that was now exhibits the behaviour above.

Simply renaming, moving or copying the file resolves the issue which leads me to believe the issue is caused by the way the filename is written when dealing with names that contain unicode.

BabyRdx avatar May 19 '21 10:05 BabyRdx

Running the latest commit and now getting this error when I start the script

Traceback (most recent call last): File "C:\Users\user\Documents\GitHub\OnlyFans\start_ofd.py", line 10, in main_test.check_config() File "C:\Users\user\Documents\GitHub\OnlyFans\tests\main_test.py", line 23, in check_config import helpers.main_helper as main_helper File "C:\Users\user\Documents\GitHub\OnlyFans\helpers\main_helper.py", line 363 filtered_text = utf8_byte_truncate(text,text_length).decode('utf8') ^

ChillyP avatar May 21 '21 14:05 ChillyP

Running the latest commit and now getting this error when I start the script

Traceback (most recent call last): File "C:\Users\user\Documents\GitHub\OnlyFans\start_ofd.py", line 10, in main_test.check_config() File "C:\Users\user\Documents\GitHub\OnlyFans\tests\main_test.py", line 23, in check_config import helpers.main_helper as main_helper File "C:\Users\user\Documents\GitHub\OnlyFans\helpers\main_helper.py", line 363 filtered_text = utf8_byte_truncate(text,text_length).decode('utf8') ^

Fixed

UltimaHoarder avatar May 21 '21 20:05 UltimaHoarder