Skip to content

Commit 71f77cc

Browse files
astagijoshthecoder
authored andcommitted
Add goo.gl service
1 parent 013d7a4 commit 71f77cc

File tree

3 files changed

+467
-433
lines changed

3 files changed

+467
-433
lines changed

common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def _test(self):
7272
try:
7373
if self.expand(turl) == 'http://test.com':
7474
return True
75+
elif self.expand(turl) == 'http://test.com/':
76+
return True
7577
else:
7678
return False
7779
except ShortyError, e:

services/google.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Shorty
2+
## Copyright 2011 Andrea Stagi
3+
## See LICENSE
4+
5+
## @url goo.gl
6+
class Google(Service):
7+
8+
def shrink(self, bigurl):
9+
resp = request('http://goo.gl/api/url', {'url': bigurl}, post_data = 'toolbar')
10+
data = resp.read()
11+
jdata = json.loads(data)
12+
if 'short_url' not in jdata:
13+
raise ShortyError(data)
14+
else:
15+
return jdata['short_url']
16+

0 commit comments

Comments
 (0)