Skip to content

Commit 2cc5198

Browse files
committed
Added cli.gs service. Implemented shrink and expand methods.
1 parent f8b094f commit 2cc5198

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Supported URL shortening services:
1515
urlborg.com
1616
bit.ly
1717
is.gd (shrink only)
18+
cli.gs
1819

1920
Language: Python
2021
Website: http://gitorious.org/shorty

shorty.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,40 @@ def shrink(self, bigurl):
268268

269269
isgd = Isgd()
270270

271+
# cli.gs
272+
class Cligs(Service):
273+
274+
def __init__(self, apikey=None, appid=None):
275+
self.apikey = apikey
276+
self.appid = appid
277+
278+
def shrink(self, bigurl, title=None):
279+
parameters = {'url': bigurl}
280+
if title:
281+
parameters['title'] = title
282+
if self.apikey:
283+
parameters['key'] = self.apikey
284+
if self.appid:
285+
parameters['appid'] = self.appid
286+
resp = request('http://cli.gs/api/v1/cligs/create', parameters)
287+
return resp.read()
288+
289+
def expand(self, tinyurl):
290+
# TODO: debug this some more, not working properly
291+
resp = request('http://cli.gs/api/v1/cligs/expand', {'clig': tinyurl})
292+
return resp.read()
293+
294+
cligs = Cligs()
295+
271296
"""Mapping of domain to service class"""
272297
services = {
273298
'sandbox': sandbox,
274299
'tinyurl.com': tinyurl,
275300
'tr.im': trim,
276301
'urlborg.com': urlborg, 'ub0.cc': urlborg,
277302
'bit.ly': bitly,
278-
'is.gd': isgd
303+
'is.gd': isgd,
304+
'cli.gs': cligs
279305
}
280306

281307
"""

0 commit comments

Comments
 (0)