xiyuesaves / LiteLoaderQQNT-lite_tools

LiteLoaderQQNT 插件 - 轻量工具箱 —— 轻量 · 优雅 · 高效 · 福瑞
GNU General Public License v3.0
870 stars 30 forks source link

[Feat]: telegram的动画贴纸无法下载 #282

Closed jiongjiongJOJO closed 1 month ago

jiongjiongJOJO commented 1 month ago

需要调整的功能内容

通过api获取的贴纸是tgs格式的文件,实际上这个文件是一个lottie 的 json文件(经过了压缩),但是不太熟悉lottie,不知道该如何转换成gif,作者是否有考虑保存动画贴纸。或者外置程序来调用(类似ffmpeg)

xiyuesaves commented 1 month ago

没有考虑,目前的逻辑应该会自动忽略无法下载的贴纸类型

jiongjiongJOJO commented 1 month ago

没有考虑,目前的逻辑应该会自动忽略无法下载的贴纸类型

是的,但是这类贴纸能否转换成gif保存到本地

xiyuesaves commented 1 month ago

刚找到一个项目,可以将 lottie 转换成图片 lottie-converter 之后有空再说吧

jiongjiongJOJO commented 1 month ago

刚找到一个项目,可以将 lottie 转换成图片 lottie-converter 之后有空再说吧

这个是c++写的,还有python相关的库,但是没找到合适的js库。后续打算通过外置转换程序的方式还是js来实现这个?

xiyuesaves commented 1 month ago

就像ffmpeg那样外挂吧,没必要内置

jiongjiongJOJO commented 1 month ago

就像ffmpeg那样外挂吧,没必要内置

那我研究一下吧,之前用js没实现(对js和electron太不熟了),外挂的话可能简单很多

jiongjiongJOJO commented 1 month ago

就像ffmpeg那样外挂吧,没必要内置

看了一下lottie-converter,对用户而言部署是比较麻烦的,还要下载gifski https://github.com/ed-asriyan/lottie-converter/blob/778ba4931a027ba4462f69f53fe7f4f39d34f6e2/README.md?plain=1#L56 并添加环境变量。

是否有必要使用python的rlottie-python,这个可以封装一个小的执行文件,用起来也很简单

xiyuesaves commented 1 month ago

是否有必要使用python的rlottie-python,这个可以封装一个小的执行文件,用起来也很简单

如果能三端通用的话倒也是个不错的方法

jiongjiongJOJO commented 1 month ago

是否有必要使用python的rlottie-python,这个可以封装一个小的执行文件,用起来也很简单

如果能三端通用的话倒也是个不错的方法

可以开一个仓库,CI自动编译出来三端的可执行文件,我这边在Windows下测试的基本上通过了,还在改一些小问题 Clip_2024-07-04_16-18-24

jiongjiongJOJO commented 1 month ago

https://github.com/jiongjiongJOJO/tgs_to_gif 创建了一个仓库用于将tgs转换成gif,后续可以用这个项目编译的程序进行处理

xiyuesaves commented 1 month ago

https://github.com/jiongjiongJOJO/tgs_to_gif 创建了一个仓库用于将tgs转换成gif,后续可以用这个项目编译的程序进行处理

能否支持管道输入?我希望是直接将 JSON 数据直接以数据流形式发送给子进程,而不是在本地再创建一个临时文件

jiongjiongJOJO commented 1 month ago

jiongjiongJOJO/tgs_to_gif 创建了一个仓库用于将tgs转换成gif,后续可以用这个项目编译的程序进行处理

能否支持管道输入?我希望是直接将 JSON 数据直接以数据流形式发送给子进程,而不是在本地再创建一个临时文件

我本来也这样想的,但是测试后发现json文本太大了,命令行不支持

xiyuesaves commented 1 month ago

我本来也这样想的,但是测试后发现json文本太大了,命令行不支持

我的意思是指通过pipe传递数据,这是nodejs下的实现,我没用过py,不过应该都是差不多的

stdout.js

import { spawn } from "child_process";
import { readFileSync } from "fs";
import { Readable } from "stream";
const exampleStdin = spawn("node", ["./stdin.js"]);
const file = readFileSync("./large.json");
// 模拟下载到的二进制数据流
const inputStream = Readable.from(file);
exampleStdin.stdout.on("data", (data) => {
  console.log("子进程:", data.toString());
});

exampleStdin.stderr.on("data", (data) => {
  console.error("子进程错误:", data.toString());
});

exampleStdin.on("close", (code) => {
  console.log(`子进程退出,退出码 ${code}`);
});

inputStream.pipe(exampleStdin.stdin);

stdin.js

let file = "";

process.stdin.on("data", (data) => {
  console.log("接收到数据", data.length);
  file += data;
});

process.stdin.on("end", () => {
  console.log("接收结束,共收到", file.length, "个字符");
});

