Skip to content

Commit

Permalink
add pix format to try to fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
giloser committed Nov 13, 2020
1 parent 328fbb3 commit ace9b75
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions octoprint_telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit ace9b75

Please sign in to comment.