Skip to content

Commit ef9084a

Browse files
committed
Implemented buk.me service.
1 parent 4945454 commit ef9084a

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Supported URL shortening services for shrinking long urls:
1919
twurl.nl (tweetburner)
2020
digg.com
2121
a.gd
22+
buk.me
2223

2324
Shorty can expand any url service by getting the redirect
2425
location by requesting the tiny url.

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
+ buk.me
21
+ burnurl.com
32
+ chilp.it
43
+ fon.gs

shorty.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ def expand(self, tinyurl):
361361

362362
digg = Digg()
363363

364+
# a.gd
364365
class Agd(Service):
365366

366367
def shrink(self, bigurl, tag=None, password=None, expires=None):
@@ -381,6 +382,30 @@ def shrink(self, bigurl, tag=None, password=None, expires=None):
381382

382383
agd = Agd()
383384

385+
# buk.me
386+
class Bukme(Service):
387+
388+
def _process(self, resp):
389+
# bukme returns some markup after the url, so chop it off
390+
url = resp[:resp.find('<')]
391+
if url.startswith('http://'):
392+
return url
393+
else:
394+
raise ShortyError(url)
395+
396+
def shrink(self, bigurl, tag=None):
397+
parameters = {'url': bigurl}
398+
if tag:
399+
parameters['buk'] = tag
400+
resp = request('http://buk.me/api.php', parameters)
401+
return self._process(resp.read())
402+
403+
def expand(self, tinyurl):
404+
resp = request('http://buk.me/api.php', {'rev': tinyurl})
405+
return self._process(resp.read())
406+
407+
bukme = Bukme()
408+
384409
"""Mapping of domain to service class"""
385410
services = {
386411
'sandbox': sandbox,
@@ -392,7 +417,8 @@ def shrink(self, bigurl, tag=None, password=None, expires=None):
392417
'cli.gs': cligs,
393418
'tweetburner': tweetburner, 'twurl.nl': tweetburner,
394419
'digg.com': digg,
395-
'a.gd': agd
420+
'a.gd': agd,
421+
'buk.me': bukme
396422
}
397423

398424
"""

0 commit comments

Comments
 (0)