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 | Provenance | Actions |
|---|---|---|---|---|
| tweet-counter-0.1.0.tar.gz | 2.8 kB | Without provenance | Details for tweet-counter-0.1.0.tar.gz |
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
|
Security for tweet-counter 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.