吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 11321|回复: 59
收起左侧

[其他原创] PotPlayer播放器在线字幕翻译-有道翻译-机器翻译版插件

  [复制链接]
XiaoPeng45 发表于 2025-5-30 13:04
在前人的基础上改动和增加了部分代码以支持有道翻译api


主要增加了下述代码
[Asm] 纯文本查看 复制代码
/*
生成uuid
*/
string generateUUID() {
    string randomStr = "" + HostGetTickCount();
    string md5Hash = HostHashMD5(randomStr); // 生成 MD5
    // 格式化为类似 UUID 的样式
    return md5Hash.substr(0, 8) + "-" + md5Hash.substr(8, 4) + "-" + md5Hash.substr(12, 4) + "-" + md5Hash.substr(16, 4) + "-" + md5Hash.substr(20, 12);
}


int daysInMonth(int year, int month) {
  if (month == 2) {
    return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) ? 29 : 28;
  } else if (month == 4 || month == 6 || month == 9 || month == 11) return 30;
  else return 31;
}

/*
获取当前时间戳(1748530654, 10位)
*/
string getCurtime() {
  datetime now;
  
  int year = now.get_year();

  int totalDays = 0;
  for (int y = 1970; y < year; y++) {
    totalDays += (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0) ? 366 : 365;
  }

  int month = now.get_month();
  for (int m = 1; m < month; m++) {
    totalDays += daysInMonth(year, m);
  }
  int day = now.get_day();

  totalDays += day - 1;

  int hour = now.get_hour();
  int minute = now.get_minute();
  int second = now.get_second();

  int totalSeconds = totalDays * 86400 + hour * 3600 + minute * 60 + second;
  string output_ = year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second;

  // return year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second;
  return "" + totalSeconds;
}

/*
用于生成sha256
*/
string getInput(const string &in input) {
  if (input.empty()) {
    return input;
  }

  uint inputLen = input.length();

  if (inputLen <= 20) {
    return input;
  } else {
    string prefix = input.substr(0, 10);
    string suffix = input.substr(inputLen - 10, 10);
    return prefix + "" + inputLen + suffix;
  }
}

/*
生成sha256
*/
string getSha256(const string &in str) {
  string hashResult = HostHashSHA256(str);
  return hashResult;
}

/*
解析翻译结果
*/
string JsonParseNew(string json) {
  JsonReader Reader;
  JsonValue Root;
  string ret = "";
  
  if (Reader.parse(json, Root) && Root.isObject()) {
    // JsonValue data = Root["data"];
    // if (data.isObject()) {

      JsonValue translations = Root["translation"];

      if (translations.isArray()) {
        for (int j = 0, len = translations.size(); j < len; j++) {
          JsonValue value1 = translations[j];
          ret = ret + value1.asString();
        }
      }
    // }
    if (Root["errorCode"].asString() != "0") ret = "errorCode:" + Root["errorCode"].asString();
  }

  return ret;
}



相关使用教程都在我的github或gitee中已说明
github: https://github.com/lp20010415/PotPlayer_Subtitle_Translate_Youdao
gitee: https://gitee.com/lp20010415/PotPlayer_Subtitle_Translate_Youdao




特别感谢前人!感恩!
前人本论坛链接: https://www.52pojie.cn/forum.php?mod=viewthread&tid=836477&highlight=PotPlayer%B2%A5%B7%C5%C6%F7%D4%DA%CF%DF%D7%D6%C4%BB%B7%AD%D2%EB

免费评分

参与人数 4吾爱币 +9 热心值 +4 收起 理由
Hrq3221 + 1 + 1 谢谢@Thanks!
bai1276 + 1 热心回复!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
lp-cg + 1 + 1 谢谢@Thanks!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

jiushancheng 发表于 2025-12-3 22:40
看日本电影能实时翻译吗,我有个朋友要学日语
 楼主| XiaoPeng45 发表于 2025-5-30 20:34
 楼主| XiaoPeng45 发表于 2025-6-2 03:15
W98 发表于 2025-6-1 23:13
Potplayer 有道翻译 怎么获取APP ID?

右键点击视频->字幕->在线字幕翻译->实时字幕翻译设置->选中有道翻译-> 点右边的 “账户设置”,会弹出一个对话框。
将在有道智云得到的“应用ID” 和 “应用秘钥”分别填进"App ID"和"密钥"进去,然后点确定,会再次弹出对话框,点击关闭就行了。

步骤1

步骤1

步骤2

步骤2

步骤3

步骤3
tein 发表于 2025-7-9 10:23
能输出字幕吗?还是只能实时显示?
付国兵123 发表于 2025-5-30 16:09
主要没看明白怎么使用。前面那贴也没看明白,没有找到 readme.md这个 文件。
 楼主| XiaoPeng45 发表于 2025-5-30 14:49
lp-cg 发表于 2025-5-30 14:37
感谢分享。晚上回去试一试

好的,感谢支持
1e3e 发表于 2025-5-30 16:06
不错,支持了
 楼主| XiaoPeng45 发表于 2025-5-30 20:33
本帖最后由 XiaoPeng45 于 2025-5-30 20:35 编辑
付国兵123 发表于 2025-5-30 16:09
主要没看明白怎么使用。前面那贴也没看明白,没有找到 readme.md这个 文件。

就是把.as那个和.ico文件放到potplayer根目录下的"Extension"文件夹中的"Subtitle"中的"Translate"里,然后重新打开potplayer,放一个视频,给它挂个字幕。而后右键视频,如图所示。
微信图片_20250530203224.png
xjl333 发表于 2025-5-31 23:09
有点复杂,支持一下
 楼主| XiaoPeng45 发表于 2025-6-1 17:53
xjl333 发表于 2025-5-31 23:09
有点复杂,支持一下

感谢支持
请问哪里觉得复杂呢?
Tinghe218 发表于 2025-6-1 21:30
收藏了,有空试一下,感谢楼主
W98 发表于 2025-6-1 23:13
Potplayer 有道翻译 怎么获取APP ID?
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-7-26 11:13

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表