Skip to content

Commit 2535ded

Browse files
committed
Implemented fon.gs service.
1 parent ef9084a commit 2535ded

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Supported URL shortening services for shrinking long urls:
2020
digg.com
2121
a.gd
2222
buk.me
23+
fon.gs
2324

2425
Shorty can expand any url service by getting the redirect
2526
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 @@
11
+ burnurl.com
22
+ chilp.it
3-
+ fon.gs
43
+ fwd4.me

shorty.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,43 @@ def expand(self, tinyurl):
404404
resp = request('http://buk.me/api.php', {'rev': tinyurl})
405405
return self._process(resp.read())
406406

407-
bukme = Bukme()
407+
bukme = Bukme()
408+
409+
class Fongs(Service):
410+
411+
def shrink(self, bigurl, tag=None):
412+
parameters = {'url': bigurl}
413+
if tag:
414+
parameters['linkname'] = tag
415+
resp = request('http://fon.gs/create.php', parameters)
416+
data = resp.read()
417+
if data.startswith('OK:'):
418+
return data.lstrip('OK: ')
419+
elif data.startswith('MODIFIED:'):
420+
return data.lstrip('MODIFIED: ')
421+
else:
422+
raise ShortyError(data)
423+
424+
# check if the given tag is taken
425+
# returns true if available false if taken
426+
def check(self, tag):
427+
resp = request('http://fon.gs/check.php', {'linkname': tag})
428+
data = resp.read()
429+
if data.startswith('AVAILABLE'):
430+
return True
431+
elif data.startswith('TAKEN'):
432+
return False
433+
else:
434+
raise ShortyError(data)
435+
436+
def expand(self, bigurl):
437+
if bigurl[-1] != '/':
438+
burl = bigurl + '/'
439+
else:
440+
burl = bigurl
441+
return Service.expand(self, burl)
442+
443+
fongs = Fongs()
408444

409445
"""Mapping of domain to service class"""
410446
services = {
@@ -418,7 +454,8 @@ def expand(self, tinyurl):
418454
'tweetburner': tweetburner, 'twurl.nl': tweetburner,
419455
'digg.com': digg,
420456
'a.gd': agd,
421-
'buk.me': bukme
457+
'buk.me': bukme,
458+
'fon.gs': fongs
422459
}
423460

424461
"""

0 commit comments

Comments
 (0)