Skip to content

Commit d4f6ead

Browse files
committed
Implemented xr.com service.
1 parent e1e3032 commit d4f6ead

File tree

4 files changed

+67
-13
lines changed

4 files changed

+67
-13
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Supported URL shortening services for shrinking long urls:
3535
to.ly
3636
budurl.com
3737
kl.am
38+
xr.com
3839

3940
Shorty can expand any url service by getting the redirect
4041
location by requesting the tiny url.

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ API available and ready to go!
66
+ adjix.com
77
+ metamark.net (xrl.us)
88
+ idek.net
9-
+ xr.com
109
+ easyuri.com
1110
+ rubyurl.com
1211
+ hurl.ws

services/xr.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Shorty
2+
## Copyright 2009 Joshua Roesslein
3+
## See LICENSE
4+
5+
## @url xr.com x.bb
6+
class Xr(Service):
7+
8+
def __init__(self, account_name=None):
9+
self.account_name = account_name
10+
11+
def shrink(self, bigurl, custom=None, domain=None, direct=True):
12+
parameters = {'link': bigurl}
13+
if custom:
14+
parameters['custom'] = custom
15+
if domain:
16+
parameters['domain'] = domain
17+
if direct:
18+
parameters['direct'] = 'yes'
19+
if self.account_name:
20+
parameters['pid'] = self.account_name
21+
resp = request('http://api.xr.com/api', parameters)
22+
url = resp.read()
23+
if url.startswith('http'):
24+
return url
25+
else:
26+
raise ShortyError(url)
27+

shorty.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,31 @@ def shrink(self, bigurl, tag=None, password=None, expires=None):
522522

523523
agd = Agd()
524524

525+
# xr
526+
class Xr(Service):
527+
528+
def __init__(self, account_name=None):
529+
self.account_name = account_name
530+
531+
def shrink(self, bigurl, custom=None, domain=None, direct=True):
532+
parameters = {'link': bigurl}
533+
if custom:
534+
parameters['custom'] = custom
535+
if domain:
536+
parameters['domain'] = domain
537+
if direct:
538+
parameters['direct'] = 'yes'
539+
if self.account_name:
540+
parameters['pid'] = self.account_name
541+
resp = request('http://api.xr.com/api', parameters)
542+
url = resp.read()
543+
if url.startswith('http'):
544+
return url
545+
else:
546+
raise ShortyError(url)
547+
548+
xr = Xr()
549+
525550
# shortto
526551
class Shortto(Service):
527552

@@ -684,26 +709,28 @@ def expand(self, tinyurl):
684709
bukme = Bukme()
685710

686711
services = {
687-
'a.gd': agd,
712+
'chilp.it': chilpit,
713+
'bit.ly': bitly,
688714
'short.to': shortto,
689-
'budurl.com': budurl,
690-
'digg.com': digg,
691-
'kl.am': klam,
692-
'tweetburner.com': tweetburner,
693715
'tr.im': trim,
694716
'twurl.nl': tweetburner,
717+
'buk.me': bukme,
718+
'fon.gs': fongs,
695719
'to.ly': toly,
720+
'fwd4.me': fwd4me,
721+
'xr.com': xr,
722+
'short.ie': shortie,
723+
'sandbox.com': sandbox,
724+
'a.gd': agd,
725+
'digg.com': digg,
726+
'kl.am': klam,
727+
'tweetburner.com': tweetburner,
728+
'budurl.com': budurl,
696729
'cli.gs': cligs,
697730
'urlborg.com': urlborg,
698731
'is.gd': isgd,
699-
'fon.gs': fongs,
700-
'chilp.it': chilpit,
701732
'ub0.cc': urlborg,
733+
'x.bb': xr,
702734
'tinyurl.com': tinyurl,
703-
'bit.ly': bitly,
704-
'fwd4.me': fwd4me,
705-
'short.ie': shortie,
706-
'sandbox.com': sandbox,
707-
'buk.me': bukme,
708735
}
709736

0 commit comments

Comments
 (0)