Spaces:
Running
Running
berkaygkv54
commited on
Commit
•
72f8098
1
Parent(s):
84201b6
submit playlist
Browse files
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
app.py
CHANGED
@@ -7,8 +7,14 @@ import pickle
|
|
7 |
import torch
|
8 |
import pandas as pd
|
9 |
import json
|
|
|
|
|
|
|
|
|
|
|
10 |
st.set_page_config(page_title="Curate me a playlist", layout="wide")
|
11 |
|
|
|
12 |
@st.cache_data
|
13 |
def load_data():
|
14 |
vectors = np.load(ProjectPaths.DATA_DIR.joinpath("vectors", "audio_representations.npy"))
|
@@ -59,4 +65,39 @@ if is_clicked:
|
|
59 |
},
|
60 |
hide_index=False,
|
61 |
use_container_width=True
|
62 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
import torch
|
8 |
import pandas as pd
|
9 |
import json
|
10 |
+
import os
|
11 |
+
import smtplib, ssl
|
12 |
+
from email.mime.multipart import MIMEMultipart
|
13 |
+
from email.mime.text import MIMEText
|
14 |
+
from email.utils import COMMASPACE, formatdate
|
15 |
st.set_page_config(page_title="Curate me a playlist", layout="wide")
|
16 |
|
17 |
+
|
18 |
@st.cache_data
|
19 |
def load_data():
|
20 |
vectors = np.load(ProjectPaths.DATA_DIR.joinpath("vectors", "audio_representations.npy"))
|
|
|
65 |
},
|
66 |
hide_index=False,
|
67 |
use_container_width=True
|
68 |
+
)
|
69 |
+
|
70 |
+
form = st.form("form")
|
71 |
+
form.write("You can submit the playlist you've curated")
|
72 |
+
sender = form.text_input("Name of the curator")
|
73 |
+
query = session.text_input
|
74 |
+
playlist = [f"{k}\n" for k in dataframe.index]
|
75 |
+
playlist_string = "\n".join(dataframe.index.tolist())
|
76 |
+
body = f"""
|
77 |
+
Curator: {sender}
|
78 |
+
Query: {session.text_input}
|
79 |
+
|
80 |
+
Playlist:
|
81 |
+
{playlist_string}
|
82 |
+
"""
|
83 |
+
|
84 |
+
is_submit = form.form_submit_button("Submit")
|
85 |
+
|
86 |
+
if is_submit:
|
87 |
+
port = 465 # For SSL
|
88 |
+
smtp_server = "smtp.gmail.com"
|
89 |
+
sender_email = os.getenv("EMAIL_ADDRESS")
|
90 |
+
receiver_email = os.getenv("EMAIL_RECEIVER")
|
91 |
+
password = os.getenv("EMAIL_PASSWORD")
|
92 |
+
|
93 |
+
msg = MIMEMultipart()
|
94 |
+
msg['From'] = os.getenv("EMAIL_ADDRESS")
|
95 |
+
msg['To'] = COMMASPACE.join(receiver_email)
|
96 |
+
msg['Date'] = formatdate(localtime=True)
|
97 |
+
msg['Subject'] = "Curate me a playlist submitted!"
|
98 |
+
msg.attach(MIMEText(body))
|
99 |
+
|
100 |
+
context = ssl.create_default_context()
|
101 |
+
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
|
102 |
+
server.login(sender_email, password)
|
103 |
+
server.sendmail(sender_email, receiver_email, msg)
|