mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-04-20 09:31:43 -04:00
Update acortame.py.
This commit is contained in:
parent
f14c9e1501
commit
d241f068c4
@ -1,27 +1,27 @@
|
|||||||
from url_shortener import URLShortener
|
from .url_shortener import URLShortener
|
||||||
import requests
|
import requests
|
||||||
import urllib
|
import urllib.request, urllib.parse, urllib.error
|
||||||
class AcortameShortener (URLShortener):
|
class AcortameShortener (URLShortener):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.name = "acorta.me"
|
self.name = "acorta.me"
|
||||||
super(AcortameShortener, self).__init__(*args, **kwargs)
|
super(AcortameShortener, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def _shorten (self, url):
|
def _shorten (self, url):
|
||||||
answer = url
|
answer = url
|
||||||
api = requests.get ("https://acorta.me/api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
api = requests.get ("https://acorta.me/api.php?action=shorturl&format=simple&url=" + urllib.parse.quote(url))
|
||||||
if api.status_code == 200:
|
if api.status_code == 200:
|
||||||
answer = api.text
|
answer = api.text
|
||||||
return answer
|
return answer
|
||||||
|
|
||||||
def created_url (self, url):
|
def created_url (self, url):
|
||||||
return 'acorta.me' in url
|
return 'acorta.me' in url
|
||||||
|
|
||||||
def unshorten (self, url):
|
def unshorten (self, url):
|
||||||
if not 'acorta.me' in url:
|
if not 'acorta.me' in url:
|
||||||
#use generic expand method
|
#use generic expand method
|
||||||
return super(AcortameShortener, self).unshorten(url)
|
return super(AcortameShortener, self).unshorten(url)
|
||||||
answer = url
|
answer = url
|
||||||
api = requests.get ("https://acorta.me/api.php?action=expand&format=simple&shorturl=" + urllib.quote(url))
|
api = requests.get ("https://acorta.me/api.php?action=expand&format=simple&shorturl=" + urllib.parse.quote(url))
|
||||||
if api.status_code == 200:
|
if api.status_code == 200:
|
||||||
answer = api.text
|
answer = api.text
|
||||||
return answer
|
return answer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user