parthrbhatt / pyshorturl Goto Github PK
View Code? Open in Web Editor NEWURL Shortening lib written in Python. pyShortUrl currently supports url shortening with several domains: goo.gl, bit.ly, git.io, j.mp, bitly.com, tinyurl.com, v.gd & is.gd.
URL Shortening lib written in Python. pyShortUrl currently supports url shortening with several domains: goo.gl, bit.ly, git.io, j.mp, bitly.com, tinyurl.com, v.gd & is.gd.
Git.io has gone https (for good reasons). Update the lib so we continue to work with the service.
Add support for is.gd & v.gd.
Both services expose exact same API:
git.io is github's url shortening service and is intended to be used only for github urls.
API Details:
https://github.com/blog/985-git-io-github-url-shortener
Depending upon the service that the user wants to use this lib for, (s)he may need to have an API key and/or an account (login). Add a wiki page dedicated to explaining various details about all the services.
This wiki should at least include the following for each service:
bit.ly supports a bunch of functionality that pyShortUrl does not yet support.
API Docs: http://dev.bitly.com/api.html
The setup.py is already in place.
pyShortUrl supports bit.ly API v2.0.1. This needs to be enhanced to support v3 so that url shortening for other domains like j.mp etc can be supported.
API Doc for v3: http://code.google.com/p/bitly-api/wiki/ApiDocumentation
Add travis CI integration so that the project and be built and unit tests can be run regularly.
Docs:
http://about.travis-ci.org/docs/user/languages/python/
Following is a log of a UT run:
$ python test_pyshorturl.py
test_expand_url_with_key (ut_googl.TestGoogl) ... ok
test_expand_url_without_key (ut_googl.TestGoogl) ... ok
test_shorten_url_with_key (ut_googl.TestGoogl) ... ok
test_shorten_url_without_key (ut_googl.TestGoogl) ... ok
test_write_qr_image (ut_googl.TestGoogl) ... ok
Ran 5 tests in 1.843s
OK
test_expand_url (ut_bitly.TestBitly) ... ok
test_expand_url_v2 (ut_bitly.TestBitly) ... ok
test_shorten_url (ut_bitly.TestBitly) ... ok
test_shorten_url_v2 (ut_bitly.TestBitly) ... ok
test_shorten_url_with_domain (ut_bitly.TestBitly) ... ok
test_validate (ut_bitly.TestBitly) ... ok
test_write_qr_image (ut_bitly.TestBitly) ... ERROR
test_write_qr_image_v2 (ut_bitly.TestBitly) ... ERROR
Traceback (most recent call last):
File "/Users/parthbhatt/workspace/projects/pyShortUrl/tests/ut_bitly.py", line 49, in test_write_qr_image
service.write_qr_image(self.test_short_url, self.qr_image_path)
File "/Users/parthbhatt/workspace/projects/pyShortUrl/pyshorturl/ShortUrl/base_shortener.py", line 67, in write_qr_image
image_data = self.get_qr_code(short_url)
File "/Users/parthbhatt/workspace/projects/pyShortUrl/pyshorturl/ShortUrl/bit_ly.py", line 139, in get_qr_code
headers, response = self._do_http_request(qr_url)
File "/Users/parthbhatt/workspace/projects/pyShortUrl/pyshorturl/ShortUrl/base_shortener.py", line 34, in _do_http_request
raise ShortenerServiceError('%s:%s' %(e.code, e.msg))
ShortenerServiceError: 410:Gone
Traceback (most recent call last):
File "/Users/parthbhatt/workspace/projects/pyShortUrl/tests/ut_bitly.py", line 75, in test_write_qr_image_v2
service.write_qr_image(self.test_short_url, self.qr_image_path)
File "/Users/parthbhatt/workspace/projects/pyShortUrl/pyshorturl/ShortUrl/base_shortener.py", line 67, in write_qr_image
image_data = self.get_qr_code(short_url)
File "/Users/parthbhatt/workspace/projects/pyShortUrl/pyshorturl/ShortUrl/bit_ly.py", line 139, in get_qr_code
headers, response = self._do_http_request(qr_url)
File "/Users/parthbhatt/workspace/projects/pyShortUrl/pyshorturl/ShortUrl/base_shortener.py", line 34, in _do_http_request
raise ShortenerServiceError('%s:%s' %(e.code, e.msg))
ShortenerServiceError: 410:Gone
Ran 8 tests in 0.639s
FAILED (errors=2)
test_expand_url (ut_gitio.TestGitio) ... ok
test_shorten_url (ut_gitio.TestGitio) ... FAIL
Traceback (most recent call last):
File "/Users/parthbhatt/workspace/projects/pyShortUrl/tests/ut_gitio.py", line 21, in test_shorten_url
self.assertEqual(self.test_short_url, generated_short_url)
AssertionError: 'http://git.io/help' != 'http://git.io/PUikkQ'
Ran 2 tests in 0.503s
FAILED (failures=1)
test_expand_url (ut_tinyurlcom.TestTinyUrlcom) ... FAIL
test_shorten_url (ut_tinyurlcom.TestTinyUrlcom) ... ok
Traceback (most recent call last):
File "/Users/parthbhatt/workspace/projects/pyShortUrl/tests/ut_tinyurlcom.py", line 27, in test_expand_url
self.assertEqual(self.test_long_url, generated_long_url)
AssertionError: 'http://www.parthbhatt.com/blog/' != 'http://tinyurl.com/8yuvzl5'
Ran 2 tests in 0.739s
FAILED (failures=1)
test_expand_url (ut_vgd.TestVgd) ... ok
test_shorten_url (ut_vgd.TestVgd) ... ok
test_shorten_url_with_stats (ut_vgd.TestVgd) ... ok
Ran 3 tests in 0.701s
OK
test_expand_url (ut_isgd.TestIsgd) ... ok
test_shorten_url (ut_isgd.TestIsgd) ... ok
test_shorten_url_with_stats (ut_isgd.TestIsgd) ... ok
Ran 3 tests in 0.713s
OK
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.