Exemplo n.º 1
0
def webhook():
    req = request.get_json()
    # print(req)
    if req['queryResult']['intent']['displayName'] == 'movie ranking':
        rankdata = Mrank()  #movieapi
        result = ''
        count = 1
        for temp in rankdata:
            result = result + str(count) + '위 : ' + temp[
                'title']  # 영화 순위 가져오기.
            if count == 3:
                break
            count += 1
    elif req['queryResult']['intent']['displayName'] == 'movie info - custom':

        movieresult = navermovie(req['queryResult']['queryText'])

        moviedata = movieresult['items'][0]

        return movie_info(
            moviedata['image'],
            moviedata['title'].replace('<b>',
                                       '').replace('</b>',
                                                   ''), moviedata['link'],
            '감독:' + moviedata['director'] + '출연자:' + moviedata['actor'])
    elif req['queryResult']['intent']['displayName'] == 'weather - city':
        wdata = get_wdata(req['queryResult']['queryText'])
        print(wdata)
        return weather_info(wdata)
    elif req['queryResult']['intent'][
            'displayName'] == 'Nshop - custom - custom':
        shopresult = navershop(req['queryResult']['queryText'])
        return shop_info(shopresult['items'])
Exemplo n.º 2
0
def webhook():
    req = request.get_json()
    if req['queryResult']['intent']['displayName'] =='movie ranking':
        rankdata = Mrank()

        result = ''
        count = 1
        for temp in rankdata:
            result = result + str(count) + '위 : '+temp['title']
            if count==3:
                break
            count += 1
    elif req['queryResult']['intent']['displayName'] =='movie info - custom':
        movieresult = navermovie(req['queryResult']['queryText'])
        moviedata = movieresult['items'][0]


        return movie_info(moviedata['image'],moviedata['title'],moviedata['link'],
                          '감독:'+moviedata['director']+' 출연자'+moviedata['actor'])
    elif req['queryResult']['intent']['displayName'] == 'weather - custom':
        wdata = get_wdata(req['queryResult']['queryText'])
        print(wdata)
        return weather_info(wdata)
    elif req['queryResult']['intent']['displayName'] == 'product - custom':
        sdata = navershop(req['queryResult']['queryText'])
        return shop_infos(sdata['items'])
Exemplo n.º 3
0
def webhook():
    req = request.get_json()
    print('---------1')
    if req['queryResult']['intent']['displayName'] == 'movie ranking':
        rankdata = Mrank()

        result = ''
        count = 1
        for temp in rankdata:
            result = result + str(count) + '위 : ' + temp['title']
            if count == 3:
                break
            count += 1
    elif req['queryResult']['intent']['displayName'] == 'movie info - custom':

        movieresult = navermovie(req['queryResult']['queryText'])

        moviedata = movieresult['items'][0]

        return movie_info(
            moviedata['image'], moviedata['title'], moviedata['link'],
            '감독:' + moviedata['director'] + ' 출연자' + moviedata['actor'])
    elif req['queryResult']['intent'][
            'displayName'] == 'Weather info - location':
        print('---------2')
        wdata = get_wdata(req['queryResult']['queryText'])
        print('---------3')
        print(wdata)
        return weather_info(wdata)
    elif req['queryResult']['intent']['displayName'] == 'thing info - custom':
        thingresult = navershop(req['queryResult']['queryText'])
        return thing_info(thingresult['items'])
Exemplo n.º 4
0
def webhook():
    req = request.get_json()
    # print(req)
    if req['queryResult']['intent'][
            'displayName'] == 'movie ranking':  #intent가 movie ranking이라면
        rankdata = collect_movie_data()
        result = ''
        count = 1
        for temp in rankdata:
            result = result + str(count) + '위: ' + temp['title'] + ' '
            if count == 3:
                break
            count += 1
        return {'fulfillmentText': result}

    if req['queryResult']['intent'][
            'displayName'] == 'movie info - input_movie':
        movie_info = navermovie(req['queryResult']['queryText'])
        # movie_info = movie_info['items']
        movie_info = movie_info['items'][0]
        print(movie_info)

        # infos = []
        # for i in movie_info:
        #     movie_title = i['title'].replace('<b>','').replace('</b>','')
        #     subtitle = i['subtitle']
        #     pubDate = i['pubDate']
        #     director = i['director']
        #     actor = i['actor']
        #     userRating = i['userRating']
        #     info = '제목: ' + movie_title + '\n' + '부제: ' + subtitle + '\n' + '개봉: ' + pubDate + '\n' + '감독: ' + director + '\n' + \
        #            '출연: ' + actor + '\n' + '평점: ' + userRating + '\n'
        #     infos.append(info)
        #
        #     print_info = ''
        #     for info in infos:
        #         if infos[-1] != info:
        #             print_info += info + '=================================================================\n'
        #         else:
        #             print_info += info
        # return {'fulfillmentText': print_info}
        return movie_info_with_links(
            movie_info['image'],
            movie_info['title'].replace('<b>',
                                        '').replace('</b>',
                                                    ''), movie_info['link'],
            '감독: ' + movie_info['director'] + ', 출연: ' + movie_info['actor'])

    if req['queryResult']['intent']['displayName'] == 'Weather - region':
        result = get_wdata(req['queryResult']['queryText'])
        return {'fulfillmentText': result}

    if req['queryResult']['intent']['displayName'] == 'Shop - search':
        result = navershop(req['queryResult']['queryText'])
        items = result['items']
        item_list = []
        for item in items:
            title = item['title']
            link = item['link']
            image = item['image']
            lprice = item['lprice']
            hprice = item['hprice']
            if hprice == '':
                hprice = lprice
            item_dic = {
                'title': title,
                'link': link,
                'image': image,
                'lprice': lprice,
                'hprice': hprice
            }
            item_list.append(item_dic)
        return shop_info_with_links(item_list)

    return {'fulfillmentText': '무슨 말인지 모르겠어요.'}