diff --git a/octoprint_telegram/__init__.py b/octoprint_telegram/__init__.py index 922f573..2408dae 100644 --- a/octoprint_telegram/__init__.py +++ b/octoprint_telegram/__init__.py @@ -1211,24 +1211,6 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, message = "[ERR GET IMAGE]\n\n" + message image_data = None - r = None - - if image_data: - self._logger.debug("Sending with image.. " + str(chatID)) - files = {'photo':("image.jpg", image_data)} - self._logger.debug("files so far: " + str(files)) - if message is not "": - data['caption'] = message - r = requests.post(self.bot_url + "/sendPhoto", files=files, data=data) - - self._logger.debug("Sending finished. " + str(r.status_code)) - else: - self._logger.debug("Sending without image.. " + str(chatID)) - data['text'] = message - r =requests.post(self.bot_url + "/sendMessage", data=data) - self._logger.debug("Sending finished. " + str(r.status_code)) - - if with_image: try: files={} sendOneInLoop = False @@ -1252,10 +1234,10 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, self._logger.debug("Snapshot URL: " + str(snapshot_url)) if snapshot_url != self._settings.global_get(["webcam", "snapshot"]): - image_data = self.take_image(snapshot_url) - if image_data != "": + image_data2 = self.take_image(snapshot_url) + if image_data2 != "": self._logger.debug("Image for " + str(li.get("name"))) - files = {'photo':("image.jpg", image_data)} + files = {'photo':("image.jpg", image_data2)} data2 = data data2['caption'] = "" r = requests.post(self.bot_url + "/sendPhoto", files=files, data=data2) @@ -1271,6 +1253,24 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, except Exception as ex: self._logger.exception("Exception occured on getting multicam plugin: "+ str(ex) ) + r = None + + if image_data: + self._logger.debug("Sending with image.. " + str(chatID)) + files = {'photo':("image.jpg", image_data)} + self._logger.debug("files so far: " + str(files)) + if message is not "": + data['caption'] = message + r = requests.post(self.bot_url + "/sendPhoto", files=files, data=data) + + self._logger.debug("Sending finished. " + str(r.status_code)) + else: + self._logger.debug("Sending without image.. " + str(chatID)) + data['text'] = message + r =requests.post(self.bot_url + "/sendMessage", data=data) + self._logger.debug("Sending finished. " + str(r.status_code)) + + if r is not None and inline: r.raise_for_status() myJson = r.json() @@ -1560,6 +1560,8 @@ def create_gif_new(self,chatID,sec=7,multicam_prof=0): params.append( stream_url) params.append( '-t') params.append( timeSec) + params.append( '-pix_fmt') + params.append( 'yuv420p') #work on android but seems to be a problem on some Iphone #params.append( '-c:v') #params.append( 'mpeg4')