示例#1
0
 def Events(self, event=None, filename=None, season=None):
     eventlist = []
     if event or season or filename:
         if event and not season and not filename:
             url = '%s/%s/searchevents.php?e=%s' % (
                 API_BASE_URL, API_KEY, str(event).replace(" ", "_"))
         elif event and season:
             url = '%s/%s/searchevents.php?e=%s&s=%s' % (
                 API_BASE_URL, API_KEY, str(event).replace(
                     " ", "_"), str(season))
         elif filename:
             url = '%s/%s/searchfilename.php?e=%s' % (
                 API_BASE_URL, API_KEY, str(filename).replace(" ", "_"))
         else:
             url = ""
         if url:
             data = json.load(urllib2.urlopen(url))
             events = data["event"]
             if events:
                 for ev in events:
                     eventlist.append(_event.as_event(ev))
     else:
         xbmc.log(
             msg=
             "[TheSportsDB] event and season or filename must be provided",
             level=xbmc.LOGERROR)
     return eventlist
示例#2
0
 def Events(self, event=None, filename=None, season=None):
     eventlist = []
     if event or season or filename:
         if event and not season and not filename:
             url = "%s/%s/searchevents.php?e=%s" % (API_BASE_URL, API_KEY, str(event).replace(" ", "_"))
         elif event and season:
             url = "%s/%s/searchevents.php?e=%s&s=%s" % (
                 API_BASE_URL,
                 API_KEY,
                 str(event).replace(" ", "_"),
                 str(season),
             )
         elif filename:
             url = "%s/%s/searchfilename.php?e=%s" % (API_BASE_URL, API_KEY, str(filename).replace(" ", "_"))
         else:
             url = ""
         if url:
             data = json.load(urllib2.urlopen(url))
             events = data["event"]
             if events:
                 for ev in events:
                     eventlist.append(_event.as_event(ev))
     else:
         xbmc.log(msg="[TheSportsDB] event and season or filename must be provided", level=xbmc.LOGERROR)
     return eventlist
示例#3
0
 def Lookup(self,
            datestring=None,
            datetimedate=None,
            league=None,
            leagueid=None,
            season=None,
            rnd=None,
            sport=None):
     eventlist = []
     if leagueid and season and rnd:
         url = '%s/%s/eventsround.php?id=%s&r=%s&s=%s' % (
             API_BASE_URL, API_KEY, str(leagueid), str(rnd),
             str(season))
     elif leagueid and season and not rnd:
         url = '%s/%s/eventsseason.php?id=%s&s=%s' % (
             API_BASE_URL, API_KEY, str(leagueid), str(season))
     elif datestring or datetimedate:
         if datestring:
             if _util.CheckDateString(datestring):
                 pass
             else:
                 xbmc.log(
                     msg=
                     "[TheSportsDB] Wrong format for the datestring. Valid format is {YYYY-MM-DD} (eg: 2014-10-10)",
                     level=xbmc.LOGERROR)
                 return eventlist
         else:
             if _util.CheckDateTime(datetimedate):
                 datestring = datetimedate.strftime("%Y-%m-%d")
             else:
                 xbmc.log(
                     msg=
                     "[TheSportsDB] Wrong type for datetime object. A python datetime object is required",
                     level=xbmc.LOGERROR)
                 return eventlist
         if sport:
             url = '%s/%s/eventsday.php?d=%s&s=%s' % (
                 API_BASE_URL, API_KEY, str(datestring), str(sport))
         elif league:
             url = '%s/%s/eventsday.php?d=%s&l=%s' % (
                 API_BASE_URL, API_KEY, str(datestring),
                 urllib.quote(league))
         else:
             url = '%s/%s/eventsday.php?d=%s' % (API_BASE_URL, API_KEY,
                                                 str(datestring))
     else:
         xbmc.log(
             msg=
             "[TheSportsDB] Wrong method invocation. You need to declare either a datetimedate (datetime.date), a datestring, a leagueid, season, rnd or sport",
             level=xbmc.LOGERROR)
         return eventlist
     data = json.load(urllib2.urlopen(url))
     events = data["events"]
     if events:
         for event in events:
             eventlist.append(_event.as_event(event))
     return eventlist
