sticker-convert 2.8.12__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.
Files changed (124) hide show
  1. sticker_convert/__main__.py +24 -24
  2. sticker_convert/auth/__init__.py +0 -0
  3. sticker_convert/auth/auth_base.py +19 -0
  4. sticker_convert/auth/auth_discord.py +149 -0
  5. sticker_convert/{utils/auth/get_kakao_auth.py → auth/auth_kakao_android_login.py} +331 -300
  6. sticker_convert/auth/auth_kakao_desktop_login.py +327 -0
  7. sticker_convert/auth/auth_kakao_desktop_memdump.py +281 -0
  8. sticker_convert/{utils/auth/get_line_auth.py → auth/auth_line.py} +98 -80
  9. sticker_convert/auth/auth_signal.py +139 -0
  10. sticker_convert/auth/auth_telethon.py +161 -0
  11. sticker_convert/auth/auth_viber.py +250 -0
  12. sticker_convert/auth/telegram_api.py +736 -0
  13. sticker_convert/cli.py +623 -509
  14. sticker_convert/converter.py +1093 -962
  15. sticker_convert/definitions.py +11 -0
  16. sticker_convert/downloaders/download_band.py +111 -0
  17. sticker_convert/downloaders/download_base.py +171 -130
  18. sticker_convert/downloaders/download_discord.py +92 -0
  19. sticker_convert/downloaders/download_kakao.py +417 -255
  20. sticker_convert/downloaders/download_line.py +484 -472
  21. sticker_convert/downloaders/download_ogq.py +80 -0
  22. sticker_convert/downloaders/download_signal.py +108 -92
  23. sticker_convert/downloaders/download_telegram.py +56 -130
  24. sticker_convert/downloaders/download_viber.py +121 -95
  25. sticker_convert/gui.py +788 -795
  26. sticker_convert/gui_components/frames/comp_frame.py +180 -165
  27. sticker_convert/gui_components/frames/config_frame.py +156 -113
  28. sticker_convert/gui_components/frames/control_frame.py +32 -30
  29. sticker_convert/gui_components/frames/cred_frame.py +232 -162
  30. sticker_convert/gui_components/frames/input_frame.py +139 -137
  31. sticker_convert/gui_components/frames/output_frame.py +112 -110
  32. sticker_convert/gui_components/frames/right_clicker.py +25 -23
  33. sticker_convert/gui_components/windows/advanced_compression_window.py +757 -715
  34. sticker_convert/gui_components/windows/base_window.py +7 -2
  35. sticker_convert/gui_components/windows/discord_get_auth_window.py +79 -0
  36. sticker_convert/gui_components/windows/kakao_get_auth_window.py +511 -186
  37. sticker_convert/gui_components/windows/line_get_auth_window.py +94 -102
  38. sticker_convert/gui_components/windows/signal_get_auth_window.py +84 -135
  39. sticker_convert/gui_components/windows/viber_get_auth_window.py +168 -0
  40. sticker_convert/ios-message-stickers-template/.github/FUNDING.yml +3 -3
  41. sticker_convert/ios-message-stickers-template/.gitignore +0 -0
  42. sticker_convert/ios-message-stickers-template/README.md +10 -10
  43. sticker_convert/ios-message-stickers-template/stickers/Info.plist +43 -43
  44. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Info.plist +31 -31
  45. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Contents.json +6 -6
  46. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Contents.json +20 -20
  47. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Contents.json +9 -9
  48. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Sticker 1.png +0 -0
  49. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Contents.json +9 -9
  50. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Sticker 2.png +0 -0
  51. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Contents.json +9 -9
  52. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Sticker 3.png +0 -0
  53. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/App-Store-1024x1024pt.png +0 -0
  54. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Contents.json +91 -91
  55. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-App-Store-1024x768pt.png +0 -0
  56. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPad-67x50pt@2x.png +0 -0
  57. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPad-Pro-74x55pt@2x.png +0 -0
  58. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPhone-60x45pt@2x.png +0 -0
  59. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPhone-60x45pt@3x.png +0 -0
  60. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages27x20pt@2x.png +0 -0
  61. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages27x20pt@3x.png +0 -0
  62. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages32x24pt@2x.png +0 -0
  63. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages32x24pt@3x.png +0 -0
  64. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPad-Settings-29pt@2x.png +0 -0
  65. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPhone-Settings-29pt@3x.png +0 -0
  66. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPhone-settings-29pt@2x.png +0 -0
  67. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.pbxproj +364 -364
  68. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
  69. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
  70. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcuserdata/niklaspeterson.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  71. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/xcuserdata/niklaspeterson.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
  72. sticker_convert/job.py +279 -179
  73. sticker_convert/job_option.py +15 -2
  74. sticker_convert/locales/en_US/LC_MESSAGES/base.mo +0 -0
  75. sticker_convert/locales/ja_JP/LC_MESSAGES/base.mo +0 -0
  76. sticker_convert/locales/zh_CN/LC_MESSAGES/base.mo +0 -0
  77. sticker_convert/locales/zh_TW/LC_MESSAGES/base.mo +0 -0
  78. sticker_convert/py.typed +0 -0
  79. sticker_convert/resources/NotoColorEmoji.ttf +0 -0
  80. sticker_convert/resources/compression.json +220 -16
  81. sticker_convert/resources/emoji.json +527 -77
  82. sticker_convert/resources/help.ja_JP.json +88 -0
  83. sticker_convert/resources/help.json +24 -10
  84. sticker_convert/resources/help.zh_CN.json +88 -0
  85. sticker_convert/resources/help.zh_TW.json +88 -0
  86. sticker_convert/resources/input.ja_JP.json +74 -0
  87. sticker_convert/resources/input.json +121 -71
  88. sticker_convert/resources/input.zh_CN.json +74 -0
  89. sticker_convert/resources/input.zh_TW.json +74 -0
  90. sticker_convert/resources/memdump_linux.sh +25 -0
  91. sticker_convert/resources/memdump_windows.ps1 +8 -0
  92. sticker_convert/resources/output.ja_JP.json +38 -0
  93. sticker_convert/resources/output.json +24 -0
  94. sticker_convert/resources/output.zh_CN.json +38 -0
  95. sticker_convert/resources/output.zh_TW.json +38 -0
  96. sticker_convert/uploaders/compress_wastickers.py +186 -156
  97. sticker_convert/uploaders/upload_base.py +44 -35
  98. sticker_convert/uploaders/upload_signal.py +218 -173
  99. sticker_convert/uploaders/upload_telegram.py +353 -388
  100. sticker_convert/uploaders/upload_viber.py +178 -0
  101. sticker_convert/uploaders/xcode_imessage.py +295 -285
  102. sticker_convert/utils/callback.py +238 -6
  103. sticker_convert/utils/chrome_remotedebug.py +219 -0
  104. sticker_convert/utils/chromiums/linux.py +52 -0
  105. sticker_convert/utils/chromiums/osx.py +68 -0
  106. sticker_convert/utils/chromiums/windows.py +45 -0
  107. sticker_convert/utils/emoji.py +28 -0
  108. sticker_convert/utils/files/json_resources_loader.py +24 -19
  109. sticker_convert/utils/files/metadata_handler.py +8 -7
  110. sticker_convert/utils/files/run_bin.py +1 -1
  111. sticker_convert/utils/media/codec_info.py +99 -67
  112. sticker_convert/utils/media/format_verify.py +33 -20
  113. sticker_convert/utils/process.py +231 -0
  114. sticker_convert/utils/translate.py +108 -0
  115. sticker_convert/utils/url_detect.py +40 -33
  116. sticker_convert/version.py +1 -1
  117. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/METADATA +189 -96
  118. sticker_convert-2.17.0.0.dist-info/RECORD +138 -0
  119. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/WHEEL +1 -1
  120. sticker_convert/utils/auth/get_signal_auth.py +0 -129
  121. sticker_convert-2.8.12.dist-info/RECORD +0 -101
  122. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/entry_points.txt +0 -0
  123. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info/licenses}/LICENSE +0 -0
  124. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/top_level.txt +0 -0
