2019-06-06 11:52:23 -05:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
from future import standard_library
|
|
|
|
standard_library.install_aliases()
|
|
|
|
import urllib.request, urllib.parse, urllib.error
|
2017-10-04 17:24:44 +02:00
|
|
|
import requests
|
2019-06-06 11:52:23 -05:00
|
|
|
from . url_shortener import URLShortener
|
2014-10-27 16:29:04 -06:00
|
|
|
|
|
|
|
class HKCShortener (URLShortener):
|
2021-06-16 16:18:41 -05:00
|
|
|
def __init__ (self, *args, **kwargs):
|
|
|
|
self.name = "HKC.im"
|
|
|
|
super(HKCShortener, self).__init__(*args, **kwargs)
|
2014-10-27 16:29:04 -06:00
|
|
|
|
2021-06-16 16:18:41 -05:00
|
|
|
def _shorten (self, url):
|
|
|
|
answer = url
|
|
|
|
api = requests.get ("http://hkc.im/yourls-api.php?action=shorturl&format=simple&url=" + urllib.parse.quote(url))
|
|
|
|
if api.status_code == 200:
|
|
|
|
answer = api.text
|
|
|
|
return answer
|
2014-10-27 16:29:04 -06:00
|
|
|
|
2021-06-16 16:18:41 -05:00
|
|
|
def created_url (self, url):
|
|
|
|
return 'hkc.im' in url.lower()
|