Yowsup: TypeError: __init__() missing 1 required positional argument: 'config' on mediauploader

Created on 7 May 2019  路  11Comments  路  Source: tgalal/yowsup

using yowsup-cli -y --config-phone xxxxxxxx, when issuing /image send xxxxxxxxx [path] using latest patch https://github.com/tgalal/yowsup/commit/31a9871b18398f5ad5f1c04459f4ba94f2b02a22

error arise
```[connected]:/image send xxxxxxxxxxxx /home/xxxx/whatsapp-framework/cacheimg/26c8af68eea2393177f4e1f9a8d1aa34.jpg test
File "/usr/lib/python3.5/asyncore.py", line 83, in read
obj.handle_read_event()
File "/usr/lib/python3.5/asyncore.py", line 423, in handle_read_event
self.handle_read()
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/network/dispatcher/dispatcher_asyncore.py", line 48, in handle_read
self.connectionCallbacks.onRecvData(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/network/layer.py", line 100, in onRecvData
self.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/network/layer.py", line 103, in receive
self.toUpper(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/noise/layer_noise_segments.py", line 39, in receive
self.toUpper(bytes(data))
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/noise/layer.py", line 156, in receive
self._flush_incoming_buffer()
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/noise/layer.py", line 144, in _flush_incoming_buffer
self.toUpper(self._wa_noiseprotocol.receive())
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/coder/layer.py", line 21, in receive
self.toUpper(node)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/logger/layer.py", line 14, in receive
self.toUpper(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/axolotl/layer_control.py", line 35, in receive
self.toUpper(protocolTreeNode)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 194, in receive
s.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/axolotl/layer_receive.py", line 34, in receive
self.toUpper(protocolTreeNode)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 194, in receive
s.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 126, in receive
if not self.processIqRegistry(node):
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 161, in processIqRegistry
successClbk(protocolTreeNode, originalIq)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/protocol_media/layer.py", line 74, in onRequestUploadSuccess
self.toUpper(ResultRequestUploadIqProtocolEntity.fromProtocolTreeNode(resultNode))
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/interface/interface.py", line 77, in receive
if not self.processIqRegistry(entity):
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/interface/interface.py", line 56, in processIqRegistry
successClbk(entity, originalIq)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/demos/cli/layer.py", line 403, in
successFn = lambda successEntity, originalEntity: self.onRequestUploadResult(jid, mediaType, path, successEntity, originalEntity, caption)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/demos/cli/layer.py", line 548, in onRequestUploadResult
successFn, self.onUploadError, self.onUploadProgress, asynchronous=False)
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0-py3.5.egg/yowsup/layers/protocol_media/mediauploader.py", line 18, in __init__
WARequest.__init__(self)
TypeError: __init__() missing 1 required positional argument: 'config'

general: Disconnected:
```

Most helpful comment

Sending media is broken and will be fixed in next release. Closing this as there are dozens of similar reports

All 11 comments

Same problem here

+1. same

@tgalal I have fix missing 1 required positional argument config, but new error show up when issuing /image send 8763xxxxx /my/image.jpg

[connected]:/image send xxxxxx /my/image.jpg Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/yowsup-3.2.3-py3.6.egg/yowsup/layers/protocol_media/mediauploader.py", line 169, in run self.successCallback(sourcePath, self.jid, result) File "/usr/local/lib/python3.6/dist-packages/yowsup-3.2.3-py3.6.egg/yowsup/demos/cli/layer.py", line 544, in <lambda> successFn = lambda filePath, jid, url: self.doSendMedia(mediaType, filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption) File "/usr/local/lib/python3.6/dist-packages/yowsup-3.2.3-py3.6.egg/yowsup/demos/cli/layer.py", line 526, in doSendMedia entity = ImageDownloadableMediaMessageProtocolEntity.fromFilePath(filePath, url, ip, to, caption = caption) AttributeError: type object 'ImageDownloadableMediaMessageProtocolEntity' has no attribute 'fromFilePath'

could you please give ours clue how to build media message..

Thank You

This is working code:

message_attrs = MessageAttributes(recipient=to)
downloadablemedia_attrs = DownloadableMediaMessageAttributes.from_file(filepath=data.filepath, url=url)
image_attrs = ImageAttributes(width=data.width, height=data.height, caption=data.caption, peg_thumbnail=data.jpegthumbnail)

entity = ImageDownloadableMediaMessageProtocolEntity(image_attrs, downloadablemedia_attrs, message_attrs)

