Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04ed0a4

Browse files
committed
Implemented snipurl.com service.
1 parente04588a commit04ed0a4

File tree

4 files changed

+101
-2
lines changed

4 files changed

+101
-2
lines changed

‎README‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Supported URL shortening services for shrinking long urls:
2020
tinyurl.com burnurl.com
2121
tr.im hurl.ws
2222
urlborg.com xr.com
23-
bit.ly
23+
bit.ly snipurl.com
2424
is.gd
2525
cli.gs
2626
twurl.nl (tweetburner)

‎TODO‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
API available and ready to go!
22
++++++++++++++++++++++++++++++
33
+ u.mavrev.com
4-
+ snipr.com/snipurl.com/sn.im
54
+ adjix.com
65
+ metamark.net (xrl.us)
76
+ idek.net

‎services/snipurl.py‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Shorty
2+
## Copyright 2009 Joshua Roesslein
3+
## See LICENSE
4+
5+
## @url snipurl.com snipr.com sn.im snurl.com
6+
classSnipurl(Service):
7+
8+
def__init__(self,user=None,apikey=None):
9+
self.user=user
10+
self.apikey=apikey
11+
12+
def_test(self):
13+
# prompt for username and apikey
14+
self.user=raw_input('snipurl username: ')
15+
self.apikey=raw_input('snipurl apikey: ')
16+
Service._test(self)
17+
18+
defshrink(self,bigurl,custom=None,title=None,private_key=None,
19+
owner=None,include_private_key=False):
20+
ifself.userisNoneorself.apikeyisNone:
21+
raiseShortyError('Must set an user and apikey')
22+
parameters= {
23+
'sniplink':bigurl,
24+
'snipuser':self.user,
25+
'snipapi':self.apikey,
26+
'snipformat':'simple'
27+
}
28+
ifcustom:
29+
parameters['snipnick']=custom
30+
iftitle:
31+
parameters['sniptitle']=title
32+
ifprivate_key:
33+
parameters['snippk']=private_key
34+
ifowner:
35+
parameters['snipowner']=owner
36+
ifinclude_private_key:
37+
parameters['snipformat_includepk']='Y'
38+
resp=request('http://snipurl.com/site/getsnip',
39+
post_data=urlencode(parameters))
40+
returnresp.read()
41+
42+
defexpand(self,tinyurl):
43+
# TODO: fetch detailed info
44+
url=Service.expand(self,tinyurl)
45+
ifurl.startswith('http'):
46+
returnurl
47+
else:
48+
raiseShortyError('Invalid url')
49+

‎shorty.py‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,53 @@ def expand(self, tinyurl):
712712

713713
sandbox=Sandbox()
714714

715+
# snipurl
716+
classSnipurl(Service):
717+
718+
def__init__(self,user=None,apikey=None):
719+
self.user=user
720+
self.apikey=apikey
721+
722+
def_test(self):
723+
# prompt for username and apikey
724+
self.user=raw_input('snipurl username: ')
725+
self.apikey=raw_input('snipurl apikey: ')
726+
Service._test(self)
727+
728+
defshrink(self,bigurl,custom=None,title=None,private_key=None,
729+
owner=None,include_private_key=False):
730+
ifself.userisNoneorself.apikeyisNone:
731+
raiseShortyError('Must set an user and apikey')
732+
parameters= {
733+
'sniplink':bigurl,
734+
'snipuser':self.user,
735+
'snipapi':self.apikey,
736+
'snipformat':'simple'
737+
}
738+
ifcustom:
739+
parameters['snipnick']=custom
740+
iftitle:
741+
parameters['sniptitle']=title
742+
ifprivate_key:
743+
parameters['snippk']=private_key
744+
ifowner:
745+
parameters['snipowner']=owner
746+
ifinclude_private_key:
747+
parameters['snipformat_includepk']='Y'
748+
resp=request('http://snipurl.com/site/getsnip',
749+
post_data=urlencode(parameters))
750+
returnresp.read()
751+
752+
defexpand(self,tinyurl):
753+
# TODO: fetch detailed info
754+
url=Service.expand(self,tinyurl)
755+
ifurl.startswith('http'):
756+
returnurl
757+
else:
758+
raiseShortyError('Invalid url')
759+
760+
snipurl=Snipurl()
761+
715762
# tinyurl
716763
classTinyurl(Service):
717764

@@ -746,6 +793,7 @@ def expand(self, tinyurl):
746793
bukme=Bukme()
747794

748795
services= {
796+
'snipr.com':snipurl,
749797
'chilp.it':chilpit,
750798
'bit.ly':bitly,
751799
'short.to':shortto,
@@ -754,6 +802,7 @@ def expand(self, tinyurl):
754802
'buk.me':bukme,
755803
'fon.gs':fongs,
756804
'ub0.cc':urlborg,
805+
'snurl.com':snipurl,
757806
'fwd4.me':fwd4me,
758807
'xr.com':xr,
759808
'short.ie':shortie,
@@ -768,8 +817,10 @@ def expand(self, tinyurl):
768817
'cli.gs':cligs,
769818
'urlborg.com':urlborg,
770819
'is.gd':isgd,
820+
'sn.im':snipurl,
771821
'tweetburner.com':tweetburner,
772822
'x.bb':xr,
773823
'tinyurl.com':tinyurl,
824+
'snipurl.com':snipurl,
774825
}
775826

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp