This project has been archived by its maintainers, and is no longer receiving any updates.
get-twitter-shortened-url (t_co)
t_co is…
- Get shortened link from Twitter URL Shortener (t.co)
- Available on package & CLI
Install
$ pip install get-twitter-shortened-url
Usage
from CLI
$ t_co -h
usage: t_co [-h] [-k key path] [--CK consumer key] [--CS consumer key secret]
[--AT accress token] [--AS access token secret] [-V]
url [url ...]
Shortened link from Twitter URL Shortener(t.co)
positional arguments:
url Urls you want to shorten.
optional arguments:
-h, --help show this help message and exit
-k key path, --key_path key path
Key file path (default: ~/.twitter.key)
--CK consumer key Twitter consumer key.
--CS consumer key secret
Twitter consumer key secret.
--AT accress token Twitter access token.
--AS access token secret
Twitter access token secret.
-V, --version show program's version number and exit
$ cat ~/.twitter.key
CONSUMER_KEY=xxxxxxxxxxxxxxxxxxx
CONSUMER_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ACCESS_TOKEN_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$ t_co https://google.co.jp 'https://www.youtube.com/watch?v=-8OqFcLyA8o'
https://google.co.jp => https://t.co/cpMOvCJCDU
https://www.youtube.com/watch?v=-8OqFcLyA8o => https://t.co/pTZgns1Fas
$ t_co 突うずるっ.com
突うずるっ.com => https://t.co/5Z1CN94Hrb
from package
import t_co
CK, CS, AT, AS = '...', '...', '...', '...'
t = t_co.Converter(CK, CS, AT, AS)
t.shorten(['https://google.co.jp'])
# => [{ 'url': 'https://t.co/cpMOvCJCDU',
# 'expanded_url': 'https://google.co.jp/',
# 'display_url': 'google.co.jp',
# 'original_url': 'https://google.co.jp' }]
t.shorten(['https://google.co.jp', 'https://www.youtube.com/watch?v=-8OqFcLyA8o'])
# => [{ 'url': 'https://t.co/cpMOvCJCDU',
# 'expanded_url': 'https://google.co.jp/',
# 'display_url': 'google.co.jp',
# 'original_url': 'https://google.co.jp' },
# { 'url': 'https://t.co/pTZgns1Fas',
# 'expanded_url': 'https://www.youtube.com/watch?v=-8OqFcLyA8o',
# 'display_url': 'youtube.com/watch?v=-8OqFc…',
# 'original_url': 'https://www.youtube.com/watch?v=-8OqFcLyA8o' }]
TIPS
- set keys with dotfile for safe
from os.path import expanduser, join
import os
from dotenv import load_dotenv
load_dotenv(join(expanduser("~"), '.twitter.key'))
CK, CS, AT, AS = [os.environ.get(_)
for _ in (
'CONSUMER_KEY', 'CONSUMER_SECRET',
'ACCESS_TOKEN', 'ACCESS_TOKEN_SECRET')]
- or, set keys on Terminal
$ export CONSUMER_KEY=xxxxxxxxxxxxxxxxxxx
$ export CONSUMER_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$ export ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$ export ACCESS_TOKEN_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Development
- local test
$ act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 --secret-file ~/.twitter.key
LISENCE
MIT
Author
eggplants (haruna)
Metadata
Release files for get-twitter-shortened-url 0.0.2
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 |
|---|---|---|---|---|
| get-twitter-shortened-url-0.0.2.tar.gz | 4.3 kB | Without provenance | Details for get-twitter-shortened-url-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| get_twitter_shortened_url-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for get_twitter_shortened_url-0.0.2-py3-none-any.whl |
Total release size: 10.0 kB
Release files / get-twitter-shortened-url-0.0.2.tar.gz
| Download URL | get-twitter-shortened-url-0.0.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb72682b591a489252aa9bc9fe2ca9d3ab429d6b9c6efce761733c3178156900
|
|
BLAKE2b-256 checksum How to use checksums |
79423aa3cdd348385ede5d6ceedd2236635bba8b38ff287d5cc3affd4b51f341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Release files / get_twitter_shortened_url-0.0.2-py3-none-any.whl
| Download URL | get_twitter_shortened_url-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa4ec3846b8cea1091516d00a1e11ed6ca622dcec3f069f4da7abe1a61f724b7
|
|
BLAKE2b-256 checksum How to use checksums |
af2581dd792147b71465c2d03e1345796df68e65a7d1853eea1f4920c3e2d142
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for get-twitter-shortened-url 0.0.2
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.