mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-18 06:06:06 -04:00
Initial Python 3 compatible code
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
import shorteners
|
||||
from __future__ import unicode_literals
|
||||
from . import shorteners
|
||||
from __main__ import *
|
||||
|
@@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from functools import wraps
|
||||
import shorteners
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
from url_shortener import URLShortener
|
||||
from hkcim import HKCShortener
|
||||
from isgd import IsgdShortener
|
||||
from onjme import OnjmeShortener
|
||||
from tinyarrows import TinyArrowsShortener
|
||||
from tinyurl import TinyurlShortener
|
||||
from xedcc import XedccShortener
|
||||
from clckru import ClckruShortener
|
||||
from acortame import AcortameShortener
|
||||
from __future__ import unicode_literals
|
||||
from .url_shortener import URLShortener
|
||||
from .hkcim import HKCShortener
|
||||
from . isgd import IsgdShortener
|
||||
from . onjme import OnjmeShortener
|
||||
from . tinyarrows import TinyArrowsShortener
|
||||
from . tinyurl import TinyurlShortener
|
||||
from . xedcc import XedccShortener
|
||||
from . clckru import ClckruShortener
|
||||
from . acortame import AcortameShortener
|
||||
__all__ = ["HKCShortener", "IsgdShortener", "OnjmeShortener", "TinyArrowsShortener", "TinyurlShortener", "XedccShortener", "ClckruShortener", "AcortameShortener"]
|
||||
|
@@ -1,6 +1,9 @@
|
||||
from url_shortener import URLShortener
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from . url_shortener import URLShortener
|
||||
import requests
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
class AcortameShortener (URLShortener):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.name = "acorta.me"
|
||||
@@ -8,7 +11,7 @@ class AcortameShortener (URLShortener):
|
||||
|
||||
def _shorten (self, 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:
|
||||
answer = api.text
|
||||
return answer
|
||||
@@ -21,7 +24,7 @@ class AcortameShortener (URLShortener):
|
||||
#use generic expand method
|
||||
return super(AcortameShortener, self).unshorten(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:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import urllib
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
from . url_shortener import URLShortener
|
||||
|
||||
|
||||
class ClckruShortener (URLShortener):
|
||||
@@ -10,7 +13,7 @@ class ClckruShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = requests.get ("http://clck.ru/--?url=" + urllib.quote(url))
|
||||
api = requests.get ("http://clck.ru/--?url=" + urllib.parse.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import urllib
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
from . url_shortener import URLShortener
|
||||
|
||||
class HKCShortener (URLShortener):
|
||||
def __init__ (self, *args, **kwargs):
|
||||
@@ -9,7 +12,7 @@ class HKCShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = requests.get ("http://hkc.im/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(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
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import urllib
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
from . url_shortener import URLShortener
|
||||
|
||||
|
||||
class IsgdShortener (URLShortener):
|
||||
@@ -10,7 +13,7 @@ class IsgdShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = requests.get ("http://is.gd/api.php?longurl=" + urllib.quote(url))
|
||||
api = requests.get ("http://is.gd/api.php?longurl=" + urllib.parse.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import urllib
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
from . url_shortener import URLShortener
|
||||
|
||||
class OnjmeShortener (URLShortener):
|
||||
def __init__ (self, *args, **kwargs):
|
||||
@@ -9,7 +12,7 @@ class OnjmeShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = requests.get ("http://onj.me/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
api = requests.get ("http://onj.me/yourls-api.php?action=shorturl&format=simple&url=" + urllib.parse.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import urllib
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
from . url_shortener import URLShortener
|
||||
|
||||
class TinyArrowsShortener (URLShortener):
|
||||
def __init__ (self, *args, **kwargs):
|
||||
@@ -9,7 +12,7 @@ class TinyArrowsShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = requests.get("http://tinyarro.ws/api-create.php?utfpure=1&url=%s" % urllib.quote(url))
|
||||
api = requests.get("http://tinyarro.ws/api-create.php?utfpure=1&url=%s" % urllib.parse.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer.decode('UTF-8')
|
||||
|
@@ -1,6 +1,9 @@
|
||||
from url_shortener import URLShortener
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .url_shortener import URLShortener
|
||||
import requests
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
class TinyurlShortener (URLShortener):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.name = "TinyURL.com"
|
||||
@@ -8,7 +11,7 @@ class TinyurlShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = requests.get ("http://tinyurl.com/api-create.php?url=" + urllib.quote(url))
|
||||
api = requests.get ("http://tinyurl.com/api-create.php?url=" + urllib.parse.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import requests
|
||||
|
||||
class URLShortener (object):
|
||||
@@ -22,7 +24,7 @@ class URLShortener (object):
|
||||
def unshorten(self, url):
|
||||
try:
|
||||
r=requests.head(url)
|
||||
if 'location' in r.headers.keys():
|
||||
if 'location' in list(r.headers.keys()):
|
||||
if 'dropbox.com' in r.headers['location']:
|
||||
return handle_dropbox(r.headers['location'])
|
||||
else:
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import urllib
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
from . url_shortener import URLShortener
|
||||
|
||||
class XedccShortener (URLShortener):
|
||||
def __init__ (self, *args, **kwargs):
|
||||
@@ -9,7 +12,7 @@ class XedccShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = requests.get ("http://xed.cc/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
api = requests.get ("http://xed.cc/yourls-api.php?action=shorturl&format=simple&url=" + urllib.parse.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
Reference in New Issue
Block a user