I also have fixed config missing parameter, however I do see the following result in mediauploader:

['HTTP/1.1 400 Bad Request', 'Content-Type: application/json', 'Date: Sun, 19 May 2019 12:21:47 GMT', 'X-FB-TRIP-ID: 78127951', 'Connection: close', 'Content-Length: 99', '', '{"debug_info":{"retriable":false,"type":"OPERATION_UNKNOWN_V3","message":"Unknown operation type"}}']
result= {'mimetype': None, 'filehash': None, 'type': None, 'error': None, 'width': None, 'height': None, 'name': None, 'url': None, 'size': None}
E 2019-05-19 08:21:57,995 yowsup.layers.protocol_media.mediauploader - uploadUrl: https://mmg.whatsapp.net/u/f/8ktdd49qZvqusevpYXi2jFzhSlsABYk8qNri4w/Ak1z8lMEkyqk5I9saBodmRqwGwpfbNinJLgt0blPngyg, result of uploading media has no url

And this is my POST content:

POST https://mmg.whatsapp.net/u/f/8ktdd49qZvqusevpYXi2jFzhSlsABYk8qNri4w/Ak1z8lMEkyqk5I9saBodmRqwGwpfbNinJLgt0blPngyg
Content-Type: multipart/form-data; boundary=-------zzXXzzYYzzXXzzQQ
Host: mmg.whatsapp.net
User-Agent: WhatsApp/2.19.51 Android/8.0.0 Device/samsung-star2lte
Content-Length: 24365


---------zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="to"

[email protected]
---------zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="from"

[email protected]
---------zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="file"; filename="YYYYYYY.jpg"
Content-Type: image/jpeg

And seems like some form-data is missing what causes "Unknown operation type". How do we figure out exactly what?

@r0bocharov thank you for your assistance I'm able build media message
```Message:
ID: 1558411776-3
To: [email protected]
Type: media
Timestamp: 1558411776

proto=image_message {
url: "https://mmg-fna.whatsapp.net/d/f/Aiw9Ytg1ikFTMxBqhY8ZMFoYQiEDp1DULx9OmSFUXeH9.enc"
mimetype: "image/jpeg"
caption: ""
file_sha256: "c\317\254g$\337{\234\260\351\360tA\031\224\343~\004\257\205\211\003\252\267\343z\345G3m\334"
file_length: 23834
height: 355
width: 474
media_key: "d32e368819889e6a3d73330fc39d89a07832ba7706d54e2a29c351655039dcbe"
jpeg_thumbnail: "\377\330\377\340\000\020JFIF\000\001\001\000\000\001\000\001\000\000\377\333\000C\000\010\006\006\007\006\005\010\007\007\007\t\t\010\n\014\024\r\014\013\013\014\031\022\023\017\024\035\032\037\036\035\032\034\034 $.\' \",#\034\034(7),01444\037\'9=82<.342\377\333\000C\001\t\t\t\014\013\014\030\r\r\0302!\034!22222222222222222222222222222222222222222222222222\377\300\000\021\010\000/\000@\003\001\"\000\002\021\001\003\021\001\377\304\000\037\000\000\001\005\001\001\001\001\001\001\000\000\000\000\000\000\000\000\001\002\003\004\005\006\007\010\t\n\013\377\304\000\265\020\000\002\001\003\003\002\004\003\005\005\004\004\000\000\001}\001\002\003\000\004\021\005\022!1A\006\023Qa\007\"q\0242\201\221\241\010#B\261301\025R\321\360$3br\202\t\n\026\027\030\031\032%&\'()
456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\203\204\205\206\207\210\211\212\222\223\224\225\226\227\230\231\232\242\243\244\245\246\247\250\251\252\262\263\264\265\266\267\270\271\272302\303\304\305\306\307\310\311\312\322\323\324\325\326\327\330\331\332\341\342\343\344\345\346\347\350\351\352\361\362\363\364\365\366\367\370\371\372\377\304\000\037\001\000\003\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\002\003\004\005\006\007\010\t\n\013\377\304\000\265\021\000\002\001\002\004\004\003\004\007\005\004\004\000\001\002w\000\001\002\003\021\004\005!1\006\022AQ\007aq\023\"2\201\010\024B\221\241\261301\t#3R\360\025br\321\n\026$4\341%\361\027\030\031\032&\'()56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\202\203\204\205\206\207\210\211\212\222\223\224\225\226\227\230\231\232\242\243\244\245\246\247\250\251\252\262\263\264\265\266\267\270\271\272302\303\304\305\306\307\310\311\312\322\323\324\325\326\327\330\331\332\342\343\344\345\346\347\350\351\352\362\363\364\365\366\367\370\371\372\377\332\000\014\003\001\000\002\021\003\021\000?\000\344--\300P\241x\rW\354\006Q\221E\232fr\235\233\014?\017\362*\375\202n\225p8\031\376u\303&uAhT\212\330\037 \201\375\321V \264\314\022\311\214ms\370\014\342\255\210\202\213p\017 \245O\010Qo,d\217\231x\367\254\357\251\265\2642\245\267\t\034\347\034\344V^\251\017\357\003\201\306@\376U\321\315\010\373,\200\363\225S\232\310\277\213*\300\372\002?*\244\307c\016HHH\370\352q\374\352\265\320\306\323\376\315k\334\374\256\212q\205l\017\316\263.\360\025\261\375\332\326,\316H\350\354\2002\302\344\343\031\006\264t\322\026fC\331\215Q\207\010Gl\020\177Z\271\177\323\035\275T\377\000J\312b\206\305\211>F\217\270P\206\246\332\252\034\225\317\177\273\317\370Um\352\376R\023\202\321\016\1771R\233\215\314\020\177\313Ln\372w\254\236\347B\330\212v\216\t\364_\320U\033\241\2724o^?Bj\343\314$\225\211301\014\347\362\342\263\347;\204`6>l\376B\251n\017c.\350\t\231\213\034\215\325\237)\r\016O^\225nV#\317\366\254\225\220\272\014\372\326\3600\233:8\345;\333\'\224u\0072i\'\004I\317\336\342\262\226P\212\006\177\213\374h\023\223\371\377\000J\241<\247z\201\352kh\243\t3\377\331"
}