输出

E:\test>node stdout.js
子进程: 接收到数据 1756296

子进程: 接收结束,共收到 1744572 个字符

子进程退出,退出码 0
jiongjiongJOJO commented 1 month ago

我本来也这样想的,但是测试后发现json文本太大了,命令行不支持

我的意思是指通过pipe传递数据,这是nodejs下的实现,我没用过py,不过应该都是差不多的

stdout.js

import { spawn } from "child_process";
import { readFileSync } from "fs";
import { Readable } from "stream";
const exampleStdin = spawn("node", ["./stdin.js"]);
const file = readFileSync("./large.json");
// 模拟下载到的二进制数据流
const inputStream = Readable.from(file);
exampleStdin.stdout.on("data", (data) => {
  console.log("子进程:", data.toString());
});

exampleStdin.stderr.on("data", (data) => {
  console.error("子进程错误:", data.toString());
});

exampleStdin.on("close", (code) => {
  console.log(`子进程退出,退出码 ${code}`);
});

inputStream.pipe(exampleStdin.stdin);

stdin.js

let file = "";

process.stdin.on("data", (data) => {
  console.log("接收到数据", data.length);
  file += data;
});

process.stdin.on("end", () => {
  console.log("接收结束,共收到", file.length, "个字符");
});

输出

E:\test>node stdout.js
子进程: 接收到数据 1756296

子进程: 接收结束,共收到 1744572 个字符

子进程退出,退出码 0

这一块我也不是很熟,周末有空看看吧,看这个示例应该是可以的

Wfgukasha commented 1 month ago

值得一试的想法

囧囧JOJO @.***> 于 2024年7月5日周五 14:06写道:

我本来也这样想的,但是测试后发现json文本太大了,命令行不支持

我的意思是指通过pipe传递数据,这是nodejs下的实现,我没用过py,不过应该都是差不多的

stdout.js

import { spawn } from "child_process";import { readFileSync } from "fs";import { Readable } from "stream";const exampleStdin = spawn("node", ["./stdin.js"]);const file = readFileSync("./large.json");// 模拟下载到的二进制数据流const inputStream = Readable.from(file);exampleStdin.stdout.on("data", (data) => { console.log("子进程:", data.toString());}); exampleStdin.stderr.on("data", (data) => { console.error("子进程错误:", data.toString());}); exampleStdin.on("close", (code) => { console.log(子进程退出,退出码 ${code});}); inputStream.pipe(exampleStdin.stdin);

stdin.js

let file = ""; process.stdin.on("data", (data) => { console.log("接收到数据", data.length); file += data;}); process.stdin.on("end", () => { console.log("接收结束,共收到", file.length, "个字符");});

输出

E:\test>node stdout.js 子进程: 接收到数据 1756296

子进程: 接收结束,共收到 1744572 个字符

子进程退出,退出码 0

这一块我也不是很熟,周末有空看看吧,看这个示例应该是可以的

— Reply to this email directly, view it on GitHub https://github.com/xiyuesaves/LiteLoaderQQNT-lite_tools/issues/282#issuecomment-2210237792, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGZ3QBIO7C7UPCHYSMQQ7B3ZKYZUVAVCNFSM6AAAAABKKSM72OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJQGIZTONZZGI . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>

jiongjiongJOJO commented 1 month ago

我本来也这样想的,但是测试后发现json文本太大了,命令行不支持

我的意思是指通过pipe传递数据,这是nodejs下的实现,我没用过py,不过应该都是差不多的

stdout.js

import { spawn } from "child_process";
import { readFileSync } from "fs";
import { Readable } from "stream";
const exampleStdin = spawn("node", ["./stdin.js"]);
const file = readFileSync("./large.json");
// 模拟下载到的二进制数据流
const inputStream = Readable.from(file);
exampleStdin.stdout.on("data", (data) => {
  console.log("子进程:", data.toString());
});

exampleStdin.stderr.on("data", (data) => {
  console.error("子进程错误:", data.toString());
});

exampleStdin.on("close", (code) => {
  console.log(`子进程退出,退出码 ${code}`);
});

inputStream.pipe(exampleStdin.stdin);

stdin.js

let file = "";

process.stdin.on("data", (data) => {
  console.log("接收到数据", data.length);
  file += data;
});

process.stdin.on("end", () => {
  console.log("接收结束,共收到", file.length, "个字符");
});

输出

E:\test>node stdout.js
子进程: 接收到数据 1756296

子进程: 接收结束,共收到 1744572 个字符

子进程退出,退出码 0

这个方案的pr已经提交了,同时jiongjiongJOJO/tgs_to_gif仓库的代码也已经更新,但是我这个月github action免费额度用完了,可能编译不了Windows和Mac端的了,或者我用小号编译完手动上传进来