sticker-convert 2.10.9__py3-none-any.whl → 2.11.1__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 (27) hide show
  1. sticker_convert/cli.py +46 -8
  2. sticker_convert/converter.py +13 -11
  3. sticker_convert/downloaders/download_base.py +5 -5
  4. sticker_convert/downloaders/download_signal.py +4 -2
  5. sticker_convert/downloaders/download_telegram.py +19 -103
  6. sticker_convert/gui.py +12 -0
  7. sticker_convert/gui_components/frames/cred_frame.py +38 -13
  8. sticker_convert/job.py +8 -8
  9. sticker_convert/job_option.py +6 -0
  10. sticker_convert/resources/compression.json +2 -2
  11. sticker_convert/resources/help.json +3 -2
  12. sticker_convert/resources/input.json +10 -0
  13. sticker_convert/resources/output.json +16 -0
  14. sticker_convert/uploaders/compress_wastickers.py +76 -56
  15. sticker_convert/uploaders/upload_telegram.py +170 -234
  16. sticker_convert/uploaders/upload_viber.py +18 -19
  17. sticker_convert/utils/auth/telegram_api.py +670 -0
  18. sticker_convert/utils/auth/telethon_setup.py +79 -0
  19. sticker_convert/utils/files/metadata_handler.py +3 -3
  20. sticker_convert/utils/url_detect.py +1 -1
  21. sticker_convert/version.py +1 -1
  22. {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.1.dist-info}/METADATA +53 -35
  23. {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.1.dist-info}/RECORD +27 -25
  24. {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.1.dist-info}/WHEEL +1 -1
  25. {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.1.dist-info}/LICENSE +0 -0
  26. {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.1.dist-info}/entry_points.txt +0 -0
  27. {sticker_convert-2.10.9.dist-info → sticker_convert-2.11.1.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
  import copy
3
3
  import json
4
- import shutil
5
4
  import zipfile
6
5
  from pathlib import Path
7
6
  from typing import Any, Dict, List, Tuple
@@ -12,7 +11,6 @@ from sticker_convert.converter import StickerConvert
12
11
  from sticker_convert.job_option import CompOption, CredOption, OutputOption
13
12
  from sticker_convert.uploaders.upload_base import UploadBase
14
13
  from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
15
- from sticker_convert.utils.files.cache_store import CacheStore
16
14
  from sticker_convert.utils.files.metadata_handler import MetadataHandler
17
15
  from sticker_convert.utils.files.sanitize_filename import sanitize_filename
18
16
  from sticker_convert.utils.media.format_verify import FormatVerify
@@ -96,31 +94,32 @@ class UploadViber(UploadBase):
96
94
  stickers_ok = 0
97
95
  for pack_title, stickers in packs.items():
98
96
  stickers_total += len(stickers)
99
- with CacheStore.get_cache_store(path=self.opt_comp.cache_dir) as tempdir:
97
+ out_f = Path(
98
+ self.opt_output.dir, sanitize_filename(pack_title + ".zip")
99
+ ).as_posix()
100
+ with zipfile.ZipFile(out_f, "w", zipfile.ZIP_DEFLATED) as zipf:
100
101
  for num, src in enumerate(stickers):
101
102
  self.cb.put(f"Verifying {src} for uploading to Viber")
102
103
 
103
- dst = Path(tempdir, f"{str(num).zfill(2)}.png")
104
-
105
- if FormatVerify.check_file(src, spec=self.png_spec):
106
- shutil.copy(src, dst)
107
- else:
108
- StickerConvert.convert(
109
- Path(src),
110
- Path(dst),
104
+ if not FormatVerify.check_file(src, spec=self.png_spec):
105
+ success, _, image_data, _ = StickerConvert.convert(
106
+ src,
107
+ Path("bytes.png"),
111
108
  self.opt_comp_merged,
112
109
  self.cb,
113
110
  self.cb_return,
114
111
  )
112
+ assert isinstance(image_data, bytes)
113
+ if not success:
114
+ self.cb.put(
115
+ f"Warning: Cannot compress file {src.name}, skip this file..."
116
+ )
117
+ continue
118
+ else:
119
+ with open(src, "rb") as f:
120
+ image_data = f.read()
115
121
 
116
- out_f = Path(
117
- self.opt_output.dir, sanitize_filename(pack_title + ".zip")
118
- ).as_posix()
119
-
120
- with zipfile.ZipFile(out_f, "w", zipfile.ZIP_DEFLATED) as zipf:
121
- for file in Path(tempdir).iterdir():
122
- file_path = Path(tempdir, file.name)
123
- zipf.write(file_path, arcname=file_path.name)
122
+ zipf.writestr(f"{str(num).zfill(2)}.png", image_data)
124
123
 
125
124
  upload_data = copy.deepcopy(upload_data_base)
126
125
  upload_data["title"] = pack_title