summaryrefslogtreecommitdiffstats
path: root/bridge/telegram/handlers.go
diff options
context:
space:
mode:
authorBenau <Benau@users.noreply.github.com>2021-08-25 04:32:50 +0800
committerGitHub <noreply@github.com>2021-08-24 22:32:50 +0200
commit53cafa9f3d0c8be33821fc7338b1da97e91d9cc6 (patch)
tree964a225219099a1a1c282e27913767da588191b4 /bridge/telegram/handlers.go
parentd4195deb3a6305c49c50ff30e8af978c7f1bdd92 (diff)
downloadmatterbridge-msglm-53cafa9f3d0c8be33821fc7338b1da97e91d9cc6.tar.gz
matterbridge-msglm-53cafa9f3d0c8be33821fc7338b1da97e91d9cc6.tar.bz2
matterbridge-msglm-53cafa9f3d0c8be33821fc7338b1da97e91d9cc6.zip
Convert .tgs with go libraries (and cgo) (telegram) (#1569)
This commit adds support for go/cgo tgs conversion when building with the -tags `cgo` The default binaries are still "pure" go and uses the old way of converting. * Move lottie_convert.py conversion code to its own file * Add optional libtgsconverter * Update vendor * Apply suggestions from code review * Update bridge/helper/libtgsconverter.go Co-authored-by: Wim <wim@42.be>
Diffstat (limited to 'bridge/telegram/handlers.go')
-rw-r--r--bridge/telegram/handlers.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go
index a93c71bb..84881f7f 100644
--- a/bridge/telegram/handlers.go
+++ b/bridge/telegram/handlers.go
@@ -220,20 +220,10 @@ func (b *Btelegram) handleDownloadAvatar(userid int, channel string) {
}
func (b *Btelegram) maybeConvertTgs(name *string, data *[]byte) {
- var format string
- switch b.GetString("MediaConvertTgs") {
- case FormatWebp:
- b.Log.Debugf("Tgs to WebP conversion enabled, converting %v", name)
- format = FormatWebp
- case FormatPng:
- // The WebP to PNG converter can't handle animated webp files yet,
- // and I'm not going to write a path for x/image/webp.
- // The error message would be:
- // conversion failed: webp: non-Alpha VP8X is not implemented
- // So instead, we tell lottie to directly go to PNG.
- b.Log.Debugf("Tgs to PNG conversion enabled, converting %v", name)
- format = FormatPng
- default:
+ format := b.GetString("MediaConvertTgs")
+ if helper.SupportsFormat(format) {
+ b.Log.Debugf("Format supported by %s, converting %v", helper.LottieBackend(), name)
+ } else {
// Otherwise, no conversion was requested. Trying to run the usual webp
// converter would fail, because '.tgs.webp' is actually a gzipped JSON
// file, and has nothing to do with WebP.