Skip to content

Commit 3f94da4

Browse files
committed
Implemented budurl.com service.
1 parent afb5026 commit 3f94da4

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Supported URL shortening services for shrinking long urls:
3232
chilp.it
3333
short.ie
3434
short.to
35+
to.ly
36+
budurl.com
3537

3638
Shorty can expand any url service by getting the redirect
3739
location by requesting the tiny url.

TODO

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ API available and ready to go!
22
++++++++++++++++++++++++++++++
33
+ burnurl.com
44
+ u.mavrev.com
5-
+ budurl.com
65
+ snipr.com/snipurl.com/sn.im
76
+ kl.am
87
+ adjix.com
98
+ metamark.net (xrl.us)
109
+ idek.net
1110
+ xr.com
12-
+ to.ly
1311
+ easyuri.com
1412
+ rubyurl.com
1513
+ hurl.ws

services/budurl.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Shorty
2+
## Copyright 2009 Joshua Roesslein
3+
## See LICENSE
4+
5+
## @url budurl.com
6+
class Budurl(Service):
7+
8+
def __init__(self, apikey=None):
9+
self.apikey = apikey
10+
11+
def _test(self):
12+
#prompt for apikey
13+
self.apikey = raw_input('budurl apikey: ')
14+
Service._test(self)
15+
16+
def shrink(self, bigurl, notes=None):
17+
if self.apikey is None:
18+
raise ShortyError('Must set an apikey')
19+
parameters = {'long_url': bigurl, 'api_key': self.apikey}
20+
if notes:
21+
parameters['notes'] = notes
22+
resp = request('http://budurl.com/api/v1/budurls/shrink', parameters)
23+
jdata = json.loads(resp.read())
24+
if jdata['success'] != 1:
25+
raise ShortyError(jdata['error_message'])
26+
else:
27+
return str(jdata['budurl'])
28+
29+
def expand(self, tinyurl):
30+
resp = request('http://budurl.com/api/v1/budurls/expand', {'budurl': tinyurl})
31+
jdata = json.loads(resp.read())
32+
if jdata['success'] != 1:
33+
raise ShortyError(jdata['error_message'])
34+
else:
35+
return str(jdata['long_url'])
36+

shorty.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class Toly(Service):
292292
def shrink(self, bigurl):
293293
resp = request('http://to.ly/api.php', {'longurl': bigurl})
294294
return resp.read()
295+
295296
toly = Toly()
296297

297298
# fongs
@@ -399,6 +400,40 @@ def expand(self, tinyurl):
399400

400401
bitly = Bitly()
401402

403+
# budurl
404+
class Budurl(Service):
405+
406+
def __init__(self, apikey=None):
407+
self.apikey = apikey
408+
409+
def _test(self):
410+
#prompt for apikey
411+
self.apikey = raw_input('budurl apikey: ')
412+
Service._test(self)
413+
414+
def shrink(self, bigurl, notes=None):
415+
if self.apikey is None:
416+
raise ShortyError('Must set an apikey')
417+
parameters = {'long_url': bigurl, 'api_key': self.apikey}
418+
if notes:
419+
parameters['notes'] = notes
420+
resp = request('http://budurl.com/api/v1/budurls/shrink', parameters)
421+
jdata = json.loads(resp.read())
422+
if jdata['success'] != 1:
423+
raise ShortyError(jdata['error_message'])
424+
else:
425+
return str(jdata['budurl'])
426+
427+
def expand(self, tinyurl):
428+
resp = request('http://budurl.com/api/v1/budurls/expand', {'budurl': tinyurl})
429+
jdata = json.loads(resp.read())
430+
if jdata['success'] != 1:
431+
raise ShortyError(jdata['error_message'])
432+
else:
433+
return str(jdata['long_url'])
434+
435+
budurl = Budurl()
436+
402437
# trim
403438
class Trim(Service):
404439

@@ -634,7 +669,7 @@ def expand(self, tinyurl):
634669
services = {
635670
'a.gd': agd,
636671
'short.to': shortto,
637-
'chilp.it': chilpit,
672+
'budurl.com': budurl,
638673
'digg.com': digg,
639674
'tweetburner.com': tweetburner,
640675
'tr.im': trim,
@@ -644,6 +679,7 @@ def expand(self, tinyurl):
644679
'urlborg.com': urlborg,
645680
'is.gd': isgd,
646681
'fon.gs': fongs,
682+
'chilp.it': chilpit,
647683
'ub0.cc': urlborg,
648684
'tinyurl.com': tinyurl,
649685
'bit.ly': bitly,

0 commit comments

Comments
 (0)