├── .gitignore
├── LICENSE
├── README.md
├── SubtitleTranslate - DeepL.as
└── SubtitleTranslate - DeepL.ico
/.gitignore:
--------------------------------------------------------------------------------
1 | ### C++ ###
2 | # Prerequisites
3 | *.d
4 |
5 | # Compiled Object files
6 | *.slo
7 | *.lo
8 | *.o
9 | *.obj
10 |
11 | # Precompiled Headers
12 | *.gch
13 | *.pch
14 |
15 | # Compiled Dynamic libraries
16 | *.so
17 | *.dylib
18 | *.dll
19 |
20 | # Fortran module files
21 | *.mod
22 | *.smod
23 |
24 | # Compiled Static libraries
25 | *.lai
26 | *.la
27 | *.a
28 | *.lib
29 |
30 | # Executables
31 | *.exe
32 | *.out
33 | *.app
34 |
35 | ### Linux ###
36 | *~
37 |
38 | # temporary files which can be created if a process still has a handle open of a deleted file
39 | .fuse_hidden*
40 |
41 | # KDE directory preferences
42 | .directory
43 |
44 | # Linux trash folder which might appear on any partition or disk
45 | .Trash-*
46 |
47 | # .nfs files are created when an open file is removed but is still being accessed
48 | .nfs*
49 |
50 | ### Vim ###
51 | # Swap
52 | [._]*.s[a-v][a-z]
53 | !*.svg # comment out if you don't need vector files
54 | [._]*.sw[a-p]
55 | [._]s[a-rt-v][a-z]
56 | [._]ss[a-gi-z]
57 | [._]sw[a-p]
58 |
59 | # Session
60 | Session.vim
61 | Sessionx.vim
62 |
63 | # Temporary
64 | .netrwhist
65 | # Auto-generated tag files
66 | tags
67 | # Persistent undo
68 | [._]*.un~
69 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 donaldturinglee
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Potplayer Subtitle Translate - DeepL
4 |
5 |
6 | Integrate DeepL for real-time translation of PotPlayer subtitles
7 |
8 | View Demo
9 |
10 | Report Bug
11 |
12 | Request Feature
13 |
14 |
15 |
16 |
17 |
18 | Table of Contents
19 |
20 | -
21 | About The Project
22 |
23 | -
24 | Getting Started
25 |
29 |
30 | - Usage
31 | - Contributing
32 | - License
33 | - Contact
34 |
35 |
36 |
37 |
38 |
39 | ## About The Project
40 |
41 | This project is a plugin for PotPlayer that enables subtitle translation via DeepL. It's designed to enhance your viewing experience by providing real-time, accurate translations of subtitles. The plugin leverages the advanced machine learning capabilities of DeepL to deliver high-quality translations, making it easier for users to enjoy media in various languages.
42 |
43 | (back to top)
44 |
45 |
46 |
47 | ## Getting Started
48 |
49 | ### Prerequisites
50 |
51 | - [DeepLX](https://github.com/OwO-Network/DeepLX)
52 |
53 | ### Installation
54 |
55 | 1. clone repo to local
56 |
57 | ```
58 | git clone https://github.com/donaldturinglee/potplayer_subtitle_translate_deepl.git
59 | ```
60 |
61 | 2. Copy file
62 |
63 | ```
64 | cp potplayer_subtitle_translate_deepl/*.{as,ico} your_directory/PotPlayer/Extension/Subtitle/Translate/
65 | ```
66 |
67 | 3. Set the server URL in the subtitles realtime translation configuration on PotPlayer
68 |
69 | 4. Enjoy it
70 |
71 | (back to top)
72 |
73 |
74 |
75 | ## Usage
76 |
77 | [Potplayer Subtitle Translate DeepL User Guide](https://youtu.be/IyuGmyAgLGA)
78 |
79 | (back to top)
80 |
81 |
82 | ## Contributing
83 |
84 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
85 |
86 | If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
87 | Don't forget to give the project a star! Thanks again!
88 |
89 | 1. Fork the Project
90 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
91 | 3. Commit your Changes (`git commit -m 'feat: Add some AmazingFeature'`)
92 | 4. Push to the Branch (`git push origin feature/AmazingFeature`)
93 | 5. Open a Pull Request
94 |
95 | (back to top)
96 |
97 |
98 |
99 | ## License
100 |
101 | Distributed under the MIT License. See `LICENSE` for more information.
102 |
103 | (back to top)
104 |
105 |
106 |
107 | ## Contact
108 |
109 | Twitter - [@Donald Lee](https://twitter.com/donaldturinglee)
110 |
111 | Project Link: [https://github.com/donaldturinglee/potplayer_subtitle_translate_deepl](https://github.com/donaldturinglee/potplayer_subtitle_translate_deepl)
112 |
113 | (back to top)
114 |
--------------------------------------------------------------------------------
/SubtitleTranslate - DeepL.as:
--------------------------------------------------------------------------------
1 | /*
2 | real time subtitle translate for PotPlayer using DeepL
3 | */
4 |
5 | // void OnInitialize()
6 | // void OnFinalize()
7 | // string GetTitle() -> get title for UI
8 | // string GetVersion -> get version for manage
9 | // string GetDesc() -> get detail information
10 | // string GetLoginTitle() -> get title for login dialog
11 | // string GetLoginDesc() -> get desc for login dialog
12 | // string GetUserText() -> get user text for login dialog
13 | // string GetPasswordText() -> get password text for login dialog
14 | // string ServerLogin(string User, string Pass) -> login
15 | // string ServerLogout() -> logout
16 | //------------------------------------------------------------------------------------------------
17 | // array GetSrcLangs() -> get source language
18 | // array GetDstLangs() -> get target language
19 | // string Translate(string Text, string &in SrcLang, string &in DstLang) -> do translate !!
20 |
21 | string JsonParse(string json) {
22 | JsonReader Reader;
23 | JsonValue Root;
24 | string ret = "";
25 |
26 | if (Reader.parse(json, Root) && Root.isObject()) {
27 | JsonValue translation = Root["data"];
28 | if(translation.isString()) {
29 | ret = translation.asString();
30 | }
31 | }
32 | return ret;
33 | }
34 |
35 | array LangTable = {
36 | "af",
37 | "sq",
38 | "am",
39 | "ar",
40 | "hy",
41 | "az",
42 | "eu",
43 | "be",
44 | "bn",
45 | "bs",
46 | "bg",
47 | "my",
48 | "ca",
49 | "ceb",
50 | "ny",
51 | "zh",
52 | "co",
53 | "hr",
54 | "cs",
55 | "da",
56 | "nl",
57 | "en",
58 | "eo",
59 | "et",
60 | "tl",
61 | "fi",
62 | "fr",
63 | "fy",
64 | "gl",
65 | "ka",
66 | "de",
67 | "el",
68 | "gu",
69 | "ht",
70 | "ha",
71 | "haw",
72 | "iw",
73 | "hi",
74 | "hmn",
75 | "hu",
76 | "is",
77 | "ig",
78 | "id",
79 | "ga",
80 | "it",
81 | "ja",
82 | "jw",
83 | "kn",
84 | "kk",
85 | "km",
86 | "ko",
87 | "ku",
88 | "ky",
89 | "lo",
90 | "la",
91 | "lv",
92 | "lt",
93 | "lb",
94 | "mk",
95 | "ms",
96 | "mg",
97 | "ml",
98 | "mt",
99 | "mi",
100 | "mr",
101 | "mn",
102 | "my",
103 | "ne",
104 | "no",
105 | "ps",
106 | "fa",
107 | "pl",
108 | "pt",
109 | "pa",
110 | "ro",
111 | "romanji",
112 | "ru",
113 | "sm",
114 | "gd",
115 | "sr",
116 | "st",
117 | "sn",
118 | "sd",
119 | "si",
120 | "sk",
121 | "sl",
122 | "so",
123 | "es",
124 | "su",
125 | "sw",
126 | "sv",
127 | "tg",
128 | "ta",
129 | "te",
130 | "th",
131 | "tr",
132 | "uk",
133 | "ur",
134 | "uz",
135 | "vi",
136 | "cy",
137 | "xh",
138 | "yi",
139 | "yo",
140 | "zu"
141 | };
142 |
143 | string UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
144 |
145 | string GetTitle() {
146 | return "{$CP950=DeepL 翻譯$}{$CP0=DeepL translate$}";
147 | }
148 |
149 | string GetVersion() {
150 | return "1";
151 | }
152 |
153 | string GetDesc() {
154 | return "https://www.deepl.com/";
155 | }
156 |
157 | string GetLoginTitle() {
158 | return "";
159 | }
160 |
161 | string GetLoginDesc() {
162 | return "";
163 | }
164 |
165 | string GetUserText() {
166 | return "Server URL: ";
167 | }
168 |
169 | string GetPasswordText() {
170 | return "";
171 | }
172 |
173 | string server_url;
174 |
175 | string ServerLogin(string User, string Pass) {
176 | server_url = User;
177 | if (server_url.empty()) server_url = "your_server_url";
178 | return "200 ok";
179 | }
180 |
181 | void ServerLogout() {
182 | server_url = "";
183 | }
184 |
185 | array GetSrcLangs() {
186 | array ret = LangTable;
187 |
188 | ret.insertAt(0, ""); // empty is auto
189 | return ret;
190 | }
191 |
192 | array GetDstLangs() {
193 | array ret = LangTable;
194 |
195 | return ret;
196 | }
197 |
198 | string Translate(string Text, string &in SrcLang, string &in DstLang) {
199 |
200 |
201 |
202 | string url = server_url;
203 |
204 | Text.replace("\\","\\\\");
205 | Text.replace("\"","\\\"");
206 | Text.replace("\n","\\\\n");
207 | Text.replace("\r","\\\\r");
208 | Text.replace("\t","\\\\t");
209 |
210 | dictionary dict = {
211 | {'text', Text},
212 | {'source_lang', SrcLang},
213 | {'target_lang', DstLang}
214 | };
215 |
216 | string data = "{";
217 | data += DictionaryToString(dict);
218 | data += "}";
219 |
220 | string header = "Content-Type: application/json";
221 |
222 | string text = HostUrlGetStringWithAPI(url, UserAgent, header, data);
223 |
224 | string ret = JsonParse(text);
225 |
226 | if (ret.length() > 0) {
227 | SrcLang = "UTF8";
228 | DstLang = "UTF8";
229 | return ret;
230 | }
231 |
232 | return ret;
233 | }
234 |
235 | string DictionaryToString(dictionary dict) {
236 | array keys = dict.getKeys();
237 | uint length = keys.length();
238 | array pairs(length);
239 | for (uint i = 0; i < length; i++) {
240 | string key = keys[i];
241 | string value = string(dict[key]);
242 | pairs[i] = '"' + key + "\":\"" + value + '"';
243 | }
244 | string jsonString = join(pairs, ',');
245 | return jsonString;
246 | }
--------------------------------------------------------------------------------
/SubtitleTranslate - DeepL.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/donaldturinglee/potplayer_subtitle_translate_deepl/3069b2c563de8dec8c03d9be3f6eb6b2c33a08db/SubtitleTranslate - DeepL.ico
--------------------------------------------------------------------------------