File size: 2,117 Bytes
00e640a
 
 
 
 
 
 
99c7f3b
 
00e640a
23ea55b
b01c3d3
 
 
23ea55b
b01c3d3
 
 
23ea55b
00e640a
b01c3d3
 
 
00e640a
b01c3d3
00e640a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23ea55b
00e640a
 
23ea55b
00e640a
b01c3d3
 
 
00e640a
 
 
 
 
 
 
 
 
1c645c1
 
23ea55b
00e640a
 
23ea55b
48b0e4b
1c645c1
 
 
23ea55b
 
 
 
 
48b0e4b
1c645c1
39bb071
b01c3d3
00e640a
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pandas as pd
import streamlit as st
import requests

from io import BytesIO
from PIL import Image

data_titles = pd.read_pickle("data/dict_of_all_titles.pkl")
data_ids = pd.read_pickle("data/dict_of_all_ids.pkl")


def ids_to_titles(ids_list):
    return [data_ids[title] for title in ids_list]


def titles_to_ids(titles_list):
    return [data_titles[id] for id in titles_list]


def generate_app_gamebox(titles):
    """

        Placeholder

    """

    titles_id = titles_to_ids(titles)

    for id in titles_id:
        url = f"https://cdn.cloudflare.steamstatic.com/steam/apps/{id}/header.jpg"
        resp = requests.get(url)

        if resp.status_code == 200:
            container = st.container()
            img_col, pref_col = container.columns([3, 2])

            img_col.image(BytesIO(resp.content))
            pref_col.selectbox(
                "Your rating:",
                options=["Positive", "Negative"],
                key=id,
            )

    return titles_id


def generate_res_gamebox(ids):
    """

        Placeholder

    """

    for id in ids:
        url_page = f"https://store.steampowered.com/app/{id}/"
        url_img = f"https://cdn.cloudflare.steamstatic.com/steam/apps/{id}/header.jpg"
        resp = requests.get(url_img)

        if resp.status_code == 200:
            with st.container():
                st.image(BytesIO(resp.content))
                # st.caption(data_ids[id])
                st.caption(f"[{data_ids[id]}]({url_page})")

            st.divider()


def combine_hybrid_result(res_ease, res_cbf):
    try:
        df = pd.concat([res_ease, res_cbf], axis=0)

        res_final = df.groupby("app_id").sum().sort_values(
            ["predicted_score"], ascending=False)

        # return res_final.head(10).index.tolist()
        return res_final

    except:
        st.error("Recommendation failed. Please select with at least 2 games title.")

    # for title in titles_list:
    #     # url = f"https://store.steampowered.com/app/"
    #     with st.container():