18
18
CACHE_LIMIT = 300
19
19
20
20
21
- class TibiaResponse :
21
+ # This class is not used in this release.
22
+ class _TibiaResponse : # pragma: no cover
22
23
def __init__ (self , data = None , cache_limit = CACHE_LIMIT , ** kwargs ):
23
24
self .data = None
24
25
self .cached = kwargs .get ("cached" )
@@ -59,7 +60,7 @@ def __init__(self, loop=None, session=None, *, proxy_url=None):
59
60
60
61
async def _initialize_session (self , proxy_url = None ):
61
62
headers = {
62
- 'User-Agent' : "Tibia.py/%s (+https://github.com/Galarzaa90/tibia.py" % tibiapy .__version__ ,
63
+ 'User-Agent' : "Tibia.py/%s (+https://github.com/Galarzaa90/tibia.py) " % tibiapy .__version__ ,
63
64
'Accept-Encoding' : "deflate, gzip"
64
65
}
65
66
connector = aiohttp_socks .SocksConnector .from_url (proxy_url ) if proxy_url else None
@@ -105,6 +106,8 @@ async def _get(self, url):
105
106
raise NetworkError ("aiohttp.ClientError: %s" % e , e )
106
107
except aiohttp_socks .SocksConnectionError as e :
107
108
raise NetworkError ("aiohttp_socks.SocksConnectionError: %s" % e , e )
109
+ except UnicodeDecodeError as e :
110
+ raise NetworkError ('UnicodeDecodeError: %s' % e , e )
108
111
109
112
async def _post (self , url , data ):
110
113
"""Base POST request, handling possible error statuses.
@@ -127,6 +130,10 @@ async def _post(self, url, data):
127
130
return await resp .text ()
128
131
except aiohttp .ClientError as e :
129
132
raise NetworkError ("aiohttp.ClientError: %s" % e , e )
133
+ except aiohttp_socks .SocksConnectionError as e :
134
+ raise NetworkError ("aiohttp_socks.SocksConnectionError: %s" % e , e )
135
+ except UnicodeDecodeError as e :
136
+ raise NetworkError ('UnicodeDecodeError: %s' % e , e )
130
137
131
138
async def fetch_boosted_creature (self ):
132
139
"""Fetches today's boosted creature.
@@ -420,9 +427,9 @@ async def fetch_news_archive(self, begin_date, end_date, categories=None, types=
420
427
if begin_date > end_date :
421
428
raise ValueError ("begin_date can't be more recent than end_date" )
422
429
if not categories :
423
- categories = NewsCategory . items ( )
430
+ categories = list ( NewsCategory )
424
431
if not types :
425
- types = NewsType . items ( )
432
+ types = list ( NewsType )
426
433
data = {
427
434
"filter_begin_day" : begin_date .day ,
428
435
"filter_begin_month" : begin_date .month ,
0 commit comments