urlparse for python3

This commit is contained in:
Ricter Z 2016-10-17 21:48:21 +08:00
parent 3ba8f62fe2
commit 148b4a1a08
3 changed files with 13 additions and 5 deletions

View File

@ -7,6 +7,7 @@ except ImportError:
pass
import nhentai.constant as constant
from nhentai.utils import urlparse
from nhentai.logger import logger
@ -64,8 +65,7 @@ def cmd_parser():
exit(0)
if args.proxy:
import urlparse
proxy_url = urlparse.urlparse(args.proxy)
proxy_url = urlparse(args.proxy)
if proxy_url.scheme not in ('http', 'https'):
logger.error('Invalid protocol \'{0}\' of proxy, ignored'.format(proxy_url.scheme))
else:

View File

@ -1,12 +1,12 @@
import os
import urlparse
from nhentai.utils import urlparse
BASE_URL = os.getenv('NHENTAI', 'https://nhentai.net')
DETAIL_URL = '%s/g' % BASE_URL
SEARCH_URL = '%s/search/' % BASE_URL
u = urlparse.urlparse(BASE_URL)
u = urlparse(BASE_URL)
IMAGE_URL = '%s://i.%s/galleries' % (u.scheme, u.hostname)
PROXY = {}

View File

@ -11,4 +11,12 @@ class _Singleton(type):
return cls._instances[cls]
class Singleton(_Singleton('SingletonMeta', (object,), {})): pass
class Singleton(_Singleton('SingletonMeta', (object,), {})):
pass
def urlparse(url):
try:
import urlparse
except ImportError:
import urllib.parse as urlparse