mediatype=image

```
but image never show up in recepient, status send.. any idea?

btw I'm using https://github.com/AragurDEV/yowsup/blob/master/yowsup/layers/protocol_media/mediauploader.py to resolve this issue 'result of uploading media has no url'

@Sharissa90 thank you for the reference. The same for me. In this thread #https://github.com/tgalal/yowsup/issues/2149 check out this post https://github.com/tgalal/yowsup/issues/2149#issuecomment-328309545. I had no time yet to apply this patch and try out.

Sending media is broken and will be fixed in next release. Closing this as there are dozens of similar reports

I also had the problem of the missing parameter.
File "/usr/local/lib/python3.5/dist-packages/yowsup-3.2.0 py3.5.egg/yowsup/layers/protocol_media/mediauploader.py", line 18, in __init__ WARequest.__init__(self) TypeError: __init__() missing 1 required positional argument: 'config'

To fix that, I modified the file mediauploader.py on the route yowsup/layers/protocol_media
Here the class WARequest.__init__(self) is receiving a parameter, so you have to import the YowProfile class from yowsup.profile.profile import YowProfile and pass an instance of it.
Then the code would be as follows:
class MediaUploader(YowProfile, WARequest, threading.Thread):
def __init__(self, ...)
profile = YowProfile('51XXXXXXXXX')
WARequest.__init__(self, profile)

The problem that I present is that when I send the following error I get

E 2019-05-30 18:52:32,349 yowsup.layers.protocol_media.mediauploader - uploadUrl: https://mmg.whatsapp.net/u/f/zqjN9TWmQ6fsiNYDqJa4OlzwJm4ABYofZnGhKQ/Ai2fRSWNK7wQ2mdRAD72AQcklnKXH1vImdXJrkoE6Jfd, result of uploading media has no url

E 2019-05-30 18:52:32,350 yowsup.demos.cli.layer - Upload file ./img.png to https://mmg.whatsapp.net/u/f/zqjN9TWmQ6fsiNYDqJa4OlzwJm4ABYofZnGhKQ/Ai2fRSWNK7wQ2mdRAD72AQcklnKXH1vImdXJrkoE6Jfd for [email protected] failed!

Somebody could help me

@jolmerdx did you read my comment?

@tgalal As I understand the release did not come out, but can indicate what is the possible commit that has this solution?

@tgalal Could you please release the fix? That would be very helpful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyberp1983 picture cyberp1983  路  3Comments

thatskriptkid picture thatskriptkid  路  3Comments

ikuraj picture ikuraj  路  5Comments

darode picture darode  路  4Comments

qvs5010 picture qvs5010  路  4Comments