k0rnh0li0 / onlyfans-dl

OnlyFans content downloader
GNU General Public License v3.0
772 stars 221 forks source link

TypeError: expected string or bytes-like object #226

Closed ghost closed 8 months ago

ghost commented 1 year ago

Works fine with 15+ other accounts. Error occurs when trying to download kazumisworld. Free trial available here.

Traceback (most recent call last): Estimated Time left: 0:00:00, Estimated finish time: 23:22:51
  File "E:\onlyfans-dl\onlyfans-dl.py", line 428, in <module>
    cur_count = download_posts(cur_count, video_posts, False)
  File "E:\onlyfans-dl\onlyfans-dl.py", line 281, in download_posts
    download_media(media, is_archived)
  File "E:\onlyfans-dl\onlyfans-dl.py", line 222, in download_media
    ext = re.findall('\.\w+\?', source)
  File "C:\Users\%User%\AppData\Local\Programs\Python\Python39\lib\re.py", line 241, in findall
    return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object
janolehuebner commented 1 year ago

I just took a look at this... as it says in the exception "line 222, in download_media ext = re.findall('.\w+\?', source)"

is the problem. source = media["source"]["source"] can for some reason sometimes be None

cpressland commented 1 year ago

Have checked in a fix, hopefully it gets merged, but if not feel free to use my branch in the mean time. Seems to work fine from my testing.

SinicalPyx commented 1 year ago

This is most likely from them adding widevine DRM. Pre widevine vids and vids from models that didn't opt into it will still download.

jadenquinn commented 1 year ago

For those who want to use the fix (which exists) and don't really know how to use Github, the fixed "merge" or whatever version is on this different page: https://github.com/cpressland/onlyfans-dl

(I literally just learned I could do this, might help others too)

MarioVilas commented 1 year ago

Is it really a fix though? Skimming through it, it just looks like it avoids the crash but doesn't download the file https://github.com/k0rnh0li0/onlyfans-dl/compare/master...cpressland:onlyfans-dl:master

cpressland commented 1 year ago

Correct @MarioVilas - this does not fix the issue at all. It simply skips it. As best as I can tell this project is not attempting any DRM decryption, adding it would be a huge piece of work.

MarioVilas commented 1 year ago

Seems like a completely reasonable choice! Maybe there could be a log of all files that did not get downloaded, but that's less of a fix and more of a feature request :)

SinicalPyx commented 1 year ago

Yeah that's a good idea and would be easy to add. I'm thinking of using a seperate browser to screen record the drm videos. Currently widevine is too difficult to crack for me at least.

jadenquinn commented 1 year ago

Yeah that's a good idea and would be easy to add. I'm thinking of using a seperate browser to screen record the drm videos. Currently widevine is too difficult to crack for me at least.

You actually can't do that. The viewport just... doesn't appear when using any one of a wide selection of screen recording programs across Windows and MacOS.

SinicalPyx commented 1 year ago

Yeah that's true, you'd have to record from outside a virtual machine. Just tested an easier automated way using playwright and... surprisingly works great!

*sound doesn't record but can be implemented