Skip to content

Commit 477c76a

Browse files
committed
code quality improvements and use loguru
1 parent 18e4d2b commit 477c76a

20 files changed

+512
-284
lines changed

README.md

Lines changed: 98 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,12 @@
1212

1313
<img src="readme-assets/icons/name.png" alt="Project Icon" width="750">
1414

15-
Download sticker packs from Telegram
16-
17-
## Basic Use
18-
19-
- NOTE: You need a telegram bot token to make use of the script. Generate a bot
20-
token and paste in a file called 'env'. Send a message to @BotFather to get started.
21-
- Create a file called 'env' (or env.txt) and paste your token
22-
- Get the URL of the telegram sticker pack
23-
- Run the program `python -m tstickers`
24-
- Enter the URL of the sticker pack
25-
- Get the output in the `downloads` folder.
26-
27-
More info at [Tutorials](/documentation/tutorials)
15+
The `tstickers` package provides functionality for downloading and converting sticker packs from https://t.me/addstickers. Download stickers, and convert them to multiple formats, with caching the converted stickers for faster retrieval.
2816

2917
- [Basic Use](#basic-use)
18+
- [Using](#using)
19+
- [Help](#help)
3020
- [Documentation](#documentation)
31-
- [Help](#help)
3221
- [Formats](#formats)
3322
- [Install With PIP](#install-with-pip)
3423
- [Language information](#language-information)
@@ -61,6 +50,101 @@ More info at [Tutorials](/documentation/tutorials)
6150
- [Support](#support)
6251
- [Rationale](#rationale)
6352

53+
## Basic Use
54+
55+
https://t.me/addstickers/DonutTheDog
56+
57+
- NOTE: You need a telegram bot token to make use of the script. Generate a bot
58+
token and paste in a file called 'env'. Send a message to @BotFather to get started.
59+
- Create a file called 'env' (or env.txt) and paste your token
60+
- Get the URL of the telegram sticker pack
61+
- Run the program `python -m tstickers`
62+
- Enter the URL of the sticker pack
63+
- Get the output in the `downloads` folder.
64+
65+
More info at [Tutorials](/documentation/tutorials)
66+
67+
## Using
68+
69+
1. Get the URL of the Signal sticker pack. In the form https://t.me/addstickers
70+
71+
2. Pass in multiple packs from the commandline with `-p/--pack`
72+
73+
```bash
74+
$ tstickers --pack https://t.me/addstickers/DonutTheDog
75+
INFO | ============================================================
76+
INFO | Starting to scrape "DonutTheDog" ..
77+
INFO | Time taken to scrape 31 stickers - 0.044s
78+
INFO |
79+
INFO | ------------------------------------------------------------
80+
INFO | Starting download of "donutthedog" into downloads\donutthedog
81+
INFO | Time taken to download 31 stickers - 0.157s
82+
INFO |
83+
INFO | ------------------------------------------------------------
84+
INFO | -> Cache miss for DonutTheDog!
85+
INFO | Converting stickers "DonutTheDog"...
86+
INFO | Time taken to convert 31 stickers (tgs) - 60.970s
87+
INFO |
88+
INFO | Time taken to convert 31 stickers (webp) - 0.447s
89+
INFO |
90+
INFO | Time taken to convert 62 stickers (total) - 61.434s
91+
INFO |
92+
93+
```
94+
95+
3. OR. Enter the URL of the sticker pack when prompted
96+
97+
```bash
98+
$ python -m tstickers
99+
Enter sticker_set URL (leave blank to stop): https://t.me/addstickers/DonutTheDog
100+
Enter sticker_set URL (leave blank to stop):
101+
INFO | ============================================================
102+
INFO | Starting to scrape "DonutTheDog" ..
103+
INFO | Time taken to scrape 31 stickers - 0.044s
104+
INFO |
105+
INFO | ------------------------------------------------------------
106+
INFO | Starting download of "donutthedog" into downloads\donutthedog
107+
INFO | Time taken to download 31 stickers - 0.157s
108+
INFO |
109+
INFO | ------------------------------------------------------------
110+
...
111+
```
112+
113+
4. Get the output in the `downloads` folder.
114+
115+
```powershell
116+
$ ls .\downloads\donutthedog\
117+
118+
Mode LastWriteTime Length Name
119+
---- ------------- ------ ----
120+
d----- 17/03/2024 17꞉00 apng
121+
d----- 17/03/2024 17꞉01 gif
122+
d----- 17/03/2024 17꞉06 png
123+
d----- 17/03/2024 17꞉00 tgs
124+
d----- 17/03/2024 17꞉02 webp
125+
```
126+
127+
## Help
128+
129+
```bash
130+
$ python -m tstickers --help
131+
usage: Welcome to TStickers, providing all of your sticker needs [-h] [-t TOKEN] [-p PACK [PACK ...]]
132+
[--frameskip FRAMESKIP] [--scale SCALE]
133+
[-b {rlottie-python,pyrlottie}]
134+
135+
options:
136+
-h, --help show this help message and exit
137+
-t TOKEN, --token TOKEN
138+
Pass in a bot token inline
139+
-p PACK [PACK ...], --pack PACK [PACK ...]
140+
Pass in a pack url inline
141+
--frameskip FRAMESKIP
142+
Set frameskip. default=1
143+
--scale SCALE Set scale. default=1.0
144+
-b {rlottie-python,pyrlottie}, --backend {rlottie-python,pyrlottie}
145+
Specify the convert backend
146+
```
147+
64148
## Documentation
65149
66150
A high-level overview of how the documentation is organized organized will help you know
@@ -76,22 +160,6 @@ where to look for certain things:
76160
may have.
77161
-->
78162
79-
### Help
80-
81-
```sh
82-
usage: Welcome to TStickers, providing all of your sticker needs [-h] [-t TOKEN] [-p PACK] [--frameskip FRAMESKIP]
83-
[--scale SCALE]
84-
85-
optional arguments:
86-
-h, --help show this help message and exit
87-
-t TOKEN, --token TOKEN
88-
Pass in a bot token inline
89-
-p PACK, --pack PACK Pass in a pack url inline
90-
--frameskip FRAMESKIP
91-
Set frameskip. default=1
92-
--scale SCALE Set scale. default=1.0
93-
```
94-
95163
## Formats
96164
97165
| Format | Static | Animated | Animated (webm) |

documentation/reference/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ A full list of `Tstickers` project modules.
77
- [Tstickers](tstickers/index.md#tstickers)
88
- [Module](tstickers/module.md#module)
99
- [Caching](tstickers/caching.md#caching)
10+
- [Cli](tstickers/cli.md#cli)
1011
- [Convert](tstickers/convert.md#convert)
1112
- [Convert Pyrlottie](tstickers/convert_pyrlottie.md#convert-pyrlottie)
1213
- [Convert Rlottie Python](tstickers/convert_rlottie_python.md#convert-rlottie-python)

documentation/reference/tstickers/caching.md

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,45 @@
1010

1111

1212
- [Caching](#caching)
13-
- [_verifyConvertedV1](#_verifyconvertedv1)
14-
- [createConverted](#createconverted)
15-
- [verifyConverted](#verifyconverted)
13+
- [_get_verify_function](#_get_verify_function)
14+
- [_verify_converted_v1](#_verify_converted_v1)
15+
- [create_converted](#create_converted)
16+
- [verify_converted](#verify_converted)
1617

17-
## _verifyConvertedV1
18+
## _get_verify_function
1819

19-
[Show source in caching.py:47](../../../tstickers/caching.py#L47)
20+
[Show source in caching.py:83](../../../tstickers/caching.py#L83)
21+
22+
Get the appropriate cache verification function based on version.
23+
24+
#### Arguments
25+
26+
----
27+
- `version` *int* - Cache version
28+
29+
#### Returns
30+
31+
-------
32+
Callable[[dict[str, Any]], bool]: Cache verification function
33+
34+
#### Signature
35+
36+
```python
37+
def _get_verify_function(version: int) -> Callable[[dict[str, Any]], bool]: ...
38+
```
39+
40+
41+
42+
## _verify_converted_v1
43+
44+
[Show source in caching.py:51](../../../tstickers/caching.py#L51)
2045

2146
Verify the cache for a packName using cache data.
2247

2348
#### Arguments
2449

2550
----
26-
data (dict[str, Any]) packName cache data to verify
51+
data (dict[Path, Any]): packName cache data to verify
2752

2853
#### Returns
2954

@@ -33,42 +58,42 @@ Verify the cache for a packName using cache data.
3358
#### Signature
3459

3560
```python
36-
def _verifyConvertedV1(data: dict[str, Any]): ...
61+
def _verify_converted_v1(data: dict[str, Any]) -> bool: ...
3762
```
3863

3964

4065

41-
## createConverted
66+
## create_converted
4267

43-
[Show source in caching.py:66](../../../tstickers/caching.py#L66)
68+
[Show source in caching.py:70](../../../tstickers/caching.py#L70)
4469

4570
Write cache data to a file identified by packName.
4671

4772
#### Arguments
4873

4974
----
50-
- `packName` *str* - name of the sticker pack eg. "DonutTheDog"
75+
- `pack_name` *str* - name of the sticker pack eg. "DonutTheDog"
5176
- `data` *dict* - packName cache data to write to cache
5277

5378
#### Signature
5479

5580
```python
56-
def createConverted(packName: str, data: dict) -> None: ...
81+
def create_converted(pack_name: str, data: dict) -> None: ...
5782
```
5883

5984

6085

61-
## verifyConverted
86+
## verify_converted
6287

63-
[Show source in caching.py:21](../../../tstickers/caching.py#L21)
88+
[Show source in caching.py:27](../../../tstickers/caching.py#L27)
6489

6590
Verify the cache for a packName eg. "DonutTheDog". Uses the cache "version"
6691
to call the verify function for that version.
6792

6893
#### Arguments
6994

7095
----
71-
- `packName` *str* - name of the sticker pack eg. "DonutTheDog"
96+
- `pack_name` *str* - name of the sticker pack eg. "DonutTheDog"
7297

7398
#### Returns
7499

@@ -78,5 +103,5 @@ to call the verify function for that version.
78103
#### Signature
79104

80105
```python
81-
def verifyConverted(packName: str) -> bool: ...
106+
def verify_converted(pack_name: str) -> bool: ...
82107
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Cli
2+
3+
[Tstickers Index](../README.md#tstickers-index) / [Tstickers](./index.md#tstickers) / Cli
4+
5+
> Auto-generated documentation for [tstickers.cli](../../../tstickers/cli.py) module.
6+
7+
- [Cli](#cli)
8+
- [cli](#cli)
9+
10+
## cli
11+
12+
[Show source in cli.py:17](../../../tstickers/cli.py#L17)
13+
14+
Cli entry point.
15+
16+
#### Signature
17+
18+
```python
19+
def cli() -> None: ...
20+
```

0 commit comments

Comments
 (0)