-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Telegram animated stickers (tgs) format #1173
Conversation
Suggested wiki page: https://github.com/42wim/matterbridge/wiki/Settings
|
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
I disagree with the linter.
|
The reason it complains is because Go supports this: func thisPanicsAndRecovers() (err error) {
defer func() {
message := recover()
fmt.Println("Recovered from this panic:", message)
}()
err = errors.New("Some fake error")
panic("aaaaa thisPanicsAndRecovers")
} In the above code, the deferred function will get called when
Now see this code: func someError() error {
return errors.New("Error from if statement")
}
func thisPanicsAndRecoversFailingLint() (err error) {
defer func() {
message := recover()
fmt.Println("Recovered from this panic:", message)
}()
err = errors.New("Some fake error")
if err := someError(); err != nil {
panic("noooooo")
}
panic("aaaaa")
} One might expect the
But it doesn't, the if statement creates a brand new
You can try it out here: https://play.golang.org/p/Y-OaeUn03-J The solution is to call it |
Yeah, this one is weird. I have no idea. |
Thank you @qaisjp for the explanation, I totally forgot about the auto-returned variable :) I'll update the code soon-ish. |
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
Updated. (And rebased for convenience.) Now the only remaining problem is this linter false-positive: |
|
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
Nice, I wasn't aware of that syntax. Pushed it. |
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
Yeah so this uses interfacer:
And it looks like wim has just turned it off 2a41abb (1 hr after your last push) So I guess just make another force push and |
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
@BenWiederhake First off sorry for the delay and thank you for this PR. This is a tricky one wrt the external dependency. I'm fine with adding this feature with a few changes:
What do you think? |
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
This is half a fix for 42wim#874 This patch introduces two new config flags: - MediaConvertTgsToWebP - MediaConvertTgsToPNG These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an *animated* WebP, and the WebP→PNG converter can't handle animated WebP files yet. Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs). The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this: $ pip3 install lottie cairosvg This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several seconds!), and then deleting the temporary file. The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files. If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired. I will propose new text for the Wiki in the PR for this patch. (Should be 42wim#1173 or so.)
Updated, and rebased for convenience. Suggested wiki page: https://github.com/42wim/matterbridge/wiki/Settings
|
LGTM, thanks! |
I've added your change to the wiki |
this was buried and wanted to bring it up in the config Convert Tgs (Telegram animated sticker) images to PNG before upload. This is useful when your bridge also contains platforms that do not support animated WebP files, like Discord. This requires the external dependency `lottie`, which can be installed like this: `pip install lottie cairosvg` #874 #1173
This is half a fix for #874
This patch introduces two new config flags:
These need to be treated independently from the existing MediaConvertWebPToPNG flag because Tgs→WebP results in an animated WebP, and the WebP→PNG converter can't handle animated WebP files yet.
Furthermore, some platforms (like discord) don't even support animated WebP files, so the user may want to fall back to static PNGs (not APNGs).
The final reason why this is only half a fix is that this introduces an external dependency, namely lottie, to be installed like this:
This patch works by writing the tgs to a temporary file in /tmp, calling lottie to convert it (this conversion may take several econds!), and then deleting the temporary file.
The temporary file is absolutely necessary, as lottie refuses to work on non-seekable files.
If anyone comes up with a reasonable use case where /tmp is unavailable, I can add yet another config option for that, if desired.
Here's a screenshot of Discord, with
MediaConvertTgsToPNG=true
:As this requires new text in the Wiki, I'll post some suggestions below.