本文整理匯總了Python中yowsup.layers.protocol_media.mediauploader.MediaUploader類的典型用法代碼示例。如果您正苦於以下問題:Python MediaUploader類的具體用法?Python MediaUploader怎麽用?Python MediaUploader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了MediaUploader類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_request_upload_result
def on_request_upload_result(
self, jid, path, result_request_upload_iq_protocol_entity, request_upload_iq_protocol_entity, caption=None
):
if request_upload_iq_protocol_entity.mediaType == RequestUploadIqProtocolEntity.MEDIA_TYPE_AUDIO:
do_send_fn = self.do_send_audio
else:
do_send_fn = self.do_send_image
if result_request_upload_iq_protocol_entity.isDuplicate():
do_send_fn(
path,
result_request_upload_iq_protocol_entity.getUrl(),
jid,
result_request_upload_iq_protocol_entity.getIp(),
caption,
)
else:
success_fn = lambda filePath, jid, url: do_send_fn(
filePath, url, jid, result_request_upload_iq_protocol_entity.getIp(), caption
)
mediaUploader = MediaUploader(
jid,
self.getOwnJid(),
path,
result_request_upload_iq_protocol_entity.getUrl(),
result_request_upload_iq_protocol_entity.getResumeOffset(),
success_fn,
self.on_upload_error,
self.on_upload_progress,
async=True,
)
mediaUploader.start()
示例2: onRequestUploadResult
def onRequestUploadResult(
self, jid, mediaType, filePath, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity, caption=None
):
if resultRequestUploadIqProtocolEntity.isDuplicate():
self.doSendMedia(
mediaType,
filePath,
resultRequestUploadIqProtocolEntity.getUrl(),
jid,
resultRequestUploadIqProtocolEntity.getIp(),
caption,
)
else:
successFn = lambda filePath, jid, url: self.doSendMedia(
mediaType, filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption
)
mediaUploader = MediaUploader(
jid,
self.getOwnJid(),
filePath,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
successFn,
self.onUploadError,
self.onUploadProgress,
async=False,
)
mediaUploader.start()
示例3: onRequestUploadResultAudio
def onRequestUploadResultAudio(self, jid, filePath, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity):
if resultRequestUploadIqProtocolEntity.isDuplicate():
self.doSendAudio(filePath, resultRequestUploadIqProtocolEntity.getUrl(), "audio", jid,
resultRequestUploadIqProtocolEntity.getIp())
else:
mediaUploader = MediaUploader(jid, self.getOwnJid(), filePath,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
self.onUploadSuccessAudio, self.onUploadError, self.onUploadProgress, async=False)
mediaUploader.start()
示例4: onRequestUploadResult
def onRequestUploadResult(self, jid, filePath, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity):
if resultRequestUploadIqProtocolEntity.isDuplicate():
self.doSendImage(filePath, resultRequestUploadIqProtocolEntity.getUrl(), jid,
resultRequestUploadIqProtocolEntity.getIp())
else:
# successFn = lambda filePath, jid, url: self.onUploadSuccess(filePath, jid, url, resultRequestUploadIqProtocolEntity.getIp())
mediaUploader = MediaUploader(jid, self.getOwnJid(), filePath,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
self.onUploadSuccess, self.onUploadError, self.onUploadProgress, async=False)
mediaUploader.start()
示例5: onRequestUploadResult
def onRequestUploadResult(self,jid,filePath,resultRequestUploadIqProtocolEntity,requestUploadIqProtocolEntity):
if resultRequestUploadIqProtocolEntity.isDuplicate():
if self.MEDIA_TYPE=="image":
self.doSendImage(filePath,resultRequestUploadIqProtocolEntity.getUrl(),jid,resultRequestUploadIqProtocolEntity.getIp())
elif self.MEDIA_TYPE=="video":
self.doSendVideo(filePath,resultRequestUploadIqProtocolEntity.getUrl(),jid,resultRequestUploadIqProtocolEntity.getIp())
elif self.MEDIA_TYPE=="audio":
self.doSendAudio(filePath,resultRequestUploadIqProtocolEntity.getUrl(),jid,resultRequestUploadIqProtocolEntity.getIp())
else:
mediaUploader=MediaUploader(jid,self.getOwnJid(),filePath,resultRequestUploadIqProtocolEntity.getUrl(),resultRequestUploadIqProtocolEntity.getResumeOffset(),self.onUploadSuccess,self.onUploadError,self.onUploadProgress,async=False)
mediaUploader.start()
示例6: __onRequestUploadSuccess
def __onRequestUploadSuccess(self, resultRequestUploadIqProtocolEntity, requestUploadEntity, builder, success, error = None, progress = None):
if(resultRequestUploadIqProtocolEntity.isDuplicate()):
return success(builder.build(resultRequestUploadIqProtocolEntity.getUrl(), resultRequestUploadIqProtocolEntity.getIp()))
else:
successFn = lambda path, jid, url: self.__onMediaUploadSuccess(builder, url, resultRequestUploadIqProtocolEntity.getIp(), success)
errorFn = lambda path, jid, errorText: self.__onMediaUploadError(builder, errorText, error)
mediaUploader = MediaUploader(builder.jid, self.getOwnJid(), builder.getFilepath(),
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
successFn, errorFn, progress, async=True)
mediaUploader.start()
示例7: _on_upload_request_result
def _on_upload_request_result(self, jid, file_path, upload_result, request_entity):
"""
If the file has never been uploaded, will be uploaded and then call the _do_send_file
"""
if upload_result.isDuplicate():
self._do_send_file(file_path, upload_result.getUrl(), jid, upload_result.getIp())
else:
callback = lambda media_path, jid, url: self._do_send_file(media_path, url, jid, upload_result.getIp())
mediaUploader = MediaUploader(jid, self.interface_layer.getOwnJid(), file_path,
upload_result.getUrl(),
upload_result.getResumeOffset(),
callback, self._on_error, self._on_upload_progress, async=True)
mediaUploader.start()
示例8: _on_upload_result
def _on_upload_result(self,upload_result, requestUploadIqProtocolEntity, caption=None):
"""
If the file has never been uploaded, will be uploaded and then call the _do_send_file
"""
if upload_result.isDuplicate():
self._do_send_file(self.path, upload_result.getUrl(), self.jid, upload_result.getIp(), caption)
else:
callback = lambda file_path, jid, url: self._do_send_file(self.path, url, self.jid, upload_result.getIp(),
caption)
mediaUploader = MediaUploader(self.jid, self.interface_layer.getOwnJid(),self.path,
upload_result.getUrl(),
upload_result.getResumeOffset(),
callback, self._on_error, self._on_upload_progress, async=True)
mediaUploader.start()
示例9: on_request_upload_result
def on_request_upload_result(self, jid, file_path, result_entity, request_entity):
if result_entity.isDuplicate():
self.send_file(file_path, result_entity.getUrl(), jid, result_entity.getIp())
else:
uploader = MediaUploader(
jid, self.getOwnJid(),
file_path,
result_entity.getUrl(),
result_entity.getResumeOffset(),
self.on_upload_success,
self.on_upload_error,
self.on_upload_progress,
async=False
)
uploader.start()
示例10: onRequestUploadResult
def onRequestUploadResult(self, jid, filePath, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity, caption = None):
if requestUploadIqProtocolEntity.mediaType == RequestUploadIqProtocolEntity.MEDIA_TYPE_AUDIO:
doSendFn = self.doSendAudio
else:
doSendFn = self.doSendImage
if resultRequestUploadIqProtocolEntity.isDuplicate():
doSendFn(filePath, resultRequestUploadIqProtocolEntity.getUrl(), jid,
resultRequestUploadIqProtocolEntity.getIp(), caption)
else:
successFn = lambda filePath, jid, url: doSendFn(filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption)
mediaUploader = MediaUploader(jid, self.getOwnJid(), filePath,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
successFn, self.onUploadError, self.onUploadProgress, async=False)
mediaUploader.start()
示例11: onRequestUploadResult
def onRequestUploadResult(self, jid, fpath, successEntity, originalEntity):
if successEntity.isDuplicate():
url = successEntity.getUrl()
ip = successEntity.getIp()
print "<= WhatsApp: upload duplicate %s, from %s" % (fpath, url)
self.send_uploaded_media(fpath, jid, url, ip)
else:
ownjid = self._yowsup.getOwnJid()
mediaUploader = MediaUploader(jid, ownjid, fpath,
successEntity.getUrl(),
successEntity.getResumeOffset(),
self.onUploadSuccess,
self.onUploadError,
self.onUploadProgress,
async=False)
print "<= WhatsApp: start upload %s, into %s" \
% (fpath, successEntity.getUrl())
mediaUploader.start()
示例12: onRequestUploadResult
def onRequestUploadResult(self, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity, jid, path, oup):
print("Request ok")
#duplicate image will provide json data not found Exception error
if resultRequestUploadIqProtocolEntity.isDuplicate():
self.doSendImage(path,resultRequestUploadIqProtocolEntity.getUrl(),jid,resultRequestUploadIqProtocolEntity.getIp())
mediaUploader = MediaUploader(jid, self.getOwnJid(), path,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
self.onUploadSuccess, self.onUploadError, oup)
print("Duplicate Image found....")
else:
#successFn = lambda filePath, jid, url: self.uploadOk(mediaType, filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption)
mediaUploader = MediaUploader(jid, self.getOwnJid(), path,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
self.onUploadSuccess, self.onUploadError, oup)
mediaUploader.start()
print("Request ok upload complete")
示例13: onRequestUploadSuccess
def onRequestUploadSuccess(self, to, path, result, original, caption):
if result.isDuplicate():
# This image is already on WhatsApp servers
logger.info("The image %s is already on the WhatsApp server" %path)
self.imageSend(path, result.getUrl(), to, result.getIp(), caption)
else:
# We need to upload the image to WhatsApp servers
# The on success callback
successFn = lambda filePath, jid, url: self.onUploadSuccess(path, url, to,
result.getIp(),
caption)
# create the actual uploader
mediaUploader = MediaUploader(to, self.getOwnJid(), path,
result.getUrl(),
result.getResumeOffset(),
successFn,
self.onUploadError, #upload error
self.onUploadProgress, #upload progress
async=False)
# begin the upload
mediaUploader.start()
示例14: onRequestUploadResult
def onRequestUploadResult(self, receiver_jid, imagePath, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity):
mediaUploader = MediaUploader(self._image_upload_receiver_jid, self.getOwnJid(), imagePath,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
self.onUploadSuccess, self.onUploadError, self.onUploadProgress)
mediaUploader.start()