Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/necraul/lain.la-link-shortener
URL Shortener using s.lain.la API
https://github.com/necraul/lain.la-link-shortener
lain python python3 requests shortener url-shortener
Last synced: about 4 hours ago
JSON representation
URL Shortener using s.lain.la API
- Host: GitHub
- URL: https://github.com/necraul/lain.la-link-shortener
- Owner: NecRaul
- License: lgpl-2.1
- Created: 2023-08-29T00:01:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-24T10:18:12.000Z (9 months ago)
- Last Synced: 2024-04-26T00:07:48.352Z (7 months ago)
- Topics: lain, python, python3, requests, shortener, url-shortener
- Language: Python
- Homepage: https://pypi.org/project/lain-shorten/
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lain.la-link-shortener
URL Shortener using s.lain.la API.
## Requirements
`requests` is used to send the API request.
`pyperclip` is used to copy the link to the clipboard.
If you want to build this on your own, you can install the requirements with
```Python
pip install -r requirements.txt
```or install the package by running
```Python
pip install lain-shorten
```Python's native `re` (used to check validity of the url), `argparse` (parse return request and set command argument) and `setuptools` (used to build the script) packages are also used.
## How it works
`s.lain.la` can shorten URLs using curl. I tend to forget the curl syntax and arguments quite easily, so I made a Python package to streamline things. Below is the aforementioned curl command.
```curl
curl -X POST -d 'url=https://yoururlhere.com' https://s.lain.la
```I just wrapped it inside Python and added validation to check for links and copied the return address to clipboard for ease of use.
You can run the script with
```Python
lain-shorten
```I added support for links not starting with http/https as well.