Skip to content

Commit bceec71

Browse files
committed
install pyrlottie by default/ regardless
1 parent c19b2e4 commit bceec71

File tree

8 files changed

+138
-98
lines changed

8 files changed

+138
-98
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
All major and minor version changes will be documented in this file. Details of
44
patch-level version changes can be found in [commit messages](../../commits/master).
55

6+
## 2024.1.3 - 2024/08/26
7+
8+
- be opinionated and install `pyrlottie` by default/ regardless
9+
- clearly notify user if backend is not installed
10+
611
## 2024.1.2 - 2024/03/25
712

813
- revert 'fix'

documentation/reference/tstickers/cli.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@
66
77
- [Cli](#cli)
88
- [cli](#cli)
9+
- [is_library_installed](#is_library_installed)
910

1011
## cli
1112

12-
[Show source in cli.py:17](../../../tstickers/cli.py#L17)
13+
[Show source in cli.py:22](../../../tstickers/cli.py#L22)
1314

1415
Cli entry point.
1516

1617
#### Signature
1718

1819
```python
1920
def cli() -> None: ...
21+
```
22+
23+
24+
25+
## is_library_installed
26+
27+
[Show source in cli.py:18](../../../tstickers/cli.py#L18)
28+
29+
#### Signature
30+
31+
```python
32+
def is_library_installed(library_name: str) -> bool: ...
2033
```

documentation/tutorials/README.md

+8-76
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,12 @@
1-
<!-- omit in toc -->
2-
# Tutorial
31

4-
See below for a step-by-step tutorial on how to use TStickers
2+
# TStickers Tutorials and User Guides
53

6-
- [Step 1 - Send a message to @BotFather](#step-1---send-a-message-to-botfather)
7-
- [Step 2 - Create a file called 'env'](#step-2---create-a-file-called-env)
8-
- [Step 3 - Get the URL of the telegram sticker pack(s)](#step-3---get-the-url-of-the-telegram-sticker-packs)
9-
- [Option 1 - Use a browser and search for the pack](#option-1---use-a-browser-and-search-for-the-pack)
10-
- [Option 2 - Use telegram](#option-2---use-telegram)
11-
- [Step 4 - Use TStickers](#step-4---use-tstickers)
4+
Welcome to the TStickers tutorials. This section provides a handful of tutorials
5+
to help you get started with TStickers and make the most of its features.
126

13-
## Step 1 - Send a message to @BotFather
7+
## Resource Table
148

15-
1. You must have a telegram account to use this
16-
2. Send a message to @BotFather to get started.
17-
3. Send a message containing `/newbot`
18-
4. Send a message containing the name of the bot e.g. `/test`
19-
5. Send a message containing the username of the bot e.g. `/test_bot`
20-
6. @BotFather will send a message with the token
21-
22-
<img src="assets/step1.png" alt="Step 1" width="600">
23-
24-
## Step 2 - Create a file called 'env'
25-
26-
Create a file called 'env' (or env.txt) and paste your token from part 1.
27-
28-
e.g. `env.txt`
29-
30-
```txt
31-
14************
32-
```
33-
34-
## Step 3 - Get the URL of the telegram sticker pack(s)
35-
36-
### Option 1 - Use a browser and search for the pack
37-
38-
1. Use a browser and search for the pack e.g. `telegram donut the dog`
39-
40-
<img src="assets/step3_0.png" alt="Step 3: Part 1" width="300">
41-
42-
2. Click on the link
43-
3. Copy the url: e.g. `https://t.me/addstickers/DonutTheDog`
44-
45-
### Option 2 - Use telegram
46-
47-
1. Open telegram, find the desired sticker pack and share the pack (on mobile pick copy link). An example of sharing a pack is below
48-
49-
<img src="assets/step3_1.png" alt="Step 3: Part 2" width="300">
50-
51-
2. Click on share stickers/ link - this will copy the url: e.g. `https://t.me/addstickers/DonutTheDog`
52-
53-
## Step 4 - Use TStickers
54-
55-
- Run the program `python -m tstickers`
56-
- Enter the URL of the sticker pack
57-
- Get the output in the `downloads` folder.
58-
59-
```bash
60-
$ tstickers
61-
Enter sticker_set url (leave blank to stop): https://t.me/addstickers/DonutTheDog
62-
Enter sticker_set url (leave blank to stop):
63-
INFO | ============================================================
64-
INFO | Starting to scrape "DonutTheDog" ..
65-
INFO | Time taken to scrape 31 stickers - 0.044s
66-
INFO |
67-
INFO | ------------------------------------------------------------
68-
INFO | Starting download of "donutthedog" into downloads\donutthedog
69-
INFO | Time taken to download 31 stickers - 0.157s
70-
INFO |
71-
INFO | ------------------------------------------------------------
72-
INFO | -> Cache miss for DonutTheDog!
73-
INFO | Converting stickers "DonutTheDog"...
74-
INFO | Time taken to convert 31 stickers (tgs) - 60.970s
75-
INFO |
76-
INFO | Time taken to convert 31 stickers (webp) - 0.447s
77-
INFO |
78-
INFO | Time taken to convert 62 stickers (total) - 61.434s
79-
INFO |
80-
```
9+
| Guide | Description | Link |
10+
|-----------------------|---------------------|---------------------------------------|
11+
| **getting-started.md** | This guide will walk you through the initial setup of TStickers, including installation and basic usage. | [View getting-started.md](./getting-started.md) |
12+
| **backends.md** | Learn about the different backend options available with TStickers. | [View backends.md](./backends.md) |
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!-- omit in toc -->
2+
# Tutorial
3+
4+
See below for a step-by-step tutorial on how to use TStickers
5+
6+
- [Step 1 - Send a message to @BotFather](#step-1---send-a-message-to-botfather)
7+
- [Step 2 - Create a file called 'env'](#step-2---create-a-file-called-env)
8+
- [Step 3 - Get the URL of the telegram sticker pack(s)](#step-3---get-the-url-of-the-telegram-sticker-packs)
9+
- [Option 1 - Use a browser and search for the pack](#option-1---use-a-browser-and-search-for-the-pack)
10+
- [Option 2 - Use telegram](#option-2---use-telegram)
11+
- [Step 4 - Use TStickers](#step-4---use-tstickers)
12+
13+
## Step 1 - Send a message to @BotFather
14+
15+
1. You must have a telegram account to use this
16+
2. Send a message to @BotFather to get started.
17+
3. Send a message containing `/newbot`
18+
4. Send a message containing the name of the bot e.g. `/test`
19+
5. Send a message containing the username of the bot e.g. `/test_bot`
20+
6. @BotFather will send a message with the token
21+
22+
<img src="assets/step1.png" alt="Step 1" width="600">
23+
24+
## Step 2 - Create a file called 'env'
25+
26+
Create a file called 'env' (or env.txt) and paste your token from part 1.
27+
28+
e.g. `env.txt`
29+
30+
```txt
31+
14************
32+
```
33+
34+
## Step 3 - Get the URL of the telegram sticker pack(s)
35+
36+
### Option 1 - Use a browser and search for the pack
37+
38+
1. Use a browser and search for the pack e.g. `telegram donut the dog`
39+
40+
<img src="assets/step3_0.png" alt="Step 3: Part 1" width="300">
41+
42+
2. Click on the link
43+
3. Copy the url: e.g. `https://t.me/addstickers/DonutTheDog`
44+
45+
### Option 2 - Use telegram
46+
47+
1. Open telegram, find the desired sticker pack and share the pack (on mobile pick copy link). An example of sharing a pack is below
48+
49+
<img src="assets/step3_1.png" alt="Step 3: Part 2" width="300">
50+
51+
2. Click on share stickers/ link - this will copy the url: e.g. `https://t.me/addstickers/DonutTheDog`
52+
53+
## Step 4 - Use TStickers
54+
55+
- Run the program `python -m tstickers`
56+
- Enter the URL of the sticker pack
57+
- Get the output in the `downloads` folder.
58+
59+
```bash
60+
$ tstickers
61+
Enter sticker_set url (leave blank to stop): https://t.me/addstickers/DonutTheDog
62+
Enter sticker_set url (leave blank to stop):
63+
INFO | ============================================================
64+
INFO | Starting to scrape "DonutTheDog" ..
65+
INFO | Time taken to scrape 31 stickers - 0.044s
66+
INFO |
67+
INFO | ------------------------------------------------------------
68+
INFO | Starting download of "donutthedog" into downloads\donutthedog
69+
INFO | Time taken to download 31 stickers - 0.157s
70+
INFO |
71+
INFO | ------------------------------------------------------------
72+
INFO | -> Cache miss for DonutTheDog!
73+
INFO | Converting stickers "DonutTheDog"...
74+
INFO | Time taken to convert 31 stickers (tgs) - 60.970s
75+
INFO |
76+
INFO | Time taken to convert 31 stickers (webp) - 0.447s
77+
INFO |
78+
INFO | Time taken to convert 62 stickers (total) - 61.434s
79+
INFO |
80+
```

move_webp_stickers.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33

44
source_dir = Path("./downloads")
55

6-
packnames = [
7-
name.name for name in source_dir.iterdir() if name.is_dir()
8-
]
6+
packnames = [name.name for name in source_dir.iterdir() if name.is_dir()]
97

108
for packname in packnames:
119
source_path = source_dir / packname / "webp"
1210
dest_path = Path("./sorted") / packname
1311

14-
1512
print(packname)
1613

1714
if not dest_path.exists():

pyproject.toml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tstickers"
3-
version = "2024.1.2"
3+
version = "2024.1.3"
44
license = "mit"
55
description = "Download sticker packs from Telegram"
66
authors = ["FredHappyface"]
@@ -22,12 +22,12 @@ readme = "README.md"
2222

2323
[tool.poetry.dependencies]
2424
python = ">=3.9,<4.0"
25-
requests = "<3,>=2.31.0"
26-
Pillow = "<11,>=10.2.0"
27-
emoji = "<3,>=2.10.1"
28-
requests-cache = "<2,>=1.2.0"
29-
rlottie-python = { version = "<2,>=1.3.3", optional = true }
30-
pyrlottie = { version = "<2026,>=2024.0.1", optional = true }
25+
requests = "<3,>=2.32.3"
26+
Pillow = "<11,>=10.4.0"
27+
emoji = "<3,>=2.12.1"
28+
requests-cache = "<2,>=1.2.1"
29+
rlottie-python = { version = "<2,>=1.3.6", optional = true }
30+
pyrlottie = "<2026,>=2024.0.1"
3131
loguru = "<2,>=0.7.2"
3232

3333
[tool.poetry.scripts]
@@ -56,14 +56,14 @@ target-version = "py38"
5656
[tool.ruff.lint]
5757
select = ["ALL"]
5858
ignore = [
59-
"ANN101", # type annotation for self in method
60-
"COM812", # enforce trailing comma
61-
"D2", # pydocstyle formatting
59+
"ANN101", # type annotation for self in method
60+
"COM812", # enforce trailing comma
61+
"D2", # pydocstyle formatting
6262
"ISC001",
63-
"N", # pep8 naming
63+
"N", # pep8 naming
6464
"PLR09", # pylint refactor too many
65-
"TCH", # type check blocks
66-
"W191" # ignore this to allow tabs
65+
"TCH", # type check blocks
66+
"W191", # ignore this to allow tabs
6767
]
6868
fixable = ["ALL"]
6969

requirements.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Pillow<11,>=10.2.0
2-
emoji<3,>=2.10.1
1+
Pillow<11,>=10.4.0
2+
emoji<3,>=2.12.1
33
loguru<2,>=0.7.2
4-
requests-cache<2,>=1.2.0
5-
requests<3,>=2.31.0
4+
pyrlottie<2026,>=2024.0.1
5+
requests-cache<2,>=1.2.1
6+
requests<3,>=2.32.3

tstickers/cli.py

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import argparse
66
import functools
7+
import importlib.util
78
import operator
89
from pathlib import Path
910
from sys import exit as sysexit
@@ -14,6 +15,10 @@
1415
from tstickers.downloader import StickerDownloader
1516

1617

18+
def is_library_installed(library_name: str) -> bool:
19+
return importlib.util.find_spec(library_name) is not None
20+
21+
1722
def cli() -> None: # pragma: no cover
1823
"""Cli entry point."""
1924
parser = argparse.ArgumentParser("Welcome to TStickers, providing all of your sticker needs")
@@ -68,6 +73,13 @@ def cli() -> None: # pragma: no cover
6873
"message to @BotFather to get started"
6974
)
7075
sysexit(1)
76+
# Get the backend
77+
backend = args.backend
78+
79+
if not is_library_installed(backend):
80+
logger.error(f'!! {backend} is not installed! Install with "pip install {backend}"')
81+
sysexit(2)
82+
7183
# Get the packs
7284

7385
packs = []

0 commit comments

Comments
 (0)