Exemplo n.º 1
0
 def process_request(self, request):
     host = request.META['HTTP_HOST']
     if host in settings.EXCLUDED_HOSTS:
         return None
     request_uri = request.build_absolute_uri()
     if '/admin/' in request_uri:
         return None
     
     ## do a single check to see if there's anything alphabetical
     has_alpha = re.compile('[a-zA-Z]+')
     if has_alpha.search(host) is not None:
         ## check if someone is hitting their application via a private IP rather than hostname
         for private in PRIVATES:
             p = re.compile(private)
             if p.match(host) is not None:
                 return None
     
     ## okay, looks like all those tests were passed, let's go shorten...
     if BitlyURL.objects.filter(unshorted_url=request_uri).count() < 1:
         try:
             newbitly = BitlyURL()
             newbitly.unshorted_url = request_uri
             a=Api(login=settings.BITLY_LOGIN,apikey=settings.BITLY_API_KEY)
             short=a.shorten(request_uri,{'history':1}) 
             newbitly.shortened_url=short
             newbitly.save()
         except:
             pass
         
     return None
Exemplo n.º 2
0
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

'''A wrapper library for Bitly http://bit.ly'''

__author__ =  'Jair Gaxiola'
__email__ = '*****@*****.**'
__license__ = 'MIT License'
__version__ = '0.0.1'

from bitly import Api
import sys

if len(sys.argv) != 5:
    print "Usage: \n\t python info.py \'version\' \'hash\' \'login\' \'apiKey\'"
    sys.exit(1)

version = sys.argv[1]
hashUrl = sys.argv[2]
login = sys.argv[3]
apiKey = sys.argv[4]

api = Api(version, login, apiKey)
api.info(hashUrl)
Exemplo n.º 3
0
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

'''A wrapper library for Bitly http://bit.ly'''

__author__ =  'Jair Gaxiola'
__email__ = '*****@*****.**'
__license__ = 'MIT License'
__version__ = '0.0.1'

from bitly import Api
import sys

if len(sys.argv) != 5:
    print "Usage: \n\t python expand.py \'version\' \'shortUrl\' \'login\' \'apiKey\'"
    sys.exit(1)

version = sys.argv[1]
shortUrl = sys.argv[2]
login = sys.argv[3]
apiKey = sys.argv[4]

api = Api(version, login, apiKey)
api.stats(shortUrl)
Exemplo n.º 4
0
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

"""A wrapper library for Bitly http://bit.ly"""

__author__ = "Jair Gaxiola"
__email__ = "*****@*****.**"
__license__ = "MIT License"
__version__ = "0.0.1"

from bitly import Api
import sys

if len(sys.argv) != 4:
    print "Usage: \n\t python expand.py 'version' 'login' 'apiKey'"
    sys.exit(1)

version = sys.argv[1]
login = sys.argv[2]
apiKey = sys.argv[3]

api = Api(version, login, apiKey)
api.errors()
Exemplo n.º 5
0
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

"""A wrapper library for Bitly http://bit.ly"""

__author__ = "Jair Gaxiola"
__email__ = "*****@*****.**"
__license__ = "MIT License"
__version__ = "0.0.1"

from bitly import Api
import sys

if len(sys.argv) != 5:
    print "Usage: \n\t python shorten.py 'version' 'longUrl' 'login' 'apiKey'"
    sys.exit(1)

version = sys.argv[1]
longUrl = sys.argv[2]
login = sys.argv[3]
apiKey = sys.argv[4]

api = Api(version, login, apiKey)
api.shorten(longUrl)
Exemplo n.º 6
0
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

"""A wrapper library for Bitly http://bit.ly"""

__author__ = "Jair Gaxiola"
__email__ = "*****@*****.**"
__license__ = "MIT License"
__version__ = "0.0.1"

from bitly import Api
import sys

if len(sys.argv) != 5:
    print "Usage: \n\t python expand.py 'version' 'shortUrl' 'login' 'apiKey'"
    sys.exit(1)

version = sys.argv[1]
shortUrl = sys.argv[2]
login = sys.argv[3]
apiKey = sys.argv[4]

api = Api(version, login, apiKey)
api.expand(shortUrl)