• Stars
    star
    178
  • Rank 207,949 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python implementation for generating Tiny URL- and bit.ly-like URLs.

Short URL Generator

travis-cli tests status for short_url PyPI Version PyPI Status PyPI License PyPI Format PyPI Py_versions PyPI Implementation PyPI Egg

Python implementation for generating Tiny URL- and bit.ly-like URLs.

A bit-shuffling approach is used to avoid generating consecutive, predictable URLs. However, the algorithm is deterministic and will guarantee that no collisions will occur.

The URL alphabet is fully customizable and may contain any number of characters. By default, digits and lower-case letters are used, with some removed to avoid confusion between characters like o, O and 0. The default alphabet is shuffled and has a prime number of characters to further improve the results of the algorithm.

The block size specifies how many bits will be shuffled. The lower BLOCK_SIZE bits are reversed. Any bits higher than BLOCK_SIZE will remain as is. BLOCK_SIZE of 0 will leave all bits unaffected and the algorithm will simply be converting your integer to a different base.

The intended use is that incrementing, consecutive integers will be used as keys to generate the short URLs. For example, when creating a new URL, the unique integer ID assigned by a database could be used to generate the URL by using this module. Or a simple counter may be used. As long as the same integer is not used twice, the same short URL will not be generated twice.

The module supports both encoding and decoding of URLs. The min_length parameter allows you to pad the URL if you want it to be a specific length.

Sample Usage:

>>> import short_url
>>> url = short_url.encode_url(12)
>>> print url
LhKA
>>> key = short_url.decode_url(url)
>>> print key
12

Use the functions in the top-level of the module to use the default encoder. Otherwise, you may create your own UrlEncoder object and use its encode_url and decode_url methods.

Install

short_url is also available at pypi:

http://pypi.python.org/pypi/short_url

Give a try to your finger:

$ pip install short_url

And done ;)

Tests

short_url is tested on both python2 and python3, to run the tests:

$ tox

Source https://github.com/Alir3z4/short_url
Website http://alir3z4.github.com/short_url
Issues https://github.com/Alir3z4/short_url/issues
PyPi http://pypi.python.org/pypi/short_url
Author Michael Fogleman
Maintainer Alireza Savand
License MIT
Link http://code.activestate.com/recipes/576918/

More Repositories

1

html2text

Convert HTML to Markdown-formatted text.
Python
1,678
star
2

stop-words

List of common stop words in various languages.
309
star
3

python-stop-words

Get list of common stop words in various languages in Python
Python
155
star
4

python-currencies

Display money format and its filthy currencies, for all money lovers out there.
Python
72
star
5

django-crequest

django-crequest - Taking care of current request in silent way.
Python
60
star
6

oss-wall-of-shame

Companies that use open source and never bother to contribute back - Open Source Software Wall of Shame
44
star
7

django-databrowse

Databrowse is a Django application that lets you browse your data.
Python
42
star
8

django-markwhat

A collection of template filters that implement common markup languages.
Python
20
star
9

ansible-suricata

An Ansible playbook for deploying the Suricata intrusion detection system and fetching Snort rules with Oinkmaster.
Jinja
14
star
10

yoDownet

yoDownet, The previous generation graphical download manager, built on Qt.
C++
10
star
11

django-base64field

A motherfucking django model field to bring base64 encoded key to models.
Python
8
star
12

cmsplugin-simple-markdown

A plugin for django-cms that provides just a markdown plugin and nothing more.
Python
6
star
13

django-mongodb-cash-backend

django-mongodb-cash-backend
Python
6
star
14

python-gignore

Get .gitignore files from github.com/github/gitignore
Python
4
star
15

flask-microblog-sqlalchemy

based on Miguel Grinberg flask tutorial at http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
Python
3
star
16

negar-cli

Negar Command Line Interface
Python
3
star
17

php-solusvm

SolusVM API PHP LIbrary
PHP
3
star
18

django-kewl

Django Kewl - Set of Django kewl utilities & helpers & highly used/needed stuff.
Python
3
star
19

nevis

Nevis is only a simple fast text editor, implemented in Qt/C++. -- Currently under development.
C++
2
star
20

python-cpanel

Python cPanel - The snake ate cPanel API.
Python
2
star
21

django-blog-book

Developing A Blog Application In Django Python Web Framework.
2
star
22

markwhat

Markwhat is a desktop cross-platform markup text editor with live preview feature. Written in pure python.
Python
2
star
23

node-money-currencies

Display money format and its filthy currencies, for all money lovers out there.
JavaScript
2
star
24

markwhat-online

Is an online tool/api to parse markup data. It's available through a web interface and a delicious API which speaks JSON.
Python
1
star
25

.dotfiles

@Alir3z4's ~/.dotfiles all over the place!
Shell
1
star
26

aur-pkgs

Alireza's ArchLinux User Repository PKGBUILDs, made with absolute rage!!!
Shell
1
star
27

WHMCS

PHP
1
star
28

python-simplerelevance

SimpleRelevance API Python Wrapper
Python
1
star