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,156 +1,186 @@
1
- #!/usr/bin/env python3
2
- import copy
3
- import shutil
4
- import zipfile
5
- from pathlib import Path
6
- from typing import Any, List
7
-
8
- from sticker_convert.converter import StickerConvert
9
- from sticker_convert.job_option import CompOption, CredOption, OutputOption
10
- from sticker_convert.uploaders.upload_base import UploadBase
11
- from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
12
- from sticker_convert.utils.files.cache_store import CacheStore
13
- from sticker_convert.utils.files.metadata_handler import MetadataHandler
14
- from sticker_convert.utils.files.sanitize_filename import sanitize_filename
15
- from sticker_convert.utils.media.codec_info import CodecInfo
16
- from sticker_convert.utils.media.format_verify import FormatVerify
17
-
18
-
19
- class CompressWastickers(UploadBase):
20
- def __init__(self, *args: Any, **kwargs: Any) -> None:
21
- super().__init__(*args, **kwargs)
22
- self.base_spec.size_max_img = 100000
23
- self.base_spec.size_max_vid = 500000
24
- self.base_spec.duration_min = 8
25
- self.base_spec.duration_max = 10000
26
- self.base_spec.square = True
27
- self.base_spec.set_res(512)
28
- self.base_spec.set_format((".webp",))
29
-
30
- self.spec_cover = CompOption(
31
- size_max_img=50000,
32
- size_max_vid=50000,
33
- animated=False,
34
- )
35
- self.spec_cover.set_res(96)
36
- self.spec_cover.set_res(96)
37
- self.spec_cover.set_fps(0)
38
- self.spec_cover.set_format((".png",))
39
-
40
- self.webp_spec = copy.deepcopy(self.base_spec)
41
- self.webp_spec.set_format((".webp",))
42
- self.webp_spec.animated = None if self.opt_comp.fake_vid else True
43
-
44
- self.png_spec = copy.deepcopy(self.base_spec)
45
- self.png_spec.set_format((".png",))
46
- self.png_spec.animated = False
47
-
48
- self.opt_comp_merged = copy.deepcopy(self.opt_comp)
49
- self.opt_comp_merged.merge(self.base_spec)
50
-
51
- def compress_wastickers(self) -> List[str]:
52
- urls: List[str] = []
53
- title, author, _ = MetadataHandler.get_metadata(
54
- self.opt_output.dir,
55
- title=self.opt_output.title,
56
- author=self.opt_output.author,
57
- )
58
- if not title:
59
- self.cb.put("Title is required for compressing .wastickers")
60
- return urls
61
- if not author:
62
- self.cb.put("Author is required for compressing .wastickers")
63
- return urls
64
- packs = MetadataHandler.split_sticker_packs(
65
- self.opt_output.dir,
66
- title=title,
67
- file_per_pack=30,
68
- separate_image_anim=not self.opt_comp.fake_vid,
69
- )
70
-
71
- for pack_title, stickers in packs.items():
72
- # Originally the Sticker Maker application name the files with int(time.time())
73
- with CacheStore.get_cache_store(path=self.opt_comp.cache_dir) as tempdir:
74
- for num, src in enumerate(stickers):
75
- self.cb.put(f"Verifying {src} for compressing into .wastickers")
76
-
77
- if self.opt_comp.fake_vid or CodecInfo.is_anim(src):
78
- ext = ".webp"
79
- else:
80
- ext = ".png"
81
-
82
- dst = Path(tempdir, f"sticker_{num+1}{ext}")
83
-
84
- if FormatVerify.check_file(
85
- src, spec=self.webp_spec
86
- ) or FormatVerify.check_file(src, spec=self.png_spec):
87
- shutil.copy(src, dst)
88
- else:
89
- StickerConvert.convert(
90
- Path(src),
91
- Path(dst),
92
- self.opt_comp_merged,
93
- self.cb,
94
- self.cb_return,
95
- )
96
-
97
- out_f = Path(
98
- self.opt_output.dir, sanitize_filename(pack_title + ".wastickers")
99
- ).as_posix()
100
-
101
- self.add_metadata(Path(tempdir), pack_title, author)
102
- with zipfile.ZipFile(out_f, "w", zipfile.ZIP_DEFLATED) as zipf:
103
- for file in Path(tempdir).iterdir():
104
- file_path = Path(tempdir, file.name)
105
- zipf.write(file_path, arcname=file_path.name)
106
-
107
- self.cb.put((out_f))
108
- urls.append(out_f)
109
-
110
- return urls
111
-
112
- def add_metadata(self, pack_dir: Path, title: str, author: str) -> None:
113
- opt_comp_merged = copy.deepcopy(self.opt_comp)
114
- opt_comp_merged.merge(self.spec_cover)
115
-
116
- cover_path_old = MetadataHandler.get_cover(self.opt_output.dir)
117
- cover_path_new = Path(pack_dir, "tray.png")
118
- if cover_path_old:
119
- if FormatVerify.check_file(cover_path_old, spec=self.spec_cover):
120
- shutil.copy(cover_path_old, cover_path_new)
121
- else:
122
- StickerConvert.convert(
123
- cover_path_old,
124
- cover_path_new,
125
- opt_comp_merged,
126
- self.cb,
127
- self.cb_return,
128
- )
129
- else:
130
- # First image in the directory, extracting first frame
131
- first_image = [
132
- i
133
- for i in sorted(self.opt_output.dir.iterdir())
134
- if Path(self.opt_output.dir, i.name).is_file()
135
- and i.suffix not in (".txt", ".m4a", ".wastickers")
136
- ][0]
137
- StickerConvert.convert(
138
- Path(self.opt_output.dir, first_image),
139
- cover_path_new,
140
- opt_comp_merged,
141
- self.cb,
142
- self.cb_return,
143
- )
144
-
145
- MetadataHandler.set_metadata(pack_dir, author=author, title=title, newline=True)
146
-
147
- @staticmethod
148
- def start(
149
- opt_output: OutputOption,
150
- opt_comp: CompOption,
151
- opt_cred: CredOption,
152
- cb: CallbackProtocol,
153
- cb_return: CallbackReturn,
154
- ) -> List[str]:
155
- exporter = CompressWastickers(opt_output, opt_comp, opt_cred, cb, cb_return)
156
- return exporter.compress_wastickers()
1
+ #!/usr/bin/env python3
2
+ import copy
3
+ import zipfile
4
+ from pathlib import Path
5
+ from typing import Any, List, Tuple
6
+
7
+ from sticker_convert.converter import StickerConvert
8
+ from sticker_convert.job_option import CompOption, CredOption, OutputOption
9
+ from sticker_convert.uploaders.upload_base import UploadBase
10
+ from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
11
+ from sticker_convert.utils.files.metadata_handler import MetadataHandler
12
+ from sticker_convert.utils.files.sanitize_filename import sanitize_filename
13
+ from sticker_convert.utils.media.codec_info import CodecInfo
14
+ from sticker_convert.utils.media.format_verify import FormatVerify
15
+ from sticker_convert.utils.translate import I
16
+
17
+
18
+ class CompressWastickers(UploadBase):
19
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
20
+ super().__init__(*args, **kwargs)
21
+ self.base_spec.size_max_img = 100000
22
+ self.base_spec.size_max_vid = 500000
23
+ self.base_spec.duration_min = 8
24
+ self.base_spec.duration_max = 10000
25
+ self.base_spec.set_res(512)
26
+ self.base_spec.set_format((".webp",))
27
+
28
+ self.spec_cover = CompOption(
29
+ size_max_img=50000,
30
+ size_max_vid=50000,
31
+ animated=False,
32
+ )
33
+ self.spec_cover.set_res(96)
34
+ self.spec_cover.set_res(96)
35
+ self.spec_cover.set_fps(0)
36
+ self.spec_cover.set_format((".png",))
37
+
38
+ self.webp_spec = copy.deepcopy(self.base_spec)
39
+ self.webp_spec.set_format((".webp",))
40
+ self.webp_spec.animated = None if self.opt_comp.fake_vid else True
41
+
42
+ self.png_spec = copy.deepcopy(self.base_spec)
43
+ self.png_spec.set_format((".png",))
44
+ self.png_spec.animated = False
45
+
46
+ self.opt_comp_merged = copy.deepcopy(self.opt_comp)
47
+ self.opt_comp_merged.merge(self.base_spec)
48
+
49
+ def compress_wastickers(self) -> Tuple[int, int, List[str]]:
50
+ urls: List[str] = []
51
+ title, author, _ = MetadataHandler.get_metadata(
52
+ self.opt_output.dir,
53
+ title=self.opt_output.title,
54
+ author=self.opt_output.author,
55
+ )
56
+ if not title:
57
+ self.cb.put(I("Title is required for compressing .wastickers"))
58
+ return 0, 0, urls
59
+ if not author:
60
+ self.cb.put(I("Author is required for compressing .wastickers"))
61
+ return 0, 0, urls
62
+ packs = MetadataHandler.split_sticker_packs(
63
+ self.opt_output.dir,
64
+ title=title,
65
+ file_per_pack=30,
66
+ separate_image_anim=not self.opt_comp.fake_vid,
67
+ )
68
+
69
+ stickers_total = 0
70
+ for pack_title, stickers in packs.items():
71
+ stickers_total += len(stickers)
72
+ out_f = Path(
73
+ self.opt_output.dir, sanitize_filename(pack_title + ".wastickers")
74
+ ).as_posix()
75
+
76
+ MetadataHandler.set_metadata(
77
+ self.opt_output.dir, author=author, title=title, newline=True
78
+ )
79
+ with zipfile.ZipFile(out_f, "w", zipfile.ZIP_DEFLATED) as zipf:
80
+ cover_opt_comp_merged = copy.deepcopy(self.opt_comp)
81
+ cover_opt_comp_merged.merge(self.spec_cover)
82
+
83
+ cover_path_old = MetadataHandler.get_cover(self.opt_output.dir)
84
+ cover_path_new = Path("bytes.png")
85
+ if cover_path_old is None:
86
+ # First image in the directory, extracting first frame
87
+ first_image = [
88
+ i
89
+ for i in sorted(self.opt_output.dir.iterdir())
90
+ if Path(self.opt_output.dir, i.name).is_file()
91
+ and i.suffix not in (".txt", ".m4a", ".wastickers")
92
+ ][0]
93
+ self.cb.put(I("Creating cover using {}").format(first_image.name))
94
+ success, _, cover_data, _ = StickerConvert.convert(
95
+ Path(self.opt_output.dir, first_image),
96
+ cover_path_new,
97
+ cover_opt_comp_merged,
98
+ self.cb,
99
+ self.cb_return,
100
+ )
101
+ if not success:
102
+ self.cb.put(
103
+ I(
104
+ "Warning: Cannot compress cover {}, unable to create .wastickers"
105
+ ).format(first_image.name)
106
+ )
107
+ continue
108
+ else:
109
+ if not FormatVerify.check_file(
110
+ cover_path_old, spec=self.spec_cover
111
+ ):
112
+ success, _, cover_data, _ = StickerConvert.convert(
113
+ cover_path_old,
114
+ cover_path_new,
115
+ cover_opt_comp_merged,
116
+ self.cb,
117
+ self.cb_return,
118
+ )
119
+ if not success:
120
+ self.cb.put(
121
+ I(
122
+ "Warning: Cannot compress cover {}, unable to create .wastickers"
123
+ ).format(cover_path_old.name)
124
+ )
125
+ continue
126
+ else:
127
+ with open(cover_path_old, "rb") as f:
128
+ cover_data = f.read()
129
+
130
+ assert isinstance(cover_data, bytes)
131
+ zipf.writestr("tray.png", cover_data)
132
+ zipf.write(Path(self.opt_output.dir, "author.txt"), "author.txt")
133
+ zipf.write(Path(self.opt_output.dir, "title.txt"), "title.txt")
134
+
135
+ for num, src in enumerate(stickers):
136
+ self.cb.put(
137
+ I("Verifying {} for compressing into .wastickers").format(src)
138
+ )
139
+
140
+ if self.opt_comp.fake_vid or CodecInfo.is_anim(src):
141
+ ext = ".webp"
142
+ else:
143
+ ext = ".png"
144
+ dst = f"bytes{ext}"
145
+
146
+ if not (
147
+ FormatVerify.check_file(src, spec=self.webp_spec)
148
+ or FormatVerify.check_file(src, spec=self.png_spec)
149
+ ):
150
+ success, _, image_data, _ = StickerConvert.convert(
151
+ Path(src),
152
+ Path(dst),
153
+ self.opt_comp_merged,
154
+ self.cb,
155
+ self.cb_return,
156
+ )
157
+ assert isinstance(image_data, bytes)
158
+ if not success:
159
+ self.cb.put(
160
+ I(
161
+ "Warning: Cannot compress file {}, skip this file..."
162
+ ).format(Path(src).name)
163
+ )
164
+ continue
165
+ else:
166
+ with open(src, "rb") as f:
167
+ image_data = f.read()
168
+
169
+ # Originally the Sticker Maker application name the files with int(time.time())
170
+ zipf.writestr(f"sticker_{num + 1}{ext}", image_data)
171
+
172
+ self.cb.put((out_f))
173
+ urls.append(out_f)
174
+
175
+ return stickers_total, stickers_total, urls
176
+
177
+ @staticmethod
178
+ def start(
179
+ opt_output: OutputOption,
180
+ opt_comp: CompOption,
181
+ opt_cred: CredOption,
182
+ cb: CallbackProtocol,
183
+ cb_return: CallbackReturn,
184
+ ) -> Tuple[int, int, List[str]]:
185
+ exporter = CompressWastickers(opt_output, opt_comp, opt_cred, cb, cb_return)
186
+ return exporter.compress_wastickers()
@@ -1,35 +1,44 @@
1
- #!/usr/bin/env python3
2
-
3
- from sticker_convert.job_option import CompOption, CredOption, OutputOption
4
- from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
5
-
6
-
7
- class UploadBase:
8
- def __init__(
9
- self,
10
- opt_output: OutputOption,
11
- opt_comp: CompOption,
12
- opt_cred: CredOption,
13
- cb: CallbackProtocol,
14
- cb_return: CallbackReturn,
15
- ) -> None:
16
- self.opt_output = opt_output
17
- self.opt_comp = opt_comp
18
- self.opt_cred = opt_cred
19
- self.cb = cb
20
- self.cb_return = cb_return
21
-
22
- self.base_spec = CompOption(
23
- fps_power=self.opt_comp.fps_power,
24
- res_power=self.opt_comp.res_power,
25
- quality_min=self.opt_comp.quality_min,
26
- quality_max=self.opt_comp.quality_max,
27
- quality_power=self.opt_comp.quality_power,
28
- color_min=self.opt_comp.color_min,
29
- color_max=self.opt_comp.color_max,
30
- color_power=self.opt_comp.color_power,
31
- quantize_method=self.opt_comp.quantize_method,
32
- scale_filter=self.opt_comp.scale_filter,
33
- steps=self.opt_comp.steps,
34
- cache_dir=self.opt_comp.cache_dir,
35
- )
1
+ #!/usr/bin/env python3
2
+ from sticker_convert.job_option import CompOption, CredOption, OutputOption
3
+ from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
4
+ from sticker_convert.utils.translate import I
5
+
6
+
7
+ def get_msg_emoji_txt_required():
8
+ return I(
9
+ "emoji.txt is required for uploading signal stickers\n"
10
+ "emoji.txt generated for you in {}\n"
11
+ "Default emoji is set to {}.\n"
12
+ "Please edit emoji.txt now, then continue"
13
+ )
14
+
15
+
16
+ class UploadBase:
17
+ def __init__(
18
+ self,
19
+ opt_output: OutputOption,
20
+ opt_comp: CompOption,
21
+ opt_cred: CredOption,
22
+ cb: CallbackProtocol,
23
+ cb_return: CallbackReturn,
24
+ ) -> None:
25
+ self.opt_output = opt_output
26
+ self.opt_comp = opt_comp
27
+ self.opt_cred = opt_cred
28
+ self.cb = cb
29
+ self.cb_return = cb_return
30
+
31
+ self.base_spec = CompOption(
32
+ fps_power=self.opt_comp.fps_power,
33
+ res_power=self.opt_comp.res_power,
34
+ quality_min=self.opt_comp.quality_min,
35
+ quality_max=self.opt_comp.quality_max,
36
+ quality_power=self.opt_comp.quality_power,
37
+ color_min=self.opt_comp.color_min,
38
+ color_max=self.opt_comp.color_max,
39
+ color_power=self.opt_comp.color_power,
40
+ quantize_method=self.opt_comp.quantize_method,
41
+ scale_filter=self.opt_comp.scale_filter,
42
+ steps=self.opt_comp.steps,
43
+ cache_dir=self.opt_comp.cache_dir,
44
+ )