Hashirama / OFDL

Onlyfans content downloader with graphical user interface
231 stars 40 forks source link

catch API errors #3

Closed jumoog closed 4 years ago

jumoog commented 4 years ago

Somehow the API has invalid source urls..

Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 140, in _new_conn conn = connection.create_connection( File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 83, in create_connection raise err File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 598, in urlopen httplib_response = self._make_request(conn, method, url, File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request self._validate_conn(conn) File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 852, in _validate_conn conn.connect() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 284, in connect conn = self._new_conn() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 149, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f3c3cb163d0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/requests/adapters.py", line 430, in send resp = conn.urlopen( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen retries = retries.increment(method, url, error=e, _pool=self, File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='us.upload.onlyfans.com', port=443): Max retries exceeded with url: /files/XXXX.mp4 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f3c3cb163d0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, self._kwargs) File "OFDL.py", line 513, in Download_Files self.onlyfans.download(self, user_folder, file) File "/home/OFDL/OFDL/module/OF.py", line 388, in download response = self.session.get(file_name, stream=True) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in get return self.request('GET', url, kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 520, in request resp = self.send(prep, send_kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 630, in send r = adapter.send(request, kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 508, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='us.upload.onlyfans.com', port=443): Max retries exceeded with url: /files/XXXX.mp4 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f3c3cb163d0>: Failed to establish a new connection: [Errno 111] Connection refused')) ^CTraceback (most recent call last): File "OFDL.py", line 548, in root.mainloop() File "/usr/lib/python3.8/tkinter/init.py", line 1420, in mainloop self.tk.mainloop(n) KeyboardInterrupt

To fix that i added a check:

if src is None or not src.startswith('https://cdn'): if type_src is None or not src.startswith('https://cdn'):

jumoog commented 4 years ago

if you wanna see for yourself i can provide you my session

and reported that issue to onlyfans as well 👍

Hashirama commented 4 years ago

if you wanna see for yourself i can provide you my session

The url "us.upload.onlyfans.com" is in one of the sources?

jumoog commented 4 years ago

if you wanna see for yourself i can provide you my session

The url "us.upload.onlyfans.com" is in one of the sources?

Yes 😒

Hashirama commented 4 years ago

if "source" in m:
    file_details = m["source"]
    if "size" in file_details and "source" in file_details:
        file_size = file_details["size"]
        type_src = file_details["source"]
        if type_src is None:
            continue

Does this work?

jumoog commented 4 years ago

if "source" in m:
    file_details = m["source"]
    if "size" in file_details and "source" in file_details:
        file_size = file_details["size"]
        type_src = file_details["source"]
        if type_src is None:
            continue

Does this work?

Yes but the download fails

Hashirama commented 4 years ago

if "source" in m:
    file_details = m["source"]
    if "size" in file_details and "source" in file_details:
        file_size = file_details["size"]
        type_src = file_details["source"]
        if type_src is None:
            continue

Does this work?

Yes but the download fails

What's the error? Same as above? Did the file previously download successfully when you made your change? If so, it won't redownload the file because it's been downloaded already

jumoog commented 4 years ago

it doesn't work because the subdomain is invalide

I sent you my session and browser agent 👍

Hashirama commented 4 years ago

I sent you my session and browser agent 👍

Alright I'll check it out, thanks