import urllib
import requests
from url_shortener import URLShortener


class ClckruShortener (URLShortener):
 def __init__ (self, *args, **kwargs):
  self.name = "clck.ru"
  super(ClckruShortener, self).__init__(*args, **kwargs)

 def _shorten (self, url):
  answer = url
  api = requests.get ("http://clck.ru/--?url=" + urllib.quote(url))
  if api.status_code == 200:
   answer = api.text
  return answer

 def created_url (self, url):
  return 'clck.ru' in url
