-
Notifications
You must be signed in to change notification settings - Fork 0
/
web_handlers.py
32 lines (29 loc) · 1.56 KB
/
web_handlers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from config import config
import urllib
def get_system_url(system_name, provider = None):
if not provider:
provider = config.get_str('L3_system_provider')
if provider == 'none':
provider = config.get_str('system_provider')
if provider == 'eddb':
return('https://eddb.io/system/name/' + urllib.parse.quote_plus(system_name))
elif provider == 'Inara':
return('https://inara.cz/galaxy-starsystem/?search=' + urllib.parse.quote_plus(system_name))
else:
return('https://www.edsm.net/show-system?systemName=' + urllib.parse.quote_plus(system_name))
def get_nearest_url(system_name):
return('https://inara.cz/galaxy-nearest-stations/?ps1=' + urllib.parse.quote_plus(system_name))
def get_station_url(system_name, station_name, provider = None, market_id = None):
if not provider:
provider = config.get_str('L3_station_provider')
if provider == 'none':
provider = config.get_str('station_provider')
if provider == 'eddb':
if market_id:
return('https://eddb.io/station/market-id/' + urllib.parse.quote_plus(str(market_id)))
else:
return(get_system_url(system_name, provider = 'eddb'))
elif provider == 'Inara':
return('https://inara.cz/galaxy-station/?search={}%20[{}]'.format(urllib.parse.quote_plus(system_name), urllib.parse.quote_plus(station_name)))
else:
return('https://www.edsm.net/show-system?systemName={}&stationName={}'.format(urllib.parse.quote_plus(system_name), urllib.parse.quote_plus(station_name)))