<commit_before>import grequests

from flask import Flask, jsonify, redirect

app = Flask(__name__)
app.config.from_object('config')

@app.route('/')
def get_live():

    live_list = []

    streamers = [streamer for streamer in app.config['STREAMERS']]
    filter_ = app.config['FILTER']

    urls = [('https://api.twitch.tv/kraken/streams/%s' % streamer) for streamer in streamers]
    headers = {'Accept': 'application/vnd.twitchtv.v3+json',
               'Client-ID': app.config['CLIENT_ID']}
    requests = (grequests.get(url, headers=headers) for url in urls)
    response = grequests.map(requests, exception_handler=exception_handler)

    for i in response:
        for streamer in streamers:
            data = i.json()
            if data['stream'] is not None:
                if not filter_:
                    live_list.append(streamer)
                else:
                    if filter_ in data['stream']['channel']['status']:
                        live_list.append(streamer)


    new_url = 'http://multistre.am/%s' % ('/'.join(user for user in live_list))

    # return jsonify({'live': live_list})
    return redirect(new_url)

def exception_handler(request, exception):
        return 'Error processing request'<commit_msg>Fix parsing response.<commit_after>import grequests

from flask import Flask, jsonify, redirect

app = Flask(__name__)
app.config.from_object('config')

@app.route('/')
def get_live():

    live_list = []

    streamers = [streamer for streamer in app.config['STREAMERS']]
    filter_ = app.config['FILTER']

    urls = [('https://api.twitch.tv/kraken/streams/%s' % streamer) for streamer in streamers]
    headers = {'Accept': 'application/vnd.twitchtv.v3+json',
               'Client-ID': app.config['CLIENT_ID']}
    requests = (grequests.get(url, headers=headers) for url in urls)
    response = grequests.map(requests, exception_handler=exception_handler)

    for index, value in enumerate(response):
        data = value.json()
        if data['stream'] is not None:
            if not filter_:
                live_list.append(streamers[index])
            elif filter_ in data['stream']['channel']['status']:
                live_list.append(streamers[index])

        # for streamer in streamers:
        #     data = i.json()
        #     if data['stream'] is not None:
        #         # if not filter_:
        #         #     live_list.append(streamer)
        #         # else:
        #         #     if filter_ in data['stream']['channel']['status']:
        #         live_list.append(streamer)


    new_url = 'http://multistre.am/%s' % ('/'.join(user for user in live_list))

    # return jsonify({'live': live_list})
    return redirect(new_url)

def exception_handler(request, exception):
        return 'Error processing request'


if __name__ == '__main__':
    app.run()
{'fraction_non_alphanumeric': 0.13255977496483826, 'fraction_numerical': 0.0007032348804500703, 'mean_word_length': 2.6104060913705585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2150976', 'n_tokens_mistral': 870, 'n_tokens_neox': 841, 'n_words': 200}