mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-04-20 09:31:43 -04:00
Added support for the i.gal shortener. This is a very basical implementation as i.gal requires an API key to work
This commit is contained in:
parent
8928a64a12
commit
de0af09a33
@ -25,7 +25,7 @@ def unshorten (url, service=None, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def default_service ():
|
def default_service ():
|
||||||
return shorteners.AcortameShortener
|
return shorteners.IgalShortener
|
||||||
|
|
||||||
def find_service (service, **kwargs):
|
def find_service (service, **kwargs):
|
||||||
for i in shorteners.__all__:
|
for i in shorteners.__all__:
|
||||||
|
@ -7,4 +7,5 @@ from tinyurl import TinyurlShortener
|
|||||||
from xedcc import XedccShortener
|
from xedcc import XedccShortener
|
||||||
from clckru import ClckruShortener
|
from clckru import ClckruShortener
|
||||||
from acortame import AcortameShortener
|
from acortame import AcortameShortener
|
||||||
__all__ = ["HKCShortener", "IsgdShortener", "OnjmeShortener", "TinyArrowsShortener", "TinyurlShortener", "XedccShortener", "ClckruShortener", "AcortameShortener"]
|
from igal import IgalShortener
|
||||||
|
__all__ = ["HKCShortener", "IsgdShortener", "OnjmeShortener", "TinyArrowsShortener", "TinyurlShortener", "XedccShortener", "ClckruShortener", "AcortameShortener", "IgalShortener"]
|
||||||
|
18
src/url_shortener/shorteners/igal.py
Normal file
18
src/url_shortener/shorteners/igal.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from url_shortener import URLShortener
|
||||||
|
import requests
|
||||||
|
import urllib
|
||||||
|
class IgalShortener (URLShortener):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.name = "i.gal"
|
||||||
|
super(IgalShortener, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def _shorten (self, url):
|
||||||
|
answer = url
|
||||||
|
api = requests.get ("https://i.gal/api/v2/action/shorten?key=apikey&url=" + urllib.quote(url))
|
||||||
|
if api.status_code == 200:
|
||||||
|
answer = api.text
|
||||||
|
return answer
|
||||||
|
|
||||||
|
def created_url (self, url):
|
||||||
|
return 'i.gal' in url
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user