Beispiel #1
0
def index():
    if is_mobile():
        return m_index()
    match=Match.objects(status=1,begin_time__gt=datetime.now()-timedelta(hours=3),stream=1).order_by('begin_time','+a')
    return render_template('main.html',matches=match)
Beispiel #2
0
def main2():
    match=Match.objects(begin_time__gt=datetime.now()-timedelta(hours=3),stream=1).order_by('begin_time','+a')
    return render_template('main.html',matches=match)
Beispiel #3
0
def leisu():
    #match=Match.objects(begin_time__gt=datetime.datetime.now())
    match=Match.objects()
    return render_template('leisu.html',matches=match)
Beispiel #4
0
def matches():
    page=int(request.args.get('page',0))
    pageSize=int(request.args.get('pageSize',20))
    matches = Match.objects(status=1).order_by('begin_time','a+').skip(page*pageSize).limit(pageSize)  #
    return jsonify(code=0,result={'matches':[m.to_mongo() for m in matches]})
Beispiel #5
0
def parse():
    res = requests.get('http://api.leisu.com/app/live/live?app=0&lang=0&platform=2&ver=2.6.1',headers=header)
    j = json.loads(res.text)
    print res.text
    mathes = j['matches']
    events = j['events']
    for match in mathes:
        m = Match()
        m.match_id = match[0]
        m.league_id = str(match[1])
        m.league_name = events[str(m.league_id)][0]
        m.begin_time = datetime.fromtimestamp(match[4])
        home = match[5]
        m.home_id = str(home[0])
        m.home_name = home[1]
        m.home_score = home[2]
        away = match[6]
        m.away_id = str(away[0])
        m.away_name = away[1]
        m.away_score = away[2]
        m.home_head, m.away_head = headers(m.match_id)
        m.stream = match[10]
        m.ttzb = 0
        match_found = Match.objects(match_id=m.match_id)
        if match_found:
            match_found.update_one(home_score=m.home_score, away_score=m.away_score,
                                   upsert=True)
        else:
            m.save()