sticker-convert 2.13.3.0__py3-none-any.whl → 2.17.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sticker_convert/__main__.py +24 -27
- sticker_convert/auth/__init__.py +0 -0
- sticker_convert/auth/auth_base.py +19 -0
- sticker_convert/{utils/auth/get_discord_auth.py → auth/auth_discord.py} +149 -118
- sticker_convert/{utils/auth/get_kakao_auth.py → auth/auth_kakao_android_login.py} +331 -330
- sticker_convert/auth/auth_kakao_desktop_login.py +327 -0
- sticker_convert/{utils/auth/get_kakao_desktop_auth.py → auth/auth_kakao_desktop_memdump.py} +281 -263
- sticker_convert/{utils/auth/get_line_auth.py → auth/auth_line.py} +98 -80
- sticker_convert/{utils/auth/get_signal_auth.py → auth/auth_signal.py} +139 -135
- sticker_convert/auth/auth_telethon.py +161 -0
- sticker_convert/{utils/auth/get_viber_auth.py → auth/auth_viber.py} +250 -235
- sticker_convert/{utils/auth → auth}/telegram_api.py +736 -675
- sticker_convert/cli.py +623 -608
- sticker_convert/converter.py +1093 -1084
- sticker_convert/definitions.py +4 -0
- sticker_convert/downloaders/download_band.py +111 -110
- sticker_convert/downloaders/download_base.py +171 -166
- sticker_convert/downloaders/download_discord.py +92 -91
- sticker_convert/downloaders/download_kakao.py +417 -404
- sticker_convert/downloaders/download_line.py +484 -475
- sticker_convert/downloaders/download_ogq.py +80 -79
- sticker_convert/downloaders/download_signal.py +108 -105
- sticker_convert/downloaders/download_telegram.py +56 -55
- sticker_convert/downloaders/download_viber.py +121 -120
- sticker_convert/gui.py +788 -873
- sticker_convert/gui_components/frames/comp_frame.py +180 -166
- sticker_convert/gui_components/frames/config_frame.py +156 -113
- sticker_convert/gui_components/frames/control_frame.py +32 -30
- sticker_convert/gui_components/frames/cred_frame.py +232 -233
- sticker_convert/gui_components/frames/input_frame.py +139 -137
- sticker_convert/gui_components/frames/output_frame.py +112 -110
- sticker_convert/gui_components/frames/right_clicker.py +25 -23
- sticker_convert/gui_components/windows/advanced_compression_window.py +757 -757
- sticker_convert/gui_components/windows/base_window.py +7 -2
- sticker_convert/gui_components/windows/discord_get_auth_window.py +79 -82
- sticker_convert/gui_components/windows/kakao_get_auth_window.py +511 -321
- sticker_convert/gui_components/windows/line_get_auth_window.py +94 -102
- sticker_convert/gui_components/windows/signal_get_auth_window.py +84 -89
- sticker_convert/gui_components/windows/viber_get_auth_window.py +168 -168
- sticker_convert/ios-message-stickers-template/.github/FUNDING.yml +3 -3
- sticker_convert/ios-message-stickers-template/README.md +10 -10
- sticker_convert/ios-message-stickers-template/stickers/Info.plist +43 -43
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Info.plist +31 -31
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Contents.json +6 -6
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Contents.json +20 -20
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Contents.json +9 -9
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Contents.json +9 -9
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Contents.json +9 -9
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Contents.json +91 -91
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.pbxproj +364 -364
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/xcuserdata/niklaspeterson.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
- sticker_convert/job.py +166 -130
- sticker_convert/job_option.py +1 -0
- sticker_convert/locales/en_US/LC_MESSAGES/base.mo +0 -0
- sticker_convert/locales/ja_JP/LC_MESSAGES/base.mo +0 -0
- sticker_convert/locales/zh_CN/LC_MESSAGES/base.mo +0 -0
- sticker_convert/locales/zh_TW/LC_MESSAGES/base.mo +0 -0
- sticker_convert/py.typed +0 -0
- sticker_convert/resources/NotoColorEmoji.ttf +0 -0
- sticker_convert/resources/help.ja_JP.json +88 -0
- sticker_convert/resources/help.json +10 -7
- sticker_convert/resources/help.zh_CN.json +88 -0
- sticker_convert/resources/help.zh_TW.json +88 -0
- sticker_convert/resources/input.ja_JP.json +74 -0
- sticker_convert/resources/input.json +121 -121
- sticker_convert/resources/input.zh_CN.json +74 -0
- sticker_convert/resources/input.zh_TW.json +74 -0
- sticker_convert/resources/output.ja_JP.json +38 -0
- sticker_convert/resources/output.zh_CN.json +38 -0
- sticker_convert/resources/output.zh_TW.json +38 -0
- sticker_convert/uploaders/compress_wastickers.py +186 -177
- sticker_convert/uploaders/upload_base.py +44 -35
- sticker_convert/uploaders/upload_signal.py +218 -203
- sticker_convert/uploaders/upload_telegram.py +353 -338
- sticker_convert/uploaders/upload_viber.py +178 -169
- sticker_convert/uploaders/xcode_imessage.py +295 -286
- sticker_convert/utils/callback.py +238 -6
- sticker_convert/utils/emoji.py +16 -4
- sticker_convert/utils/files/json_resources_loader.py +24 -19
- sticker_convert/utils/files/metadata_handler.py +3 -3
- sticker_convert/utils/translate.py +108 -0
- sticker_convert/utils/url_detect.py +40 -37
- sticker_convert/version.py +1 -1
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/METADATA +89 -74
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/RECORD +91 -74
- sticker_convert/utils/auth/telethon_setup.py +0 -97
- sticker_convert/utils/singletons.py +0 -18
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/WHEEL +0 -0
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/entry_points.txt +0 -0
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/licenses/LICENSE +0 -0
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,169 +1,178 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
import copy
|
|
3
|
-
import json
|
|
4
|
-
import zipfile
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from typing import Any, Dict, List, Tuple
|
|
7
|
-
|
|
8
|
-
import requests
|
|
9
|
-
|
|
10
|
-
from sticker_convert.converter import StickerConvert
|
|
11
|
-
from sticker_convert.job_option import CompOption, CredOption, OutputOption
|
|
12
|
-
from sticker_convert.uploaders.upload_base import UploadBase
|
|
13
|
-
from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
|
|
14
|
-
from sticker_convert.utils.files.metadata_handler import MetadataHandler
|
|
15
|
-
from sticker_convert.utils.files.sanitize_filename import sanitize_filename
|
|
16
|
-
from sticker_convert.utils.media.format_verify import FormatVerify
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
self.png_spec.
|
|
27
|
-
self.png_spec.
|
|
28
|
-
self.
|
|
29
|
-
self.opt_comp_merged.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
self.png_cover_spec.
|
|
33
|
-
self.png_cover_spec.
|
|
34
|
-
self.
|
|
35
|
-
self.opt_comp_cover_merged.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
self.
|
|
89
|
-
self.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
self.
|
|
110
|
-
self.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
upload_data
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
self.cb.put(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import copy
|
|
3
|
+
import json
|
|
4
|
+
import zipfile
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any, Dict, List, Tuple
|
|
7
|
+
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
from sticker_convert.converter import StickerConvert
|
|
11
|
+
from sticker_convert.job_option import CompOption, CredOption, OutputOption
|
|
12
|
+
from sticker_convert.uploaders.upload_base import UploadBase
|
|
13
|
+
from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
|
|
14
|
+
from sticker_convert.utils.files.metadata_handler import MetadataHandler
|
|
15
|
+
from sticker_convert.utils.files.sanitize_filename import sanitize_filename
|
|
16
|
+
from sticker_convert.utils.media.format_verify import FormatVerify
|
|
17
|
+
from sticker_convert.utils.translate import I
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class UploadViber(UploadBase):
|
|
21
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
22
|
+
super().__init__(*args, **kwargs)
|
|
23
|
+
|
|
24
|
+
self.base_spec.set_size_max(0)
|
|
25
|
+
|
|
26
|
+
self.png_spec = copy.deepcopy(self.base_spec)
|
|
27
|
+
self.png_spec.set_res_max(490)
|
|
28
|
+
self.png_spec.set_format((".png",))
|
|
29
|
+
self.opt_comp_merged = copy.deepcopy(self.opt_comp)
|
|
30
|
+
self.opt_comp_merged.merge(self.png_spec)
|
|
31
|
+
|
|
32
|
+
self.png_cover_spec = copy.deepcopy(self.base_spec)
|
|
33
|
+
self.png_cover_spec.set_res_max(120)
|
|
34
|
+
self.png_cover_spec.set_format((".png",))
|
|
35
|
+
self.opt_comp_cover_merged = copy.deepcopy(self.opt_comp)
|
|
36
|
+
self.opt_comp_cover_merged.merge(self.png_cover_spec)
|
|
37
|
+
|
|
38
|
+
def upload_stickers_viber(self) -> Tuple[int, int, List[str]]:
|
|
39
|
+
urls: List[str] = []
|
|
40
|
+
|
|
41
|
+
if not self.opt_cred.viber_auth:
|
|
42
|
+
self.cb.put(I("Viber auth required for uploading to viber"))
|
|
43
|
+
return 0, 0, urls
|
|
44
|
+
|
|
45
|
+
upload_data_base: Dict[str, str] = {}
|
|
46
|
+
for i in self.opt_cred.viber_auth.split(";"):
|
|
47
|
+
j = i.split(":")
|
|
48
|
+
upload_data_base[j[0]] = j[1]
|
|
49
|
+
|
|
50
|
+
if upload_data_base.get("member_id") is None:
|
|
51
|
+
self.cb.put(I("Invalid Viber auth: Missing member_id"))
|
|
52
|
+
return 0, 0, urls
|
|
53
|
+
if upload_data_base.get("m_token") is None:
|
|
54
|
+
self.cb.put(I("Invalid Viber auth: Missing m_token"))
|
|
55
|
+
return 0, 0, urls
|
|
56
|
+
if upload_data_base.get("m_ts") is None:
|
|
57
|
+
self.cb.put(I("Invalid Viber auth: Missing m_ts"))
|
|
58
|
+
return 0, 0, urls
|
|
59
|
+
|
|
60
|
+
title, author, _ = MetadataHandler.get_metadata(
|
|
61
|
+
self.opt_output.dir,
|
|
62
|
+
title=self.opt_output.title,
|
|
63
|
+
author=self.opt_output.author,
|
|
64
|
+
)
|
|
65
|
+
if title is None:
|
|
66
|
+
raise TypeError(I("title cannot be {}").format(title))
|
|
67
|
+
if author is None:
|
|
68
|
+
author = ""
|
|
69
|
+
|
|
70
|
+
packs = MetadataHandler.split_sticker_packs(
|
|
71
|
+
self.opt_output.dir,
|
|
72
|
+
title=title,
|
|
73
|
+
file_per_pack=24,
|
|
74
|
+
separate_image_anim=False,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
cover_path = MetadataHandler.get_cover(self.opt_output.dir)
|
|
78
|
+
if cover_path is None:
|
|
79
|
+
cover_path = MetadataHandler.get_stickers_present(self.opt_output.dir)[0]
|
|
80
|
+
|
|
81
|
+
if FormatVerify.check_file(cover_path, spec=self.png_cover_spec):
|
|
82
|
+
with open(cover_path, "rb") as f:
|
|
83
|
+
cover_bytes = f.read()
|
|
84
|
+
else:
|
|
85
|
+
_, _, cover_bytes, _ = StickerConvert.convert( # type: ignore
|
|
86
|
+
cover_path,
|
|
87
|
+
Path("bytes.png"),
|
|
88
|
+
self.opt_comp_cover_merged,
|
|
89
|
+
self.cb,
|
|
90
|
+
self.cb_return,
|
|
91
|
+
)
|
|
92
|
+
assert isinstance(cover_bytes, bytes)
|
|
93
|
+
|
|
94
|
+
stickers_total = 0
|
|
95
|
+
stickers_ok = 0
|
|
96
|
+
for pack_title, stickers in packs.items():
|
|
97
|
+
stickers_total += len(stickers)
|
|
98
|
+
out_f = Path(
|
|
99
|
+
self.opt_output.dir, sanitize_filename(pack_title + ".zip")
|
|
100
|
+
).as_posix()
|
|
101
|
+
with zipfile.ZipFile(out_f, "w", zipfile.ZIP_DEFLATED) as zipf:
|
|
102
|
+
for num, src in enumerate(stickers):
|
|
103
|
+
self.cb.put(I("Verifying {} for uploading to Viber").format(src))
|
|
104
|
+
|
|
105
|
+
if not FormatVerify.check_file(src, spec=self.png_spec):
|
|
106
|
+
success, _, image_data, _ = StickerConvert.convert(
|
|
107
|
+
src,
|
|
108
|
+
Path("bytes.png"),
|
|
109
|
+
self.opt_comp_merged,
|
|
110
|
+
self.cb,
|
|
111
|
+
self.cb_return,
|
|
112
|
+
)
|
|
113
|
+
assert isinstance(image_data, bytes)
|
|
114
|
+
if not success:
|
|
115
|
+
self.cb.put(
|
|
116
|
+
I(
|
|
117
|
+
"Warning: Cannot compress file {}, skip this file..."
|
|
118
|
+
).format(src.name)
|
|
119
|
+
)
|
|
120
|
+
continue
|
|
121
|
+
else:
|
|
122
|
+
with open(src, "rb") as f:
|
|
123
|
+
image_data = f.read()
|
|
124
|
+
|
|
125
|
+
zipf.writestr(f"{str(num).zfill(2)}.png", image_data)
|
|
126
|
+
|
|
127
|
+
upload_data = copy.deepcopy(upload_data_base)
|
|
128
|
+
upload_data["title"] = pack_title
|
|
129
|
+
upload_data["description"] = author
|
|
130
|
+
upload_data["shareable"] = "1"
|
|
131
|
+
|
|
132
|
+
with open(out_f, "rb") as f:
|
|
133
|
+
r = requests.post(
|
|
134
|
+
"https://market.api.viber.com/2/users/custom-sticker-packs/create",
|
|
135
|
+
files={
|
|
136
|
+
"file": ("upload.zip", f.read()),
|
|
137
|
+
"file_icon": ("color_icon.png", cover_bytes),
|
|
138
|
+
},
|
|
139
|
+
data=upload_data,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
if r.ok:
|
|
143
|
+
rjson = json.loads(r.text)
|
|
144
|
+
if rjson["status"] == 1:
|
|
145
|
+
pack_id = rjson["custom_sticker_pack"]["id"]
|
|
146
|
+
url = f"https://stickers.viber.com/pages/custom-sticker-packs/{pack_id}"
|
|
147
|
+
urls.append(url)
|
|
148
|
+
self.cb.put(I("Uploaded {}").format(pack_title))
|
|
149
|
+
stickers_ok += len(stickers)
|
|
150
|
+
else:
|
|
151
|
+
self.cb.put(
|
|
152
|
+
I("Failed to upload {}: {} {}").format(
|
|
153
|
+
pack_title, r.status_code, r.text
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
if rjson["status"] == 103:
|
|
157
|
+
self.cb.put(
|
|
158
|
+
"Viber auth data may have expired. Try to regenerate it?"
|
|
159
|
+
)
|
|
160
|
+
else:
|
|
161
|
+
self.cb.put(
|
|
162
|
+
I("Failed to upload {}: {} {}").format(
|
|
163
|
+
pack_title, r.status_code, r.text
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
return stickers_ok, stickers_total, urls
|
|
168
|
+
|
|
169
|
+
@staticmethod
|
|
170
|
+
def start(
|
|
171
|
+
opt_output: OutputOption,
|
|
172
|
+
opt_comp: CompOption,
|
|
173
|
+
opt_cred: CredOption,
|
|
174
|
+
cb: CallbackProtocol,
|
|
175
|
+
cb_return: CallbackReturn,
|
|
176
|
+
) -> Tuple[int, int, List[str]]:
|
|
177
|
+
exporter = UploadViber(opt_output, opt_comp, opt_cred, cb, cb_return)
|
|
178
|
+
return exporter.upload_stickers_viber()
|