Tweet counter
Calculate the size that Twitter will consider a tweet to be.
This is not as advanced as the official twitter-text libraries, but attempts to at least take into account the following:
- Twitter will convert anything that looks like a URL (with a valid TLD) into a Twitter short link, and count it as taking up exactly 23 characters
- Twitter counts emoji and any unicode character above
U+2037as each taking up 2 characters
Installation
pip3 install tweet-counter
Python usage
from tweet_counter import count_tweet
print(count_tweet("Otters 👪 otters 𝗼𝘁𝘁𝗲𝗿𝘀 otters otters.com/otters"))
# Output => 60
Command-line usage
$ count-tweet "Otters 👪 otters 𝗼𝘁𝘁𝗲𝗿𝘀 otters otters.com/otters"
60
Metadata
Release files for tweet-counter 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tweet-counter-0.1.0.tar.gz | 2.8 kB | Details |
Release files / tweet-counter-0.1.0.tar.gz
| Download URL | tweet-counter-0.1.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69913254c01397b97f33eb058b887e991d2b2378cfeb3c0cd41d23c33d572221
|
|
BLAKE2b-256 checksum How to use checksums |
7997c7f93f13791aeeef1688a305f80c3bf8688c4690f587f715728eb144b27d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|