Exemplo n.º 1
0
def add_lives():

    if request.method == 'GET':
        return render_template('admin/event/schedule_list.html')

    live_str = request.form.to_dict()['data']
    live_dict = eval(live_str)
    match_id = int(live_dict['id'])

    # delete the lives
    def delete_live(lives):
        MatchLiveService.delete(lives['id'])
        return True

    match_lives = MatchLiveService.get_all(match_id)
    match_delete= map(delete_live, match_lives)

    lives = live_dict['allSources']

    for live in lives:
        try:
            stream_time = live['stream_time']
            if stream_time:
                resault= re.search('/', stream_time)
                if resault:
                    tmp = time.strptime(live['stream_time'], "%Y/%m/%d %H:%M")
                    live['stream_time'] = time.strftime("%Y-%m-%d %H:%M:%S", tmp)
        except:
            raise InvalidArgument()
        live['match_id'] = int(live_dict['id'])
        live['site'] = live['sourcesName']
        live['play_url'] = live['sourcesUrl']
        live['play_code'] = live['playCode']
        live['feed_code'] = live['feedCode']
        live['play_html'] = live['playHtml']
        del(live['sourcesName'])
        del(live['sourcesUrl'])
        del(live['playCode'])
        del(live['feedCode'])
        del(live['playHtml'])

    # get match info
    def add_match_info(lives):
        MatchLiveService.add_dict(lives)
        return True
    matches = map(add_match_info, lives)

    return jsonify_with_data((200, 'OK'))
Exemplo n.º 2
0
def add_lives():

    if request.method == 'GET':
        return render_template('admin/event/schedule_list.html')

    live_str = request.form.to_dict()['data']
    live_dict = eval(live_str)

    match_id = int(live_dict['id'])

    # delete the lives
    def delete_live(lives):
        MatchLiveService.delete(lives['id'])
        return True

    match_lives = MatchLiveService.get_all(match_id)
    match_delete = map(delete_live, match_lives)

    lives = live_dict['allSources']

    for live in lives:
        live['match_id'] = int(live_dict['id'])
        live['site'] = live['sourcesName']
        live['play_url'] = live['sourcesUrl']
        live['play_code'] = live['playCode']
        live['feed_code'] = live['feedCode']
        live['play_html'] = live['playHtml']
        del (live['sourcesName'])
        del (live['sourcesUrl'])
        del (live['playCode'])
        del (live['feedCode'])
        del (live['playHtml'])
        del (live['isOwn'])

    # get match info
    def add_match_info(lives):
        MatchLiveService.add_dict(lives)
        return True

    matches = map(add_match_info, lives)

    return redirect(url_for('admin.list_schedules'))
Exemplo n.º 3
0
 def add_match_info(lives):
     MatchLiveService.add_dict(lives)
     return True
Exemplo n.º 4
0
 def delete_live(lives):
     MatchLiveService.delete(lives['id'])
     return True
Exemplo n.º 5
0
 def get_match_info(match):
     lives = MatchLiveService.get_all(match_id=match.id)
     match = MatchService.get_match_info(match.id)
     match['lives'] = lives
     return match