mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.03k stars 796 forks source link

Can not download media with chat id #1045

Open ashokdath opened 3 years ago

ashokdath commented 3 years ago

Can not download media with the chat id, Getting the following error

webwhatsapi.wapi_js_wrapper.JsException: Error in function downloadFile (ReferenceError: None is not defined). Command: return WAPI.downloadFile(None, arguments[0])

Can somebody help?

atthevergeof commented 3 years ago

I am trying to download a PDF from a chat using

messages = myContact.get_chat().get_messages()
for message in messages:
    if message.type == "document":
        filename = message.save_media(dirPath, force_download=True)

but I am getting a similar error

Traceback (most recent call last):
  File "/app/webwhatsapi/wapi_js_wrapper.py", line 135, in __call__
    return self.driver.execute_async_script(command)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 657, in execute_async_script
    return self.execute(command, {
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: ReferenceError: None is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Documents.py", line 116, in <module>
    filename = message.save_media(dirPath, force_download=True)
  File "/app/webwhatsapi/objects/message.py", line 103, in save_media
    ioobj = self.driver.download_media(self, force_download)
  File "/app/webwhatsapi/__init__.py", line 798, in download_media
    file_data = self.download_file(media_msg.client_url)
  File "/app/webwhatsapi/__init__.py", line 785, in download_file
    return b64decode(self.wapi_functions.downloadFile(url))
  File "/app/webwhatsapi/wapi_js_wrapper.py", line 143, in __call__
    raise JsException(
webwhatsapi.wapi_js_wrapper.JsException: Error in function downloadFile (ReferenceError: None is not defined). Command: return WAPI.downloadFile(None, arguments[0])