sticker-convert 2.10.9__py3-none-any.whl → 2.11.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- sticker_convert/cli.py +39 -1
- sticker_convert/converter.py +8 -5
- sticker_convert/downloaders/download_base.py +3 -3
- sticker_convert/downloaders/download_signal.py +4 -2
- sticker_convert/downloaders/download_telegram.py +19 -103
- sticker_convert/gui.py +12 -0
- sticker_convert/gui_components/frames/cred_frame.py +38 -13
- sticker_convert/job.py +6 -6
- sticker_convert/job_option.py +6 -0
- sticker_convert/resources/compression.json +2 -2
- sticker_convert/resources/help.json +3 -2
- sticker_convert/resources/input.json +10 -0
- sticker_convert/resources/output.json +16 -0
- sticker_convert/uploaders/upload_telegram.py +170 -234
- sticker_convert/utils/auth/telegram_api.py +668 -0
- sticker_convert/utils/auth/telethon_setup.py +79 -0
- sticker_convert/utils/url_detect.py +1 -1
- sticker_convert/version.py +1 -1
- {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.0.dist-info}/METADATA +49 -31
- {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.0.dist-info}/RECORD +24 -22
- {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.0.dist-info}/LICENSE +0 -0
- {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.0.dist-info}/WHEEL +0 -0
- {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.0.dist-info}/entry_points.txt +0 -0
- {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.0.dist-info}/top_level.txt +0 -0
sticker_convert/cli.py
CHANGED
@@ -20,6 +20,7 @@ from sticker_convert.utils.auth.get_kakao_desktop_auth import GetKakaoDesktopAut
|
|
20
20
|
from sticker_convert.utils.auth.get_line_auth import GetLineAuth
|
21
21
|
from sticker_convert.utils.auth.get_signal_auth import GetSignalAuth
|
22
22
|
from sticker_convert.utils.auth.get_viber_auth import GetViberAuth
|
23
|
+
from sticker_convert.utils.auth.telethon_setup import TelethonSetup
|
23
24
|
from sticker_convert.utils.callback import Callback
|
24
25
|
from sticker_convert.utils.files.json_manager import JsonManager
|
25
26
|
from sticker_convert.utils.url_detect import UrlDetect
|
@@ -168,10 +169,12 @@ class CLI:
|
|
168
169
|
parser_cred = parser.add_argument_group("Credentials options")
|
169
170
|
flags_cred_bool = (
|
170
171
|
"signal_get_auth",
|
172
|
+
"telethon_setup",
|
171
173
|
"kakao_get_auth",
|
172
174
|
"kakao_get_auth_desktop",
|
173
175
|
"line_get_auth",
|
174
176
|
"discord_get_auth",
|
177
|
+
"save_cred",
|
175
178
|
)
|
176
179
|
for k, v in self.help["cred"].items():
|
177
180
|
keyword_args = {}
|
@@ -226,6 +229,7 @@ class CLI:
|
|
226
229
|
"signal": args.download_signal,
|
227
230
|
"line": args.download_line,
|
228
231
|
"telegram": args.download_telegram,
|
232
|
+
"telegram_telethon": args.download_telegram_telethon,
|
229
233
|
"kakao": args.download_kakao,
|
230
234
|
"viber": args.download_viber,
|
231
235
|
"discord": args.download_discord,
|
@@ -266,6 +270,14 @@ class CLI:
|
|
266
270
|
export_option = "signal"
|
267
271
|
elif args.export_telegram:
|
268
272
|
export_option = "telegram"
|
273
|
+
elif args.export_telegram_emoji:
|
274
|
+
export_option = "telegram_emoji"
|
275
|
+
elif args.export_telegram_telethon:
|
276
|
+
export_option = "telegram_telethon"
|
277
|
+
elif args.export_telegram_emoji_telethon:
|
278
|
+
export_option = "telegram_emoji_telethon"
|
279
|
+
elif args.export_viber:
|
280
|
+
export_option = "viber"
|
269
281
|
elif args.export_imessage:
|
270
282
|
export_option = "imessage"
|
271
283
|
else:
|
@@ -291,6 +303,10 @@ class CLI:
|
|
291
303
|
args.export_whatsapp,
|
292
304
|
args.export_signal,
|
293
305
|
args.export_telegram,
|
306
|
+
args.export_telegram_emoji,
|
307
|
+
args.export_telegram_telethon,
|
308
|
+
args.export_telegram_emoji_telethon,
|
309
|
+
args.export_viber,
|
294
310
|
args.export_imessage,
|
295
311
|
)
|
296
312
|
)
|
@@ -302,8 +318,12 @@ class CLI:
|
|
302
318
|
preset = "whatsapp"
|
303
319
|
elif args.export_signal:
|
304
320
|
preset = "signal"
|
305
|
-
elif args.export_telegram:
|
321
|
+
elif args.export_telegram or args.export_telegram_telethon:
|
306
322
|
preset = "telegram"
|
323
|
+
elif args.export_telegram_emoji or args.export_telegram_emoji_telethon:
|
324
|
+
preset = "telegram_emoji"
|
325
|
+
elif args.export_viber:
|
326
|
+
preset = "viber"
|
307
327
|
elif args.export_imessage:
|
308
328
|
preset = "imessage_small"
|
309
329
|
elif args.preset == "auto":
|
@@ -316,6 +336,12 @@ class CLI:
|
|
316
336
|
self.cb.msg(
|
317
337
|
"Auto compression option set to no_compress (Reason: Export to local directory only)"
|
318
338
|
)
|
339
|
+
elif "telegram_emoji" in output_option:
|
340
|
+
preset = "telegram_emoji"
|
341
|
+
self.cb.msg(f"Auto compression option set to {preset}")
|
342
|
+
elif "telegram" in output_option:
|
343
|
+
preset = "telegram"
|
344
|
+
self.cb.msg(f"Auto compression option set to {preset}")
|
319
345
|
elif output_option == "imessage":
|
320
346
|
preset = "imessage_small"
|
321
347
|
self.cb.msg(f"Auto compression option set to {preset}")
|
@@ -445,6 +471,8 @@ class CLI:
|
|
445
471
|
telegram_userid=args.telegram_userid
|
446
472
|
if args.telegram_userid
|
447
473
|
else creds.get("telegram", {}).get("userid"),
|
474
|
+
telethon_api_id=creds.get("telethon", {}).get("api_id"),
|
475
|
+
telethon_api_hash=creds.get("telethon", {}).get("api_hash"),
|
448
476
|
kakao_auth_token=args.kakao_auth_token
|
449
477
|
if args.kakao_auth_token
|
450
478
|
else creds.get("kakao", {}).get("auth_token"),
|
@@ -511,6 +539,16 @@ class CLI:
|
|
511
539
|
|
512
540
|
self.cb.msg("Failed to get uuid and password")
|
513
541
|
|
542
|
+
if args.telethon_setup:
|
543
|
+
telethon_setup = TelethonSetup(opt_cred, self.cb.ask_str)
|
544
|
+
success, _, telethon_api_id, telethon_api_hash = telethon_setup.start()
|
545
|
+
|
546
|
+
if success:
|
547
|
+
opt_cred.telethon_api_id = telethon_api_id
|
548
|
+
opt_cred.telethon_api_hash = telethon_api_hash
|
549
|
+
|
550
|
+
self.cb.msg("Telethon setup successful")
|
551
|
+
|
514
552
|
if args.line_get_auth:
|
515
553
|
get_line_auth = GetLineAuth()
|
516
554
|
|
sticker_convert/converter.py
CHANGED
@@ -434,7 +434,7 @@ class StickerConvert:
|
|
434
434
|
# Pillow is not reliable for getting webp frame durations
|
435
435
|
durations: Optional[List[int]]
|
436
436
|
if im.format == "WEBP":
|
437
|
-
_, _, _, durations = CodecInfo._get_file_fps_frames_duration_webp(
|
437
|
+
_, _, _, durations = CodecInfo._get_file_fps_frames_duration_webp( # type: ignore
|
438
438
|
self.in_f
|
439
439
|
)
|
440
440
|
else:
|
@@ -764,7 +764,7 @@ class StickerConvert:
|
|
764
764
|
format=self.out_f.suffix.replace(".", ""),
|
765
765
|
options=options_container,
|
766
766
|
) as output:
|
767
|
-
out_stream = output.add_stream(codec, rate=self.fps, options=options_stream)
|
767
|
+
out_stream = output.add_stream(codec, rate=self.fps, options=options_stream) # type: ignore
|
768
768
|
out_stream = cast(VideoStream, out_stream)
|
769
769
|
assert isinstance(self.res_w, int) and isinstance(self.res_h, int)
|
770
770
|
out_stream.width = self.res_w
|
@@ -811,9 +811,12 @@ class StickerConvert:
|
|
811
811
|
elif self.out_f.suffix == ".webp":
|
812
812
|
im_out = [Image.fromarray(i) for i in self.frames_processed] # type: ignore
|
813
813
|
extra_kwargs["format"] = "WebP"
|
814
|
-
|
815
|
-
|
816
|
-
|
814
|
+
extra_kwargs["allow_mixed"] = True
|
815
|
+
if self.quality:
|
816
|
+
if self.quality < 20:
|
817
|
+
extra_kwargs["minimize_size"] = True
|
818
|
+
extra_kwargs["method"] = 4 + int(2 * (100 - self.quality) / 100)
|
819
|
+
extra_kwargs["alpha_quality"] = self.quality
|
817
820
|
else:
|
818
821
|
raise RuntimeError(f"Invalid format {self.out_f.suffix}")
|
819
822
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
3
3
|
|
4
4
|
from functools import partial
|
5
5
|
from pathlib import Path
|
6
|
-
from typing import Any, List, Optional, Tuple
|
6
|
+
from typing import Any, Dict, List, Optional, Tuple
|
7
7
|
|
8
8
|
import anyio
|
9
9
|
import httpx
|
@@ -34,8 +34,8 @@ class DownloadBase:
|
|
34
34
|
retries: int = 3,
|
35
35
|
headers: Optional[dict[Any, Any]] = None,
|
36
36
|
**kwargs: Any,
|
37
|
-
) ->
|
38
|
-
results:
|
37
|
+
) -> Dict[str, bool]:
|
38
|
+
results: Dict[str, bool] = {}
|
39
39
|
anyio.run(
|
40
40
|
partial(
|
41
41
|
self.download_multiple_files_async,
|
@@ -63,11 +63,13 @@ class DownloadSignal(DownloadBase):
|
|
63
63
|
)
|
64
64
|
|
65
65
|
def download_stickers_signal(self) -> Tuple[int, int]:
|
66
|
-
if "signal.art" not in self.url
|
66
|
+
if "signal.art" not in self.url or not self.url.startswith(
|
67
|
+
"sgnl://addstickers/"
|
68
|
+
):
|
67
69
|
self.cb.put("Download failed: Unrecognized URL format")
|
68
70
|
return 0, 0
|
69
71
|
|
70
|
-
pack_id = self.url.split("
|
72
|
+
pack_id = self.url.split("pack_id=")[1].split("&pack_key=")[0]
|
71
73
|
pack_key = self.url.split("&pack_key=")[1]
|
72
74
|
|
73
75
|
try:
|
@@ -1,15 +1,13 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
from pathlib import Path
|
3
|
-
from typing import
|
3
|
+
from typing import Optional, Tuple
|
4
4
|
from urllib.parse import urlparse
|
5
5
|
|
6
6
|
import anyio
|
7
|
-
from telegram import PhotoSize, Sticker, StickerSet
|
8
|
-
from telegram.error import TelegramError
|
9
|
-
from telegram.ext import AIORateLimiter, ApplicationBuilder
|
10
7
|
|
11
8
|
from sticker_convert.downloaders.download_base import DownloadBase
|
12
9
|
from sticker_convert.job_option import CredOption, InputOption
|
10
|
+
from sticker_convert.utils.auth.telegram_api import BotAPI, TelegramAPI, TelethonAPI
|
13
11
|
from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
|
14
12
|
from sticker_convert.utils.files.metadata_handler import MetadataHandler
|
15
13
|
|
@@ -19,114 +17,32 @@ class DownloadTelegram(DownloadBase):
|
|
19
17
|
# super().__init__(*args, **kwargs)
|
20
18
|
|
21
19
|
def download_stickers_telegram(self) -> Tuple[int, int]:
|
22
|
-
self.token = ""
|
23
|
-
|
24
|
-
if self.opt_cred:
|
25
|
-
self.token = self.opt_cred.telegram_token.strip()
|
26
|
-
if not self.token:
|
27
|
-
self.cb.put("Download failed: Token required for downloading from telegram")
|
28
|
-
return 0, 0
|
29
|
-
|
30
20
|
if not ("telegram.me" in self.url or "t.me" in self.url):
|
31
21
|
self.cb.put("Download failed: Unrecognized URL format")
|
32
22
|
return 0, 0
|
33
23
|
|
34
|
-
self.title = Path(urlparse(self.url).path).name
|
35
|
-
|
36
|
-
self.emoji_dict: Dict[str, str] = {}
|
37
|
-
|
38
24
|
return anyio.run(self.save_stickers)
|
39
25
|
|
40
26
|
async def save_stickers(self) -> Tuple[int, int]:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
.
|
49
|
-
|
50
|
-
.write_timeout(timeout)
|
51
|
-
.connection_pool_size(20)
|
52
|
-
.build()
|
53
|
-
)
|
54
|
-
|
55
|
-
async with application:
|
56
|
-
bot = application.bot
|
57
|
-
try:
|
58
|
-
sticker_set: StickerSet = await bot.get_sticker_set(
|
59
|
-
self.title,
|
60
|
-
read_timeout=timeout,
|
61
|
-
write_timeout=timeout,
|
62
|
-
connect_timeout=timeout,
|
63
|
-
pool_timeout=timeout,
|
64
|
-
)
|
65
|
-
except TelegramError as e:
|
66
|
-
self.cb.put(
|
67
|
-
f"Failed to download telegram sticker set {self.title} due to: {e}"
|
68
|
-
)
|
69
|
-
return 0, 0
|
70
|
-
|
71
|
-
self.cb.put(
|
72
|
-
(
|
73
|
-
"bar",
|
74
|
-
None,
|
75
|
-
{
|
76
|
-
"set_progress_mode": "determinate",
|
77
|
-
"steps": len(sticker_set.stickers),
|
78
|
-
},
|
79
|
-
)
|
80
|
-
)
|
81
|
-
|
82
|
-
async def download_sticker(
|
83
|
-
sticker: Union[PhotoSize, Sticker], f_id: str, results: dict[str, bool]
|
84
|
-
) -> None:
|
85
|
-
try:
|
86
|
-
sticker_file = await sticker.get_file(
|
87
|
-
read_timeout=timeout,
|
88
|
-
write_timeout=timeout,
|
89
|
-
connect_timeout=timeout,
|
90
|
-
pool_timeout=timeout,
|
91
|
-
)
|
92
|
-
except TelegramError as e:
|
93
|
-
self.cb.put(f"Failed to download {f_id}: {str(e)}")
|
94
|
-
results[f_id] = False
|
95
|
-
return
|
96
|
-
fpath = sticker_file.file_path
|
97
|
-
assert fpath is not None
|
98
|
-
ext = Path(fpath).suffix
|
99
|
-
f_name = f_id + ext
|
100
|
-
f_path = Path(self.out_dir, f_name)
|
101
|
-
await sticker_file.download_to_drive(
|
102
|
-
custom_path=f_path,
|
103
|
-
read_timeout=timeout,
|
104
|
-
write_timeout=timeout,
|
105
|
-
connect_timeout=timeout,
|
106
|
-
pool_timeout=timeout,
|
107
|
-
)
|
108
|
-
if isinstance(sticker, Sticker) and sticker.emoji is not None:
|
109
|
-
self.emoji_dict[f_id] = sticker.emoji
|
110
|
-
self.cb.put(f"Downloaded {f_name}")
|
111
|
-
results[f_id] = True
|
112
|
-
if f_id != "cover":
|
113
|
-
self.cb.put("update_bar")
|
114
|
-
|
115
|
-
async with anyio.create_task_group() as tg:
|
116
|
-
for num, sticker in enumerate(sticker_set.stickers):
|
117
|
-
f_id = str(num).zfill(3)
|
118
|
-
tg.start_soon(download_sticker, sticker, f_id, results)
|
27
|
+
tg_api: TelegramAPI
|
28
|
+
if self.input_option.endswith("telethon"):
|
29
|
+
tg_api = TelethonAPI()
|
30
|
+
else:
|
31
|
+
tg_api = BotAPI()
|
32
|
+
|
33
|
+
if self.opt_cred is None:
|
34
|
+
self.cb.put("Download failed: No credentials")
|
35
|
+
return 0, 0
|
119
36
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
)
|
37
|
+
success = await tg_api.setup(self.opt_cred, False, self.cb, self.cb_return)
|
38
|
+
if success is False:
|
39
|
+
self.cb.put("Download failed: Invalid credentials")
|
40
|
+
return 0, 0
|
125
41
|
|
126
|
-
|
127
|
-
|
128
|
-
)
|
129
|
-
return sum(results.values()), len(
|
42
|
+
title = Path(urlparse(self.url).path).name
|
43
|
+
results, emoji_dict = await tg_api.pack_dl(title, self.out_dir)
|
44
|
+
MetadataHandler.set_metadata(self.out_dir, title=title, emoji_dict=emoji_dict)
|
45
|
+
return sum(results.values()), len(results)
|
130
46
|
|
131
47
|
@staticmethod
|
132
48
|
def start(
|
sticker_convert/gui.py
CHANGED
@@ -154,6 +154,8 @@ class GUI(Window):
|
|
154
154
|
self.signal_password_var = StringVar(self)
|
155
155
|
self.telegram_token_var = StringVar(self)
|
156
156
|
self.telegram_userid_var = StringVar(self)
|
157
|
+
self.telethon_api_id_var = IntVar(self)
|
158
|
+
self.telethon_api_hash_var = StringVar(self)
|
157
159
|
self.kakao_auth_token_var = StringVar(self)
|
158
160
|
self.kakao_username_var = StringVar(self)
|
159
161
|
self.kakao_password_var = StringVar(self)
|
@@ -406,6 +408,10 @@ class GUI(Window):
|
|
406
408
|
self.signal_password_var.set(self.creds.get("signal", {}).get("password", ""))
|
407
409
|
self.telegram_token_var.set(self.creds.get("telegram", {}).get("token", ""))
|
408
410
|
self.telegram_userid_var.set(self.creds.get("telegram", {}).get("userid", ""))
|
411
|
+
self.telethon_api_id_var.set(self.creds.get("telethon", {}).get("api_id", 0))
|
412
|
+
self.telethon_api_hash_var.set(
|
413
|
+
self.creds.get("telethon", {}).get("api_hash", "")
|
414
|
+
)
|
409
415
|
self.kakao_auth_token_var.set(self.creds.get("kakao", {}).get("auth_token", ""))
|
410
416
|
self.kakao_username_var.set(self.creds.get("kakao", {}).get("username", ""))
|
411
417
|
self.kakao_password_var.set(self.creds.get("kakao", {}).get("password", ""))
|
@@ -451,6 +457,10 @@ class GUI(Window):
|
|
451
457
|
selection = self.comp_preset_var.get()
|
452
458
|
if selection == "auto":
|
453
459
|
output_option = self.get_output_name()
|
460
|
+
if "telegram_emoji" in output_option:
|
461
|
+
return "telegram_emoji"
|
462
|
+
if "telegram" in output_option:
|
463
|
+
return "telegram"
|
454
464
|
if output_option == "imessage":
|
455
465
|
return "imessage_small"
|
456
466
|
if output_option == "local":
|
@@ -572,6 +582,8 @@ class GUI(Window):
|
|
572
582
|
signal_password=self.signal_password_var.get(),
|
573
583
|
telegram_token=self.telegram_token_var.get(),
|
574
584
|
telegram_userid=self.telegram_userid_var.get(),
|
585
|
+
telethon_api_id=self.telethon_api_id_var.get(),
|
586
|
+
telethon_api_hash=self.telethon_api_hash_var.get(),
|
575
587
|
kakao_auth_token=self.kakao_auth_token_var.get(),
|
576
588
|
kakao_username=self.kakao_username_var.get(),
|
577
589
|
kakao_password=self.kakao_password_var.get(),
|
@@ -10,6 +10,7 @@ from sticker_convert.gui_components.windows.kakao_get_auth_window import KakaoGe
|
|
10
10
|
from sticker_convert.gui_components.windows.line_get_auth_window import LineGetAuthWindow
|
11
11
|
from sticker_convert.gui_components.windows.signal_get_auth_window import SignalGetAuthWindow
|
12
12
|
from sticker_convert.gui_components.windows.viber_get_auth_window import ViberGetAuthWindow
|
13
|
+
from sticker_convert.utils.auth.telethon_setup import TelethonSetup
|
13
14
|
|
14
15
|
if TYPE_CHECKING:
|
15
16
|
from sticker_convert.gui import GUI # type: ignore
|
@@ -77,6 +78,16 @@ class CredFrame(LabelFrame):
|
|
77
78
|
)
|
78
79
|
self.telegram_userid_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
|
79
80
|
|
81
|
+
self.telethon_auth_lbl = Label(
|
82
|
+
self, text="Telethon authorization", justify="left", anchor="w"
|
83
|
+
)
|
84
|
+
self.telethon_auth_btn = Button(
|
85
|
+
self,
|
86
|
+
text="Generate",
|
87
|
+
command=self.cb_telethon_get_auth,
|
88
|
+
bootstyle="secondary", # type: ignore
|
89
|
+
)
|
90
|
+
|
80
91
|
self.kakao_auth_token_lbl = Label(
|
81
92
|
self, text="Kakao auth_token", justify="left", anchor="w"
|
82
93
|
)
|
@@ -157,19 +168,21 @@ class CredFrame(LabelFrame):
|
|
157
168
|
self.telegram_userid_entry.grid(
|
158
169
|
column=1, row=4, columnspan=2, sticky="w", padx=3, pady=3
|
159
170
|
)
|
160
|
-
self.
|
161
|
-
self.
|
162
|
-
self.
|
163
|
-
self.
|
164
|
-
self.
|
165
|
-
self.
|
166
|
-
self.
|
167
|
-
self.
|
168
|
-
self.
|
169
|
-
self.
|
170
|
-
self.
|
171
|
-
self.
|
172
|
-
self.
|
171
|
+
self.telethon_auth_lbl.grid(column=0, row=5, sticky="w", padx=3, pady=3)
|
172
|
+
self.telethon_auth_btn.grid(column=2, row=5, sticky="e", padx=3, pady=3)
|
173
|
+
self.kakao_auth_token_lbl.grid(column=0, row=6, sticky="w", padx=3, pady=3)
|
174
|
+
self.kakao_auth_token_entry.grid(column=1, row=6, sticky="w", padx=3, pady=3)
|
175
|
+
self.kakao_get_auth_btn.grid(column=2, row=6, sticky="e", padx=3, pady=3)
|
176
|
+
self.line_cookies_lbl.grid(column=0, row=7, sticky="w", padx=3, pady=3)
|
177
|
+
self.line_cookies_entry.grid(column=1, row=7, sticky="w", padx=3, pady=3)
|
178
|
+
self.line_get_auth_btn.grid(column=2, row=7, sticky="e", padx=3, pady=3)
|
179
|
+
self.viber_auth_lbl.grid(column=0, row=8, sticky="w", padx=3, pady=3)
|
180
|
+
self.viber_auth_entry.grid(column=1, row=8, sticky="w", padx=3, pady=3)
|
181
|
+
self.viber_get_auth_btn.grid(column=2, row=8, sticky="e", padx=3, pady=3)
|
182
|
+
self.discord_token_lbl.grid(column=0, row=9, sticky="w", padx=3, pady=3)
|
183
|
+
self.discord_token_entry.grid(column=1, row=9, sticky="w", padx=3, pady=3)
|
184
|
+
self.discord_get_auth_btn.grid(column=2, row=9, sticky="e", padx=3, pady=3)
|
185
|
+
self.help_btn.grid(column=2, row=10, sticky="e", padx=3, pady=3)
|
173
186
|
|
174
187
|
def cb_cred_help(self, *_: Any) -> None:
|
175
188
|
faq_site = "https://github.com/laggykiller/sticker-convert#faq"
|
@@ -177,6 +190,18 @@ class CredFrame(LabelFrame):
|
|
177
190
|
if not success:
|
178
191
|
self.gui.cb_ask_str("You can get help from:", initialvalue=faq_site)
|
179
192
|
|
193
|
+
def cb_telethon_get_auth(self, *_: Any) -> None:
|
194
|
+
success, _client, api_id, api_hash = TelethonSetup(
|
195
|
+
self.gui.get_opt_cred(), self.gui.cb_ask_str
|
196
|
+
).start()
|
197
|
+
if success:
|
198
|
+
self.gui.telethon_api_id_var.set(api_id)
|
199
|
+
self.gui.telethon_api_hash_var.set(api_hash)
|
200
|
+
self.gui.save_creds()
|
201
|
+
self.gui.cb_msg_block("Telethon setup successful")
|
202
|
+
else:
|
203
|
+
self.gui.cb_msg_block("Telethon setup failed")
|
204
|
+
|
180
205
|
def cb_kakao_get_auth(self, *_: Any) -> None:
|
181
206
|
KakaoGetAuthWindow(self.gui)
|
182
207
|
|
sticker_convert/job.py
CHANGED
@@ -379,7 +379,10 @@ class Job:
|
|
379
379
|
not self.opt_comp.no_compress
|
380
380
|
and self.opt_output.option != "local"
|
381
381
|
and self.opt_comp.preset != "custom"
|
382
|
-
and
|
382
|
+
and (
|
383
|
+
self.opt_output.option not in self.opt_comp.preset
|
384
|
+
and self.opt_comp.preset not in self.opt_output.option
|
385
|
+
)
|
383
386
|
):
|
384
387
|
msg = "Compression preset does not match export option\n"
|
385
388
|
msg += "You may continue, but the files will need to be compressed again before export\n"
|
@@ -551,7 +554,7 @@ class Job:
|
|
551
554
|
if self.opt_input.option == "line":
|
552
555
|
downloaders.append(DownloadLine.start)
|
553
556
|
|
554
|
-
if self.opt_input.option
|
557
|
+
if self.opt_input.option.startswith("telegram"):
|
555
558
|
downloaders.append(DownloadTelegram.start)
|
556
559
|
|
557
560
|
if self.opt_input.option == "kakao":
|
@@ -702,10 +705,7 @@ class Job:
|
|
702
705
|
if self.opt_output.option == "signal":
|
703
706
|
exporters.append(UploadSignal.start)
|
704
707
|
|
705
|
-
if self.opt_output.option
|
706
|
-
exporters.append(UploadTelegram.start)
|
707
|
-
|
708
|
-
if self.opt_output.option == "telegram_emoji":
|
708
|
+
if self.opt_output.option.startswith("telegram"):
|
709
709
|
exporters.append(UploadTelegram.start)
|
710
710
|
|
711
711
|
if self.opt_output.option == "imessage":
|
sticker_convert/job_option.py
CHANGED
@@ -214,6 +214,8 @@ class CredOption(BaseOption):
|
|
214
214
|
signal_password: str = ""
|
215
215
|
telegram_token: str = ""
|
216
216
|
telegram_userid: str = ""
|
217
|
+
telethon_api_id: int = 0
|
218
|
+
telethon_api_hash: str = ""
|
217
219
|
kakao_auth_token: str = ""
|
218
220
|
kakao_username: str = ""
|
219
221
|
kakao_password: str = ""
|
@@ -227,6 +229,10 @@ class CredOption(BaseOption):
|
|
227
229
|
return {
|
228
230
|
"signal": {"uuid": self.signal_uuid, "password": self.signal_password},
|
229
231
|
"telegram": {"token": self.telegram_token, "userid": self.telegram_userid},
|
232
|
+
"telethon": {
|
233
|
+
"api_id": self.telethon_api_id,
|
234
|
+
"api_hash": self.telethon_api_hash,
|
235
|
+
},
|
230
236
|
"kakao": {
|
231
237
|
"auth_token": self.kakao_auth_token,
|
232
238
|
"username": self.kakao_username,
|
@@ -59,7 +59,8 @@
|
|
59
59
|
"signal_password": "Set Signal password. Required for uploading Signal stickers.",
|
60
60
|
"signal_get_auth": "Generate Signal uuid and password.",
|
61
61
|
"telegram_token": "Set Telegram token. Required for uploading and downloading Telegram stickers.",
|
62
|
-
"telegram_userid": "Set
|
62
|
+
"telegram_userid": "Set Telegram user_id (From real account, not bot account). Required for uploading Telegram stickers.",
|
63
|
+
"telethon_setup": "Setup Telethon",
|
63
64
|
"kakao_auth_token": "Set Kakao auth_token. Required for downloading animated stickers from https://e.kakao.com/t/xxxxx",
|
64
65
|
"kakao_get_auth": "Generate Kakao auth_token by simulating login. Kakao username, password, country code and phone number are also required.",
|
65
66
|
"kakao_get_auth_desktop": "Get Kakao auth_token from Kakao Desktop application.\n(Only working on Windows.)",
|
@@ -75,6 +76,6 @@
|
|
75
76
|
"viber_bin_path": "Specify location of Viber Desktop application.\nUseful for portable installation.",
|
76
77
|
"discord_get_auth": "Get Discord token.",
|
77
78
|
"discord_token": "Set Discord token. Required for downloading Discord stickers and emojis.",
|
78
|
-
"save_cred": "Save
|
79
|
+
"save_cred": "Save credentials."
|
79
80
|
}
|
80
81
|
}
|
@@ -29,6 +29,16 @@
|
|
29
29
|
"author": false
|
30
30
|
}
|
31
31
|
},
|
32
|
+
"telegram_telethon": {
|
33
|
+
"full_name": "Download from Telegram with Telethon",
|
34
|
+
"help": "Download telegram stickers from a URL as input with Telethon",
|
35
|
+
"example": "Example: https://telegram.me/addstickers/xxxxx\n OR https://telegram.me/addemoji/xxxxx",
|
36
|
+
"address_lbls": "URL address",
|
37
|
+
"metadata_provides": {
|
38
|
+
"title": true,
|
39
|
+
"author": false
|
40
|
+
}
|
41
|
+
},
|
32
42
|
"line": {
|
33
43
|
"full_name": "Download from Line",
|
34
44
|
"help": "Download line stickers from a URL / ID as input",
|
@@ -23,6 +23,22 @@
|
|
23
23
|
"author": false
|
24
24
|
}
|
25
25
|
},
|
26
|
+
"telegram_telethon": {
|
27
|
+
"full_name": "Upload to Telegram with Telethon",
|
28
|
+
"help": "Upload to Telegram with Telethon *Not recommended, but allow link not end with _by_xxxbot*",
|
29
|
+
"metadata_requirements": {
|
30
|
+
"title": true,
|
31
|
+
"author": false
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"telegram_emoji_telethon": {
|
35
|
+
"full_name": "Upload to Telegram with Telethon (Custom emoji)",
|
36
|
+
"help": "Upload to Telegram with Telethon (Custom emoji) *Not recommended, but allow link not end with _by_xxxbot*",
|
37
|
+
"metadata_requirements": {
|
38
|
+
"title": true,
|
39
|
+
"author": false
|
40
|
+
}
|
41
|
+
},
|
26
42
|
"viber": {
|
27
43
|
"full_name": "Upload to Viber",
|
28
44
|
"help": "Upload to Viber",
|