sticker-convert 2.7.2__py3-none-any.whl → 2.7.4__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/__init__.py +1 -0
- sticker_convert/__main__.py +3 -1
- sticker_convert/cli.py +20 -24
- sticker_convert/converter.py +108 -119
- sticker_convert/definitions.py +8 -12
- sticker_convert/downloaders/download_base.py +14 -31
- sticker_convert/downloaders/download_kakao.py +25 -39
- sticker_convert/downloaders/download_line.py +24 -33
- sticker_convert/downloaders/download_signal.py +7 -16
- sticker_convert/downloaders/download_telegram.py +6 -15
- sticker_convert/gui.py +53 -61
- sticker_convert/gui_components/frames/comp_frame.py +11 -20
- sticker_convert/gui_components/frames/config_frame.py +9 -9
- sticker_convert/gui_components/frames/control_frame.py +3 -3
- sticker_convert/gui_components/frames/cred_frame.py +12 -18
- sticker_convert/gui_components/frames/input_frame.py +9 -15
- sticker_convert/gui_components/frames/output_frame.py +9 -15
- sticker_convert/gui_components/frames/progress_frame.py +8 -8
- sticker_convert/gui_components/frames/right_clicker.py +2 -2
- sticker_convert/gui_components/gui_utils.py +6 -8
- sticker_convert/gui_components/windows/advanced_compression_window.py +23 -32
- sticker_convert/gui_components/windows/base_window.py +6 -6
- sticker_convert/gui_components/windows/kakao_get_auth_window.py +5 -11
- sticker_convert/gui_components/windows/line_get_auth_window.py +5 -5
- sticker_convert/gui_components/windows/signal_get_auth_window.py +6 -6
- sticker_convert/job.py +84 -90
- sticker_convert/job_option.py +36 -32
- sticker_convert/resources/emoji.json +334 -70
- sticker_convert/resources/help.json +1 -1
- sticker_convert/uploaders/compress_wastickers.py +19 -30
- sticker_convert/uploaders/upload_base.py +19 -13
- sticker_convert/uploaders/upload_signal.py +20 -33
- sticker_convert/uploaders/upload_telegram.py +21 -28
- sticker_convert/uploaders/xcode_imessage.py +30 -95
- sticker_convert/utils/auth/get_kakao_auth.py +7 -8
- sticker_convert/utils/auth/get_line_auth.py +5 -6
- sticker_convert/utils/auth/get_signal_auth.py +7 -7
- sticker_convert/utils/callback.py +31 -23
- sticker_convert/utils/files/cache_store.py +6 -8
- sticker_convert/utils/files/json_manager.py +6 -7
- sticker_convert/utils/files/json_resources_loader.py +12 -0
- sticker_convert/utils/files/metadata_handler.py +93 -84
- sticker_convert/utils/files/run_bin.py +11 -10
- sticker_convert/utils/files/sanitize_filename.py +30 -28
- sticker_convert/utils/media/apple_png_normalize.py +3 -2
- sticker_convert/utils/media/codec_info.py +41 -44
- sticker_convert/utils/media/decrypt_kakao.py +7 -7
- sticker_convert/utils/media/format_verify.py +14 -14
- sticker_convert/utils/url_detect.py +4 -5
- sticker_convert/version.py +2 -1
- {sticker_convert-2.7.2.dist-info → sticker_convert-2.7.4.dist-info}/METADATA +19 -17
- {sticker_convert-2.7.2.dist-info → sticker_convert-2.7.4.dist-info}/RECORD +56 -55
- {sticker_convert-2.7.2.dist-info → sticker_convert-2.7.4.dist-info}/WHEEL +1 -1
- {sticker_convert-2.7.2.dist-info → sticker_convert-2.7.4.dist-info}/LICENSE +0 -0
- {sticker_convert-2.7.2.dist-info → sticker_convert-2.7.4.dist-info}/entry_points.txt +0 -0
- {sticker_convert-2.7.2.dist-info → sticker_convert-2.7.4.dist-info}/top_level.txt +0 -0
@@ -3,12 +3,12 @@ from __future__ import annotations
|
|
3
3
|
|
4
4
|
from pathlib import Path
|
5
5
|
from queue import Queue
|
6
|
-
from typing import Any, Optional, Union
|
6
|
+
from typing import Any, List, Optional, Tuple, Union
|
7
7
|
|
8
8
|
import requests
|
9
9
|
|
10
10
|
from sticker_convert.job_option import CredOption
|
11
|
-
from sticker_convert.utils.callback import Callback, CallbackReturn
|
11
|
+
from sticker_convert.utils.callback import Callback, CallbackReturn, CbQueueItemType
|
12
12
|
|
13
13
|
|
14
14
|
class DownloadBase:
|
@@ -18,35 +18,20 @@ class DownloadBase:
|
|
18
18
|
out_dir: Path,
|
19
19
|
opt_cred: Optional[CredOption],
|
20
20
|
cb: Union[
|
21
|
-
Queue[
|
22
|
-
Union[
|
23
|
-
tuple[str, Optional[tuple[str]], Optional[dict[str, Any]]],
|
24
|
-
str,
|
25
|
-
None,
|
26
|
-
]
|
27
|
-
],
|
21
|
+
Queue[CbQueueItemType],
|
28
22
|
Callback,
|
29
23
|
],
|
30
24
|
cb_return: CallbackReturn,
|
31
|
-
):
|
32
|
-
self.url
|
33
|
-
self.out_dir
|
34
|
-
self.opt_cred
|
35
|
-
self.cb
|
36
|
-
|
37
|
-
Union[
|
38
|
-
tuple[str, Optional[tuple[str]], Optional[dict[str, Any]]],
|
39
|
-
str,
|
40
|
-
None,
|
41
|
-
]
|
42
|
-
],
|
43
|
-
Callback,
|
44
|
-
] = cb
|
45
|
-
self.cb_return: CallbackReturn = cb_return
|
25
|
+
) -> None:
|
26
|
+
self.url = url
|
27
|
+
self.out_dir = out_dir
|
28
|
+
self.opt_cred = opt_cred
|
29
|
+
self.cb = cb
|
30
|
+
self.cb_return = cb_return
|
46
31
|
|
47
32
|
def download_multiple_files(
|
48
|
-
self, targets:
|
49
|
-
):
|
33
|
+
self, targets: List[Tuple[str, Path]], retries: int = 3, **kwargs: Any
|
34
|
+
) -> None:
|
50
35
|
# targets format: [(url1, dest2), (url2, dest2), ...]
|
51
36
|
self.cb.put(
|
52
37
|
("bar", None, {"set_progress_mode": "determinate", "steps": len(targets)})
|
@@ -75,8 +60,7 @@ class DownloadBase:
|
|
75
60
|
|
76
61
|
if response.status_code != 200:
|
77
62
|
return b""
|
78
|
-
|
79
|
-
self.cb.put(f"Downloading {url}")
|
63
|
+
self.cb.put(f"Downloading {url}")
|
80
64
|
|
81
65
|
if show_progress:
|
82
66
|
steps = (total_length / chunk_size) + 1
|
@@ -101,11 +85,10 @@ class DownloadBase:
|
|
101
85
|
|
102
86
|
if not result:
|
103
87
|
return b""
|
104
|
-
|
88
|
+
if dest:
|
105
89
|
with open(dest, "wb+") as f:
|
106
90
|
f.write(result)
|
107
91
|
msg = f"Downloaded {url}"
|
108
92
|
self.cb.put(msg)
|
109
93
|
return b""
|
110
|
-
|
111
|
-
return result
|
94
|
+
return result
|
@@ -6,7 +6,7 @@ import zipfile
|
|
6
6
|
from io import BytesIO
|
7
7
|
from pathlib import Path
|
8
8
|
from queue import Queue
|
9
|
-
from typing import Any, Optional, Union
|
9
|
+
from typing import Any, List, Optional, Tuple, Union
|
10
10
|
from urllib.parse import urlparse
|
11
11
|
|
12
12
|
import requests
|
@@ -15,14 +15,14 @@ from bs4.element import Tag
|
|
15
15
|
|
16
16
|
from sticker_convert.downloaders.download_base import DownloadBase
|
17
17
|
from sticker_convert.job_option import CredOption
|
18
|
-
from sticker_convert.utils.callback import Callback, CallbackReturn
|
18
|
+
from sticker_convert.utils.callback import Callback, CallbackReturn, CbQueueItemType
|
19
19
|
from sticker_convert.utils.files.metadata_handler import MetadataHandler
|
20
20
|
from sticker_convert.utils.media.decrypt_kakao import DecryptKakao
|
21
21
|
|
22
22
|
|
23
23
|
class MetadataKakao:
|
24
24
|
@staticmethod
|
25
|
-
def get_info_from_share_link(url: str) ->
|
25
|
+
def get_info_from_share_link(url: str) -> Tuple[Optional[str], Optional[str]]:
|
26
26
|
headers = {"User-Agent": "Android"}
|
27
27
|
|
28
28
|
response = requests.get(url, headers=headers)
|
@@ -40,7 +40,7 @@ class MetadataKakao:
|
|
40
40
|
data_urls = app_scheme_link_tag.get("data-url")
|
41
41
|
if not data_urls:
|
42
42
|
return None, None
|
43
|
-
|
43
|
+
if isinstance(data_urls, list):
|
44
44
|
data_url = data_urls[0]
|
45
45
|
else:
|
46
46
|
data_url = data_urls
|
@@ -52,7 +52,7 @@ class MetadataKakao:
|
|
52
52
|
@staticmethod
|
53
53
|
def get_info_from_pack_title(
|
54
54
|
pack_title: str,
|
55
|
-
) ->
|
55
|
+
) -> Tuple[Optional[str], Optional[str], Optional[str]]:
|
56
56
|
pack_meta_r = requests.get(f"https://e.kakao.com/api/v1/items/t/{pack_title}")
|
57
57
|
|
58
58
|
if pack_meta_r.status_code == 200:
|
@@ -111,8 +111,8 @@ class MetadataKakao:
|
|
111
111
|
|
112
112
|
|
113
113
|
class DownloadKakao(DownloadBase):
|
114
|
-
def __init__(self, *args: Any, **kwargs: Any):
|
115
|
-
super(
|
114
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
115
|
+
super().__init__(*args, **kwargs)
|
116
116
|
self.pack_title: Optional[str] = None
|
117
117
|
self.author: Optional[str] = None
|
118
118
|
|
@@ -128,13 +128,10 @@ class DownloadKakao(DownloadBase):
|
|
128
128
|
|
129
129
|
if item_code:
|
130
130
|
return self.download_animated(item_code)
|
131
|
-
|
132
|
-
|
133
|
-
"Download failed: Cannot download metadata for sticker pack"
|
134
|
-
)
|
135
|
-
return False
|
131
|
+
self.cb.put("Download failed: Cannot download metadata for sticker pack")
|
132
|
+
return False
|
136
133
|
|
137
|
-
|
134
|
+
if self.url.isnumeric() or self.url.startswith("kakaotalk://store/emoticon/"):
|
138
135
|
item_code = self.url.replace("kakaotalk://store/emoticon/", "")
|
139
136
|
|
140
137
|
self.pack_title = None
|
@@ -149,7 +146,7 @@ class DownloadKakao(DownloadBase):
|
|
149
146
|
|
150
147
|
return self.download_animated(item_code)
|
151
148
|
|
152
|
-
|
149
|
+
if urlparse(self.url).netloc == "e.kakao.com":
|
153
150
|
self.pack_title = self.url.replace("https://e.kakao.com/t/", "")
|
154
151
|
(
|
155
152
|
self.author,
|
@@ -171,31 +168,29 @@ class DownloadKakao(DownloadBase):
|
|
171
168
|
item_code = MetadataKakao.get_item_code(title_ko, auth_token)
|
172
169
|
if item_code:
|
173
170
|
return self.download_animated(item_code)
|
171
|
+
msg = "Warning: Cannot get item code.\n"
|
172
|
+
msg += "Is auth_token invalid / expired? Try to regenerate it.\n"
|
173
|
+
msg += "Continue to download static stickers instead?"
|
174
|
+
self.cb.put(("ask_bool", (msg,), None))
|
175
|
+
if self.cb_return:
|
176
|
+
response = self.cb_return.get_response()
|
174
177
|
else:
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
if self.cb_return:
|
180
|
-
response = self.cb_return.get_response()
|
181
|
-
else:
|
182
|
-
response = False
|
183
|
-
|
184
|
-
if response is False:
|
185
|
-
return False
|
178
|
+
response = False
|
179
|
+
|
180
|
+
if response is False:
|
181
|
+
return False
|
186
182
|
|
187
183
|
return self.download_static(thumbnail_urls)
|
188
184
|
|
189
|
-
|
190
|
-
|
191
|
-
return False
|
185
|
+
self.cb.put("Download failed: Unrecognized URL")
|
186
|
+
return False
|
192
187
|
|
193
188
|
def download_static(self, thumbnail_urls: str) -> bool:
|
194
189
|
MetadataHandler.set_metadata(
|
195
190
|
self.out_dir, title=self.pack_title, author=self.author
|
196
191
|
)
|
197
192
|
|
198
|
-
targets:
|
193
|
+
targets: List[Tuple[str, Path]] = []
|
199
194
|
|
200
195
|
for num, url in enumerate(thumbnail_urls):
|
201
196
|
dest = Path(self.out_dir, str(num).zfill(3) + ".png")
|
@@ -254,16 +249,7 @@ class DownloadKakao(DownloadBase):
|
|
254
249
|
url: str,
|
255
250
|
out_dir: Path,
|
256
251
|
opt_cred: Optional[CredOption],
|
257
|
-
cb: Union[
|
258
|
-
Queue[
|
259
|
-
Union[
|
260
|
-
tuple[str, Optional[tuple[str]], Optional[dict[str, str]]],
|
261
|
-
str,
|
262
|
-
None,
|
263
|
-
]
|
264
|
-
],
|
265
|
-
Callback,
|
266
|
-
],
|
252
|
+
cb: "Union[Queue[CbQueueItemType], Callback]",
|
267
253
|
cb_return: CallbackReturn,
|
268
254
|
) -> bool:
|
269
255
|
downloader = DownloadKakao(url, out_dir, opt_cred, cb, cb_return)
|
@@ -8,7 +8,7 @@ import zipfile
|
|
8
8
|
from io import BytesIO
|
9
9
|
from pathlib import Path
|
10
10
|
from queue import Queue
|
11
|
-
from typing import Any, Optional, Union
|
11
|
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
12
12
|
from urllib import parse
|
13
13
|
|
14
14
|
import requests
|
@@ -18,16 +18,16 @@ from PIL import Image
|
|
18
18
|
from sticker_convert.downloaders.download_base import DownloadBase
|
19
19
|
from sticker_convert.job_option import CredOption
|
20
20
|
from sticker_convert.utils.auth.get_line_auth import GetLineAuth
|
21
|
-
from sticker_convert.utils.callback import Callback, CallbackReturn
|
21
|
+
from sticker_convert.utils.callback import Callback, CallbackReturn, CbQueueItemType
|
22
22
|
from sticker_convert.utils.files.metadata_handler import MetadataHandler
|
23
23
|
from sticker_convert.utils.media.apple_png_normalize import ApplePngNormalize
|
24
24
|
|
25
|
-
|
25
|
+
# Reference: https://github.com/doubleplusc/Line-sticker-downloader/blob/master/sticker_dl.py
|
26
26
|
|
27
27
|
|
28
28
|
class MetadataLine:
|
29
29
|
@staticmethod
|
30
|
-
def analyze_url(url: str) -> Optional[
|
30
|
+
def analyze_url(url: str) -> Optional[Tuple[str, str, bool]]:
|
31
31
|
region = ""
|
32
32
|
is_emoji = False
|
33
33
|
if url.startswith("line://shop/detail/"):
|
@@ -78,7 +78,7 @@ class MetadataLine:
|
|
78
78
|
@staticmethod
|
79
79
|
def get_metadata_sticon(
|
80
80
|
pack_id: str, region: str
|
81
|
-
) -> Optional[
|
81
|
+
) -> Optional[Tuple[str, str, List[Dict[str, Any]], str, bool]]:
|
82
82
|
pack_meta_r = requests.get(
|
83
83
|
f"https://stickershop.line-scdn.net/sticonshop/v1/{pack_id}/sticon/iphone/meta.json"
|
84
84
|
)
|
@@ -122,7 +122,7 @@ class MetadataLine:
|
|
122
122
|
@staticmethod
|
123
123
|
def get_metadata_stickers(
|
124
124
|
pack_id: str, region: str
|
125
|
-
) -> Optional[
|
125
|
+
) -> Optional[Tuple[str, str, List[Dict[str, Any]], str, bool]]:
|
126
126
|
pack_meta_r = requests.get(
|
127
127
|
f"https://stickershop.line-scdn.net/stickershop/v1/product/{pack_id}/android/productInfo.meta"
|
128
128
|
)
|
@@ -160,18 +160,18 @@ class MetadataLine:
|
|
160
160
|
|
161
161
|
|
162
162
|
class DownloadLine(DownloadBase):
|
163
|
-
def __init__(self, *args: Any, **kwargs: Any):
|
164
|
-
super(
|
163
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
164
|
+
super().__init__(*args, **kwargs)
|
165
165
|
self.headers = {
|
166
166
|
"referer": "https://store.line.me",
|
167
167
|
"user-agent": "Android",
|
168
168
|
"x-requested-with": "XMLHttpRequest",
|
169
169
|
}
|
170
170
|
self.cookies = self.load_cookies()
|
171
|
-
self.sticker_text_dict:
|
171
|
+
self.sticker_text_dict: Dict[int, Any] = {}
|
172
172
|
|
173
|
-
def load_cookies(self) ->
|
174
|
-
cookies:
|
173
|
+
def load_cookies(self) -> Dict[str, str]:
|
174
|
+
cookies: Dict[str, str] = {}
|
175
175
|
if self.opt_cred and self.opt_cred.line_cookies:
|
176
176
|
line_cookies = self.opt_cred.line_cookies
|
177
177
|
|
@@ -226,7 +226,7 @@ class DownloadLine(DownloadBase):
|
|
226
226
|
num: int,
|
227
227
|
prefix: str = "",
|
228
228
|
suffix: str = "",
|
229
|
-
):
|
229
|
+
) -> None:
|
230
230
|
data = zf.read(f_path)
|
231
231
|
ext = Path(f_path).suffix
|
232
232
|
if ext == ".png" and not self.is_emoji and int() < 775:
|
@@ -237,7 +237,7 @@ class DownloadLine(DownloadBase):
|
|
237
237
|
with open(out_path, "wb") as f:
|
238
238
|
f.write(data)
|
239
239
|
|
240
|
-
def decompress_emoticon(self, zip_file: bytes):
|
240
|
+
def decompress_emoticon(self, zip_file: bytes) -> None:
|
241
241
|
with zipfile.ZipFile(BytesIO(zip_file)) as zf:
|
242
242
|
self.cb.put("Unzipping...")
|
243
243
|
|
@@ -258,7 +258,7 @@ class DownloadLine(DownloadBase):
|
|
258
258
|
|
259
259
|
self.cb.put("update_bar")
|
260
260
|
|
261
|
-
def decompress_stickers(self, zip_file: bytes):
|
261
|
+
def decompress_stickers(self, zip_file: bytes) -> None:
|
262
262
|
with zipfile.ZipFile(BytesIO(zip_file)) as zf:
|
263
263
|
self.cb.put("Unzipping...")
|
264
264
|
|
@@ -300,7 +300,7 @@ class DownloadLine(DownloadBase):
|
|
300
300
|
|
301
301
|
self.cb.put("update_bar")
|
302
302
|
|
303
|
-
def edit_custom_sticker_text(self):
|
303
|
+
def edit_custom_sticker_text(self) -> None:
|
304
304
|
line_sticker_text_path = Path(self.out_dir, "line-sticker-text.txt")
|
305
305
|
|
306
306
|
if not line_sticker_text_path.is_file():
|
@@ -319,9 +319,9 @@ class DownloadLine(DownloadBase):
|
|
319
319
|
with open(line_sticker_text_path, "r", encoding="utf-8") as f:
|
320
320
|
self.sticker_text_dict = json.load(f)
|
321
321
|
|
322
|
-
def get_custom_sticker_text_urls(self) ->
|
323
|
-
custom_sticker_text_urls:
|
324
|
-
name_text_key_cache:
|
322
|
+
def get_custom_sticker_text_urls(self) -> List[Tuple[str, Path]]:
|
323
|
+
custom_sticker_text_urls: List[Tuple[str, Path]] = []
|
324
|
+
name_text_key_cache: Dict[str, str] = {}
|
325
325
|
|
326
326
|
for num, data in self.sticker_text_dict.items():
|
327
327
|
out_path = Path(self.out_dir, str(num).zfill(3))
|
@@ -382,7 +382,7 @@ class DownloadLine(DownloadBase):
|
|
382
382
|
|
383
383
|
return name_text_key
|
384
384
|
|
385
|
-
def combine_custom_text(self):
|
385
|
+
def combine_custom_text(self) -> None:
|
386
386
|
for i in sorted(self.out_dir.iterdir()):
|
387
387
|
if i.name.endswith("-text.png"):
|
388
388
|
base_path = Path(self.out_dir, i.name.replace("-text.png", ".png"))
|
@@ -442,14 +442,14 @@ class DownloadLine(DownloadBase):
|
|
442
442
|
else:
|
443
443
|
self.decompress_stickers(zip_file)
|
444
444
|
|
445
|
-
custom_sticker_text_urls:
|
446
|
-
if self.sticker_text_dict
|
445
|
+
custom_sticker_text_urls: List[Tuple[str, Path]] = []
|
446
|
+
if self.sticker_text_dict and (
|
447
447
|
self.resource_type == "PER_STICKER_TEXT"
|
448
|
-
or (self.resource_type == "NAME_TEXT" and self.cookies
|
448
|
+
or (self.resource_type == "NAME_TEXT" and self.cookies)
|
449
449
|
):
|
450
450
|
self.edit_custom_sticker_text()
|
451
451
|
custom_sticker_text_urls = self.get_custom_sticker_text_urls()
|
452
|
-
elif self.resource_type == "NAME_TEXT" and self.cookies
|
452
|
+
elif self.resource_type == "NAME_TEXT" and not self.cookies:
|
453
453
|
self.cb.put('Warning: Line "Custom stickers" is supplied as input')
|
454
454
|
self.cb.put(
|
455
455
|
"However, adding custom message requires Line cookies, and it is not supplied"
|
@@ -466,16 +466,7 @@ class DownloadLine(DownloadBase):
|
|
466
466
|
url: str,
|
467
467
|
out_dir: Path,
|
468
468
|
opt_cred: Optional[CredOption],
|
469
|
-
cb: Union[
|
470
|
-
Queue[
|
471
|
-
Union[
|
472
|
-
tuple[str, Optional[tuple[str]], Optional[dict[str, str]]],
|
473
|
-
str,
|
474
|
-
None,
|
475
|
-
]
|
476
|
-
],
|
477
|
-
Callback,
|
478
|
-
],
|
469
|
+
cb: "Union[Queue[CbQueueItemType], Callback]",
|
479
470
|
cb_return: CallbackReturn,
|
480
471
|
) -> bool:
|
481
472
|
downloader = DownloadLine(url, out_dir, opt_cred, cb, cb_return)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
from pathlib import Path
|
3
3
|
from queue import Queue
|
4
|
-
from typing import
|
4
|
+
from typing import Dict, Optional, Union
|
5
5
|
|
6
6
|
import anyio
|
7
7
|
from signalstickers_client import StickersClient # type: ignore
|
@@ -10,14 +10,14 @@ from signalstickers_client.models import StickerPack # type: ignore
|
|
10
10
|
|
11
11
|
from sticker_convert.downloaders.download_base import DownloadBase
|
12
12
|
from sticker_convert.job_option import CredOption
|
13
|
-
from sticker_convert.utils.callback import Callback, CallbackReturn
|
13
|
+
from sticker_convert.utils.callback import Callback, CallbackReturn, CbQueueItemType
|
14
14
|
from sticker_convert.utils.files.metadata_handler import MetadataHandler
|
15
15
|
from sticker_convert.utils.media.codec_info import CodecInfo
|
16
16
|
|
17
17
|
|
18
18
|
class DownloadSignal(DownloadBase):
|
19
|
-
def __init__(self, *args: Any, **kwargs: Any):
|
20
|
-
|
19
|
+
# def __init__(self, *args: Any, **kwargs: Any) -> None:
|
20
|
+
# super().__init__(*args, **kwargs)
|
21
21
|
|
22
22
|
@staticmethod
|
23
23
|
async def get_pack(pack_id: str, pack_key: str) -> StickerPack:
|
@@ -26,7 +26,7 @@ class DownloadSignal(DownloadBase):
|
|
26
26
|
|
27
27
|
return pack
|
28
28
|
|
29
|
-
def save_stickers(self, pack: StickerPack):
|
29
|
+
def save_stickers(self, pack: StickerPack) -> None:
|
30
30
|
self.cb.put(
|
31
31
|
(
|
32
32
|
"bar",
|
@@ -38,7 +38,7 @@ class DownloadSignal(DownloadBase):
|
|
38
38
|
)
|
39
39
|
)
|
40
40
|
|
41
|
-
emoji_dict:
|
41
|
+
emoji_dict: Dict[str, str] = {}
|
42
42
|
for sticker in pack.stickers: # type: ignore
|
43
43
|
f_id = str(sticker.id).zfill(3) # type: ignore
|
44
44
|
f_path = Path(self.out_dir, f_id)
|
@@ -86,16 +86,7 @@ class DownloadSignal(DownloadBase):
|
|
86
86
|
url: str,
|
87
87
|
out_dir: Path,
|
88
88
|
opt_cred: Optional[CredOption],
|
89
|
-
cb: Union[
|
90
|
-
Queue[
|
91
|
-
Union[
|
92
|
-
tuple[str, Optional[tuple[str]], Optional[dict[str, str]]],
|
93
|
-
str,
|
94
|
-
None,
|
95
|
-
]
|
96
|
-
],
|
97
|
-
Callback,
|
98
|
-
],
|
89
|
+
cb: "Union[Queue[CbQueueItemType], Callback]",
|
99
90
|
cb_return: CallbackReturn,
|
100
91
|
) -> bool:
|
101
92
|
downloader = DownloadSignal(url, out_dir, opt_cred, cb, cb_return)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
from pathlib import Path
|
3
3
|
from queue import Queue
|
4
|
-
from typing import
|
4
|
+
from typing import Dict, Optional, Union
|
5
5
|
from urllib.parse import urlparse
|
6
6
|
|
7
7
|
import anyio
|
@@ -10,13 +10,13 @@ from telegram.error import TelegramError
|
|
10
10
|
|
11
11
|
from sticker_convert.downloaders.download_base import DownloadBase
|
12
12
|
from sticker_convert.job_option import CredOption
|
13
|
-
from sticker_convert.utils.callback import Callback, CallbackReturn
|
13
|
+
from sticker_convert.utils.callback import Callback, CallbackReturn, CbQueueItemType
|
14
14
|
from sticker_convert.utils.files.metadata_handler import MetadataHandler
|
15
15
|
|
16
16
|
|
17
17
|
class DownloadTelegram(DownloadBase):
|
18
|
-
def __init__(self, *args: Any, **kwargs: Any):
|
19
|
-
|
18
|
+
# def __init__(self, *args: Any, **kwargs: Any) -> None:
|
19
|
+
# super().__init__(*args, **kwargs)
|
20
20
|
|
21
21
|
def download_stickers_telegram(self) -> bool:
|
22
22
|
self.token = ""
|
@@ -63,7 +63,7 @@ class DownloadTelegram(DownloadBase):
|
|
63
63
|
)
|
64
64
|
)
|
65
65
|
|
66
|
-
emoji_dict:
|
66
|
+
emoji_dict: Dict[str, str] = {}
|
67
67
|
for num, i in enumerate(sticker_set.stickers):
|
68
68
|
sticker = await i.get_file(
|
69
69
|
read_timeout=30,
|
@@ -115,16 +115,7 @@ class DownloadTelegram(DownloadBase):
|
|
115
115
|
url: str,
|
116
116
|
out_dir: Path,
|
117
117
|
opt_cred: Optional[CredOption],
|
118
|
-
cb: Union[
|
119
|
-
Queue[
|
120
|
-
Union[
|
121
|
-
tuple[str, Optional[tuple[str]], Optional[dict[str, str]]],
|
122
|
-
str,
|
123
|
-
None,
|
124
|
-
]
|
125
|
-
],
|
126
|
-
Callback,
|
127
|
-
],
|
118
|
+
cb: "Union[Queue[CbQueueItemType], Callback]",
|
128
119
|
cb_return: CallbackReturn,
|
129
120
|
) -> bool:
|
130
121
|
downloader = DownloadTelegram(url, out_dir, opt_cred, cb, cb_return)
|