示例#4
0
 def Lookup(
     self, datestring=None, datetimedate=None, league=None, leagueid=None, season=None, rnd=None, sport=None
 ):
     eventlist = []
     if leagueid and season and rnd:
         url = "%s/%s/eventsround.php?id=%s&r=%s&s=%s" % (
             API_BASE_URL,
             API_KEY,
             str(leagueid),
             str(rnd),
             str(season),
         )
     elif leagueid and season and not rnd:
         url = "%s/%s/eventsseason.php?id=%s&s=%s" % (API_BASE_URL, API_KEY, str(leagueid), str(season))
     elif datestring or datetimedate:
         if datestring:
             if _util.CheckDateString(datestring):
                 pass
             else:
                 xbmc.log(
                     msg="[TheSportsDB] Wrong format for the datestring. Valid format is {YYYY-MM-DD} (eg: 2014-10-10)",
                     level=xbmc.LOGERROR,
                 )
                 return eventlist
         else:
             if _util.CheckDateTime(datetimedate):
                 datestring = datetimedate.strftime("%Y-%m-%d")
             else:
                 xbmc.log(
                     msg="[TheSportsDB] Wrong type for datetime object. A python datetime object is required",
                     level=xbmc.LOGERROR,
                 )
                 return eventlist
         if sport:
             url = "%s/%s/eventsday.php?d=%s&s=%s" % (API_BASE_URL, API_KEY, str(datestring), str(sport))
         elif league:
             url = "%s/%s/eventsday.php?d=%s&l=%s" % (
                 API_BASE_URL,
                 API_KEY,
                 str(datestring),
                 urllib.quote(league),
             )
         else:
             url = "%s/%s/eventsday.php?d=%s" % (API_BASE_URL, API_KEY, str(datestring))
     else:
         xbmc.log(
             msg="[TheSportsDB] Wrong method invocation. You need to declare either a datetimedate (datetime.date), a datestring, a leagueid, season, rnd or sport",
             level=xbmc.LOGERROR,
         )
         return eventlist
     data = json.load(urllib2.urlopen(url))
     events = data["events"]
     if events:
         for event in events:
             eventlist.append(_event.as_event(event))
     return eventlist
示例#5
0
 def Event(self, eventid=None):
     eventlist = []
     if eventid:
         url = "%s/%s/lookupevent.php?id=%s" % (API_BASE_URL, API_KEY, str(eventid))
         data = json.load(urllib2.urlopen(url))
         events = data["events"]
         if events:
             for ev in events:
                 eventlist.append(_event.as_event(ev))
     else:
         xbmc.log(msg="[TheSportsDB] eventid must be provided", level=xbmc.LOGERROR)
     return eventlist
示例#6
0
 def League(self, leagueid=None):
     eventlist = []
     if leagueid:
         url = "%s/%s/eventspastleague.php?id=%s" % (API_BASE_URL, API_KEY, str(leagueid))
         data = json.load(urllib2.urlopen(url))
         events = data["events"]
         if events:
             for event in events:
                 eventlist.append(_event.as_event(event))
     else:
         xbmc.log(msg="[TheSportsDB] leagueid must be provided", level=xbmc.LOGERROR)
     return eventlist
示例#7
0
 def Team(self, teamid=None):
     eventlist = []
     if teamid:
         url = "%s/%s/eventslast.php?id=%s" % (API_BASE_URL, API_KEY, str(teamid))
         data = json.load(urllib2.urlopen(url))
         events = data["results"]
         if events:
             for event in events:
                 eventlist.append(_event.as_event(event))
     else:
         xbmc.log(msg="[TheSportsDB] teamid must be provided", level=xbmc.LOGERROR)
     return eventlist
示例#8
0
 def Event(self, eventid=None):
     eventlist = []
     if eventid:
         url = '%s/%s/lookupevent.php?id=%s' % (API_BASE_URL, API_KEY,
                                                str(eventid))
         data = json.load(urllib2.urlopen(url))
         events = data["events"]
         if events:
             for ev in events:
                 eventlist.append(_event.as_event(ev))
     else:
         xbmc.log(msg="[TheSportsDB] eventid must be provided",
                  level=xbmc.LOGERROR)
     return eventlist
示例#9
0
 def League(self, leagueid=None):
     eventlist = []
     if leagueid:
         url = '%s/%s/eventspastleague.php?id=%s' % (
             API_BASE_URL, API_KEY, str(leagueid))
         data = json.load(urllib2.urlopen(url))
         events = data["events"]
         if events:
             for event in events:
                 eventlist.append(_event.as_event(event))
     else:
         xbmc.log(msg="[TheSportsDB] leagueid must be provided",
                  level=xbmc.LOGERROR)
     return eventlist
示例#10
0
 def Team(self, teamid=None):
     eventlist = []
     if teamid:
         url = '%s/%s/eventslast.php?id=%s' % (API_BASE_URL,
                                               API_KEY, str(teamid))
         data = json.load(urllib2.urlopen(url))
         events = data["results"]
         if events:
             for event in events:
                 eventlist.append(_event.as_event(event))
     else:
         xbmc.log(msg="[TheSportsDB] teamid must be provided",
                  level=xbmc.LOGERROR)
     return eventlist