Exemplo n.º 1
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.º 2
0
def webhook():
    print('webhook')
    req = request.get_json()
    print(req['queryResult']['intent']['displayName'])
    rankdata = Mrank()
    # print(rankdata)
    result = ''
    if req['queryResult']['intent']['displayName'] == 'movie ranking':
        count = 1
        for tmp in rankdata:
            result = result + str(count) + '위 : ' + tmp['title'] + '\n'
            if count == 3:
                break
            count += 1
    elif req['queryResult']['intent']['displayName'] == 'movie info - title':
        movieresult = navermovie(req['queryResult']['queryText'])
        print(movieresult)
        mdata = movieresult['items'][0]
        # print(req['queryResult']['queryText'])
        # for tmp in rankdata:
        #     # print('aa')
        #     if req['queryResult']['queryText'] in tmp['title']:
        #         result += '제목 : ' + tmp['title']
        #         result += ' 평점 : ' + tmp['star']
        #         result += ' 장르 : ' + tmp['genre']
        #         print(navermovie(req['queryResult']['queryText']))
        #     # print('result: '+ result)
        print(mdata['director'])
        return movie_info(mdata['image'], mdata['title'],
                          '감독: ' + mdata['director'],
                          ' 출연진: ' + mdata['actor'])
    return ''
Exemplo n.º 3
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.º 4
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.º 5
0
def Navermovie():
    form = NaverMovieForm()

    if request.method == 'POST' and form.validate_on_submit():
        result = navermovie(form.search.data)
        return render_template('naver/navermovie.html',
                               movieinfo_list=result['items'],
                               form=form)
    return render_template('naver/navermovie.html', form=form)
Exemplo n.º 6
0
def Navermovie():
    form = NaverMovieForm()

    if request.method == "POST" and form.validate_on_submit():
        result = navermovie(form.search.data)
        return render_template('naver/navermovie.html',
                               movieinfo_list=result['items'],
                               form=form)

    return render_template('naver/navermovie.html', form=form)


# SQL , NO-SQL

#SQL - MYSQL, 오라클 , 마리아DB, MS-SQL, SQLite
#NO-SQL - MONGODB, Redis, ......
Exemplo n.º 7
0
def Kakaoweather():
    req = request.get_json()

    print(req)
    if req['intent']['name'] == '날씨 지역 블럭':
        print(req['action']['params']['sys_location'])
        result = get_wdata(req['action']['params']['sys_location'])

        imgurl = '맑음 이미지 주소'
        if result['현재일기'] == "":
            imgurl = ''
        elif result['현재일기'] == "구름":
            imgurl = ''

    elif req['intent']['name'] == '영화 정보 블럭':
        result = navermovie("미나리")
        print(result)





    res = {
        "version":"2.0",
        "template":{
            "outputs":[
                {
                   "simpleText" : {"text":result['현재일기']}
                },
                {
                    "simpleImage": {
                        "imageUrl": imgurl,
                        "altText": result['현재일기']
                    }
                }
            ]
        }
    }

    print(res)

    return jsonify(res)
Exemplo n.º 8
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': '무슨 말인지 모르겠어요.'}
Exemplo n.º 9
0
def Kakaomovie():
    result = get_movie()

    moviedata1 = navermovie(result[0][0])
    moviedata2 = navermovie(result[1][0])
    moviedata3 = navermovie(result[2][0])


    print(moviedata1['items'][0]['title'])
    print(moviedata1['items'][0]['subtitle'])
    print(moviedata1['items'][0]['image'])
    print(moviedata1['items'][0]['link'])

    print(result[0][0])

    res = {
          "version": "2.0",
          "template": {
            "outputs": [
              {
                "listCard": {
                  "header": {
                    "title": "추천영화"
                  },
                  "items": [
                    {
                      "title": moviedata1['items'][0]['title'],
                      "description": moviedata1['items'][0]['subtitle'],
                      "imageUrl": moviedata1['items'][0]['image'],
                      "link": {
                        "web": moviedata1['items'][0]['link']
                      }
                    },
                    {
                      "title": moviedata2['items'][0]['title'],
                      "description": moviedata2['items'][0]['subtitle'],
                      "imageUrl":moviedata2['items'][0]['image'] ,
                      "link": {
                        "web": moviedata2['items'][0]['link']
                      }
                    },
                    {
                      "title": moviedata3['items'][0]['title'],
                      "description": moviedata3['items'][0]['subtitle'],
                      "imageUrl": moviedata3['items'][0]['image'],
                      "link": {
                        "web": moviedata3['items'][0]['link']
                      }
                    }
                  ],
                  "buttons": [
                    {
                      "label": "구경가기",
                      "action": "webLink",
                      "webLinkUrl": "https://namu.wiki/w/%EC%B9%B4%EC%B9%B4%EC%98%A4%ED%94%84%EB%A0%8C%EC%A6%88"
                    }
                  ]
                }
              }
            ]
          }
        }
    return jsonify(res)