@@ -1,173 +1,218 @@
1
- #!/usr/bin/env python3
2
- import copy
3
- from pathlib import Path
4
- from typing import Any, Dict, List
5
-
6
- import anyio
7
- from signalstickers_client.errors import SignalException
8
- from signalstickers_client.models import LocalStickerPack, Sticker
9
- from signalstickers_client.stickersclient import StickersClient
10
-
11
- from sticker_convert.converter import StickerConvert
12
- from sticker_convert.job_option import CompOption, CredOption, OutputOption
13
- from sticker_convert.uploaders.upload_base import UploadBase
14
- from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
15
- from sticker_convert.utils.files.metadata_handler import MetadataHandler
16
- from sticker_convert.utils.media.codec_info import CodecInfo
17
- from sticker_convert.utils.media.format_verify import FormatVerify
18
-
19
-
20
- class UploadSignal(UploadBase):
21
- def __init__(self, *args: Any, **kwargs: Any) -> None:
22
- super().__init__(*args, **kwargs)
23
-
24
- self.base_spec.set_size_max(300000)
25
- self.base_spec.set_res_max(512)
26
- self.base_spec.duration_max = 3000
27
- self.base_spec.square = True
28
-
29
- self.png_spec = copy.deepcopy(self.base_spec)
30
- self.png_spec.set_format((".apng",))
31
-
32
- self.webp_spec = copy.deepcopy(self.base_spec)
33
- self.webp_spec.format_img = (".webp",)
34
- self.webp_spec.animated = False
35
-
36
- self.opt_comp_merged = copy.deepcopy(self.opt_comp)
37
- self.opt_comp_merged.merge(self.base_spec)
38
-
39
- @staticmethod
40
- async def upload_pack(pack: LocalStickerPack, uuid: str, password: str) -> str:
41
- async with StickersClient(uuid, password) as client:
42
- pack_id, pack_key = await client.upload_pack(pack)
43
-
44
- result = (
45
- f"https://signal.art/addstickers/#pack_id={pack_id}&pack_key={pack_key}"
46
- )
47
- return result
48
-
49
- def add_stickers_to_pack(
50
- self, pack: LocalStickerPack, stickers: List[Path], emoji_dict: Dict[str, str]
51
- ) -> None:
52
- for src in stickers:
53
- self.cb.put(f"Verifying {src} for uploading to signal")
54
-
55
- sticker = Sticker()
56
- sticker.id = pack.nb_stickers
57
-
58
- emoji = emoji_dict.get(Path(src).stem, None)
59
- if not emoji:
60
- self.cb.put(
61
- f"Warning: Cannot find emoji for file {Path(src).name}, skip uploading this file..."
62
- )
63
- continue
64
- sticker.emoji = emoji[:1]
65
-
66
- if Path(src).suffix == ".webp":
67
- spec_choice = self.webp_spec
68
- else:
69
- spec_choice = self.png_spec
70
-
71
- if not FormatVerify.check_file(src, spec=spec_choice):
72
- if self.opt_comp.fake_vid or CodecInfo.is_anim(src):
73
- dst = "bytes.apng"
74
- else:
75
- dst = "bytes.png"
76
- success, _, image_data, _ = StickerConvert.convert(
77
- Path(src), Path(dst), self.opt_comp_merged, self.cb, self.cb_return
78
- )
79
- if not success:
80
- self.cb.put(
81
- f"Warning: Cannot compress file {Path(src).name}, skip uploading this file..."
82
- )
83
- continue
84
-
85
- assert isinstance(image_data, bytes)
86
-
87
- sticker.image_data = image_data
88
- else:
89
- with open(src, "rb") as f:
90
- sticker.image_data = f.read()
91
-
92
- pack._addsticker(sticker) # type: ignore
93
-
94
- def upload_stickers_signal(self) -> List[str]:
95
- urls: List[str] = []
96
-
97
- if not self.opt_cred.signal_uuid:
98
- self.cb.put("uuid required for uploading to Signal")
99
- return urls
100
- if not self.opt_cred.signal_password:
101
- self.cb.put("password required for uploading to Signal")
102
- return urls
103
-
104
- title, author, emoji_dict = MetadataHandler.get_metadata(
105
- self.opt_output.dir,
106
- title=self.opt_output.title,
107
- author=self.opt_output.author,
108
- )
109
- if title is None:
110
- raise TypeError(f"title cannot be {title}")
111
- if author is None:
112
- raise TypeError(f"author cannot be {author}")
113
- if emoji_dict is None:
114
- msg_block = "emoji.txt is required for uploading signal stickers\n"
115
- msg_block += f"emoji.txt generated for you in {self.opt_output.dir}\n"
116
- msg_block += f"Default emoji is set to {self.opt_comp.default_emoji}.\n"
117
- msg_block += "Please edit emoji.txt now, then continue"
118
- MetadataHandler.generate_emoji_file(
119
- directory=self.opt_output.dir, default_emoji=self.opt_comp.default_emoji
120
- )
121
-
122
- self.cb.put(("msg_block", (msg_block,), None))
123
- if self.cb_return:
124
- self.cb_return.get_response()
125
-
126
- title, author, emoji_dict = MetadataHandler.get_metadata(
127
- self.opt_output.dir,
128
- title=self.opt_output.title,
129
- author=self.opt_output.author,
130
- )
131
- assert title
132
- assert author
133
- assert emoji_dict
134
-
135
- packs = MetadataHandler.split_sticker_packs(
136
- self.opt_output.dir,
137
- title=title,
138
- file_per_pack=200,
139
- separate_image_anim=False,
140
- )
141
- for pack_title, stickers in packs.items():
142
- pack = LocalStickerPack()
143
- pack.title = pack_title
144
- pack.author = author
145
-
146
- self.add_stickers_to_pack(pack, stickers, emoji_dict)
147
- self.cb.put(f"Uploading pack {pack_title}")
148
- self.cb.put("update_bar")
149
- try:
150
- result = anyio.run(
151
- UploadSignal.upload_pack,
152
- pack,
153
- self.opt_cred.signal_uuid,
154
- self.opt_cred.signal_password,
155
- )
156
- self.cb.put((result))
157
- urls.append(result)
158
-
159
- except SignalException as e:
160
- self.cb.put(f"Failed to upload pack {pack_title} due to {repr(e)}")
161
-
162
- return urls
163
-
164
- @staticmethod
165
- def start(
166
- opt_output: OutputOption,
167
- opt_comp: CompOption,
168
- opt_cred: CredOption,
169
- cb: CallbackProtocol,
170
- cb_return: CallbackReturn,
171
- ) -> List[str]:
172
- exporter = UploadSignal(opt_output, opt_comp, opt_cred, cb, cb_return)
173
- return exporter.upload_stickers_signal()
1
+ #!/usr/bin/env python3
2
+ import copy
3
+ from pathlib import Path
4
+ from typing import Any, Dict, List, Optional, Tuple
5
+
6
+ import anyio
7
+ from signalstickers_client.errors import SignalException
8
+ from signalstickers_client.models import LocalStickerPack, Sticker
9
+ from signalstickers_client.stickersclient import StickersClient
10
+
11
+ from sticker_convert.converter import StickerConvert
12
+ from sticker_convert.job_option import CompOption, CredOption, OutputOption
13
+ from sticker_convert.uploaders.upload_base import UploadBase, get_msg_emoji_txt_required
14
+ from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
15
+ from sticker_convert.utils.emoji import extract_emojis
16
+ from sticker_convert.utils.files.metadata_handler import MetadataHandler
17
+ from sticker_convert.utils.media.codec_info import CodecInfo
18
+ from sticker_convert.utils.media.format_verify import FormatVerify
19
+ from sticker_convert.utils.translate import I
20
+
21
+
22
+ class UploadSignal(UploadBase):
23
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
24
+ super().__init__(*args, **kwargs)
25
+
26
+ self.base_spec.set_size_max(300000)
27
+ self.base_spec.set_res_max(512)
28
+ self.base_spec.duration_max = 3000
29
+
30
+ self.png_spec = copy.deepcopy(self.base_spec)
31
+ self.png_spec.set_format((".apng",))
32
+
33
+ self.webp_spec = copy.deepcopy(self.base_spec)
34
+ self.webp_spec.format_img = (".webp",)
35
+ self.webp_spec.animated = False
36
+
37
+ self.opt_comp_merged = copy.deepcopy(self.opt_comp)
38
+ self.opt_comp_merged.merge(self.base_spec)
39
+
40
+ @staticmethod
41
+ async def upload_pack(pack: LocalStickerPack, uuid: str, password: str) -> str:
42
+ async with StickersClient(uuid, password) as client:
43
+ pack_id, pack_key = await client.upload_pack(pack)
44
+
45
+ result = (
46
+ f"https://signal.art/addstickers/#pack_id={pack_id}&pack_key={pack_key}"
47
+ )
48
+ return result
49
+
50
+ def create_sticker(
51
+ self, src: Path, emoji_dict: Dict[str, str]
52
+ ) -> Optional[Sticker]:
53
+ self.cb.put(I("Verifying {} for uploading to signal").format(src))
54
+
55
+ sticker = Sticker()
56
+
57
+ emoji = extract_emojis(emoji_dict.get(Path(src).stem, ""))
58
+ if emoji == "":
59
+ self.cb.put(
60
+ I(
61
+ "Warning: Cannot find emoji for file {}, using default emoji..."
62
+ ).format(Path(src).name)
63
+ )
64
+ emoji = self.opt_comp.default_emoji
65
+ sticker.emoji = emoji
66
+
67
+ if Path(src).suffix == ".webp":
68
+ spec_choice = self.webp_spec
69
+ else:
70
+ spec_choice = self.png_spec
71
+
72
+ if not FormatVerify.check_file(src, spec=spec_choice):
73
+ if self.opt_comp.fake_vid or CodecInfo.is_anim(src):
74
+ dst = "bytes.apng"
75
+ else:
76
+ dst = "bytes.png"
77
+ success, _, image_data, _ = StickerConvert.convert(
78
+ Path(src), Path(dst), self.opt_comp_merged, self.cb, self.cb_return
79
+ )
80
+ if not success:
81
+ self.cb.put(
82
+ I(
83
+ "Warning: Cannot compress file {}, skip uploading this file..."
84
+ ).format(Path(src).name)
85
+ )
86
+ return None
87
+
88
+ assert isinstance(image_data, bytes)
89
+
90
+ sticker.image_data = image_data
91
+ else:
92
+ with open(src, "rb") as f:
93
+ sticker.image_data = f.read()
94
+
95
+ return sticker
96
+
97
+ def add_stickers_to_pack(
98
+ self, pack: LocalStickerPack, stickers: List[Path], emoji_dict: Dict[str, str]
99
+ ) -> None:
100
+ cover_file = MetadataHandler.get_cover(self.opt_output.dir)
101
+ cover_file_bytes = None
102
+ if cover_file:
103
+ with open(cover_file, "rb") as f:
104
+ cover_file_bytes = f.read()
105
+ for src in stickers:
106
+ sticker = self.create_sticker(src, emoji_dict)
107
+ if sticker is None:
108
+ continue
109
+ sticker.id = pack.nb_stickers
110
+ pack._addsticker(sticker) # type: ignore
111
+
112
+ if (
113
+ cover_file
114
+ and pack.cover is None
115
+ and sticker.image_data == cover_file_bytes
116
+ ):
117
+ pack.cover = sticker
118
+
119
+ if cover_file and pack.cover is None:
120
+ sticker = self.create_sticker(cover_file, emoji_dict)
121
+ if sticker is not None:
122
+ sticker.id = pack.nb_stickers
123
+ pack.cover = sticker
124
+
125
+ def upload_stickers_signal(self) -> Tuple[int, int, List[str]]:
126
+ urls: List[str] = []
127
+
128
+ if not self.opt_cred.signal_uuid:
129
+ self.cb.put(I("uuid required for uploading to Signal"))
130
+ return 0, 0, urls
131
+ if not self.opt_cred.signal_password:
132
+ self.cb.put(I("password required for uploading to Signal"))
133
+ return 0, 0, urls
134
+
135
+ title, author, emoji_dict = MetadataHandler.get_metadata(
136
+ self.opt_output.dir,
137
+ title=self.opt_output.title,
138
+ author=self.opt_output.author,
139
+ )
140
+ if title is None:
141
+ raise TypeError(I("title cannot be {}").format(title))
142
+ if author is None:
143
+ raise TypeError(I("author cannot be {}").format(author))
144
+ if emoji_dict is None:
145
+ MetadataHandler.generate_emoji_file(
146
+ directory=self.opt_output.dir, default_emoji=self.opt_comp.default_emoji
147
+ )
148
+
149
+ self.cb.put(
150
+ (
151
+ "msg_block",
152
+ (
153
+ get_msg_emoji_txt_required().format(
154
+ self.opt_output.dir, self.opt_comp.default_emoji
155
+ ),
156
+ ),
157
+ None,
158
+ )
159
+ )
160
+ if self.cb_return:
161
+ self.cb_return.get_response()
162
+
163
+ title, author, emoji_dict = MetadataHandler.get_metadata(
164
+ self.opt_output.dir,
165
+ title=self.opt_output.title,
166
+ author=self.opt_output.author,
167
+ )
168
+ assert title
169
+ assert author
170
+ assert emoji_dict
171
+
172
+ packs = MetadataHandler.split_sticker_packs(
173
+ self.opt_output.dir,
174
+ title=title,
175
+ file_per_pack=200,
176
+ separate_image_anim=False,
177
+ )
178
+ stickers_total = 0
179
+ stickers_ok = 0
180
+ for pack_title, stickers in packs.items():
181
+ stickers_total += len(stickers)
182
+ pack = LocalStickerPack()
183
+ pack.title = pack_title
184
+ pack.author = author
185
+
186
+ self.add_stickers_to_pack(pack, stickers, emoji_dict)
187
+ self.cb.put(I("Uploading pack {}").format(pack_title))
188
+ self.cb.put("update_bar")
189
+ try:
190
+ result = anyio.run(
191
+ UploadSignal.upload_pack,
192
+ pack,
193
+ self.opt_cred.signal_uuid,
194
+ self.opt_cred.signal_password,
195
+ )
196
+ self.cb.put((result))
197
+ urls.append(result)
198
+ stickers_ok += len(stickers)
199
+
200
+ except SignalException as e:
201
+ self.cb.put(
202
+ I("Failed to upload pack {}. Reason: {}").format(
203
+ pack_title, repr(e)
204
+ )
205
+ )
206
+
207
+ return stickers_ok, stickers_total, urls
208
+
209
+ @staticmethod
210
+ def start(
211
+ opt_output: OutputOption,
212
+ opt_comp: CompOption,
213
+ opt_cred: CredOption,
214
+ cb: CallbackProtocol,
215
+ cb_return: CallbackReturn,
216
+ ) -> Tuple[int, int, List[str]]:
217
+ exporter = UploadSignal(opt_output, opt_comp, opt_cred, cb, cb_return)
218
+ return exporter.upload_stickers_signal()