Initial commit
This commit is contained in:
68
tipp/openliga.py
Executable file
68
tipp/openliga.py
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2013 by Martin Bley <martin@mb-oss.de>
|
||||
#
|
||||
# tippy.py is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# tippy.py is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with tippy.py. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import sys, locale, suds, urllib2, psycopg2
|
||||
|
||||
class OpenLiga(object):
|
||||
version = "0.1"
|
||||
error = ""
|
||||
proxyurl = None
|
||||
debug = None
|
||||
client = None
|
||||
|
||||
def __init__(self, proxyurl=None, debug=False):
|
||||
|
||||
# set locale to environment (for dispaying localized dates)
|
||||
locale.setlocale(locale.LC_TIME, "")
|
||||
|
||||
self.debug = debug
|
||||
|
||||
# get a SUDS client object
|
||||
if self.proxyurl is None:
|
||||
try:
|
||||
self.client = suds.client.Client('http://www.openligadb.de/Webservices/Sportsdata.asmx?WSDL')
|
||||
except (urllib2.URLError):
|
||||
self.error += "Connect to webservice failed."
|
||||
else:
|
||||
try:
|
||||
t = suds.transport.http.HttpTransport()
|
||||
proxy = urllib2.ProxyHandler({'http':proxyurl})
|
||||
opener = urllib2.build_opener(proxy)
|
||||
t.urlopener = opener
|
||||
self.client = suds.client.Client('http://www.openligadb.de/Webservices/Sportsdata.asmx?WSDL', transport=t)
|
||||
except urllib2.URLError as e:
|
||||
self.error += "Connect to webservice failed (via proxy " + proxyurl + "): " + str(e) + "\n"
|
||||
|
||||
def getSeason(self, season, league='bl1'):
|
||||
""" Get the whole season.
|
||||
|
||||
Args: season and league shortcut (optional)
|
||||
"""
|
||||
return(self.client.service.GetMatchdataByLeagueSaison(leagueShortcut=league,leagueSaison=season))
|
||||
|
||||
def getMatchday(self, season, matchdaynumber, league='bl1'):
|
||||
""" Get matchday.
|
||||
|
||||
Args: season, matchdaynumber and league shortcut (optional)
|
||||
"""
|
||||
return(self.client.service.GetMatchdataByGroupLeagueSaison(groupOrderID=matchdaynumber,leagueShortcut=league,leagueSaison=season))
|
||||
|
||||
def getTeams(self, season, league='bl1'):
|
||||
return(self.client.service.GetTeamsByLeagueSaison(leagueShortcut=league,leagueSaison=season))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user