feat: make types and languages selectable

This commit is contained in:
2026-02-12 23:48:38 +01:00
parent 6405f8dd3b
commit 9253bcbe80
46 changed files with 248 additions and 178 deletions

View File

@@ -3,6 +3,7 @@ title: Yourls URL Shortener for Turpial
date: 2015-01-24T01:58:32+00:00
aliases: yourls-url-shortener-for-turpial
categories:
- blog
- english
tags:
- chat
@@ -21,19 +22,19 @@ And maybe you also know [Turpial][2], a Twitter client for GNU/Linux systems (I
Turpial already offers some link shorteners but not Yourls. But we can add it manually. To do so, open the file `/usr/lib/python2.7/dist-packages/libturpial/lib/services/url/shortypython/shorty.py` as root. Now add the following somewhere between the already existing shorteners
```py
# Yourls
class Yourls(Service):
def shrink(self, bigurl):
resp = request('http://YOUR_DOMAIN/yourls-api.php', {'action': 'shorturl', 'format': 'xml', 'url': bigurl, 'signature': 'YOUR_SIGNATURE'})
returned_data = resp.read()
matched_re = re.search('(http://YOUR_DOMAIN/[^"]+)', returned_data)
if matched_re:
return matched_re.group(1)
else:
raise ShortyError('Failed to shrink url')
yourls = Yourls()
# Yourls
class Yourls(Service):
def shrink(self, bigurl):
resp = request('http://YOUR_DOMAIN/yourls-api.php', {'action': 'shorturl', 'format': 'xml', 'url': bigurl, 'signature': 'YOUR_SIGNATURE'})
returned_data = resp.read()
matched_re = re.search('(http://YOUR_DOMAIN/[^"]+)', returned_data)
if matched_re:
return matched_re.group(1)
else:
raise ShortyError('Failed to shrink url')
yourls = Yourls()
```
Just replace `YOUR_DOMAIN` and `YOUR_SIGNATURE` accordingly. The usage of a signature enables you to hide your username and password when sending the shorten requests, like an API key and looks like `f51qw35w6` ([more about passwordlessAPI][4]). You can retrieve your signature on your Yourls Admin page via *Tools*.