Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- app.py +79 -0
- channel_matrix.xlsx +0 -0
- requirements.txt +5 -0
- saved_lists_creds.json +13 -0
app.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import gspread
|
| 4 |
+
from oauth2client.service_account import ServiceAccountCredentials
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
|
| 7 |
+
st.set_page_config(page_title="Skype Contact Manager", layout="wide")
|
| 8 |
+
st.title("π Skype Contacts: Saved Lists")
|
| 9 |
+
|
| 10 |
+
CONTACTS_FILE = "contacts.xlsx"
|
| 11 |
+
CREDS_FILE = "saved_lists_creds.json"
|
| 12 |
+
SHEET_NAME = "saved_lists"
|
| 13 |
+
|
| 14 |
+
# Load contacts
|
| 15 |
+
@st.cache_data
|
| 16 |
+
def load_contacts():
|
| 17 |
+
df = pd.read_excel(CONTACTS_FILE)
|
| 18 |
+
df = df[["display_name", "profile.locations[0].country"]].copy()
|
| 19 |
+
df.columns = ["display_name", "country"]
|
| 20 |
+
return df
|
| 21 |
+
|
| 22 |
+
contacts_df = load_contacts()
|
| 23 |
+
|
| 24 |
+
# Google Sheets setup
|
| 25 |
+
@st.cache_resource
|
| 26 |
+
def get_sheet():
|
| 27 |
+
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
| 28 |
+
creds = ServiceAccountCredentials.from_json_keyfile_name(CREDS_FILE, scope)
|
| 29 |
+
client = gspread.authorize(creds)
|
| 30 |
+
sheet = client.open_by_url("https://docs.google.com/spreadsheets/d/1bYRrOokZ_D85fj_0bbByc6dfaxW50Hj2PqDRG_r25yU")
|
| 31 |
+
return sheet.worksheet(SHEET_NAME)
|
| 32 |
+
|
| 33 |
+
sheet = get_sheet()
|
| 34 |
+
|
| 35 |
+
# Ticking contacts
|
| 36 |
+
st.markdown("### β
Tick Contacts to Save in a List")
|
| 37 |
+
selected_contacts = st.multiselect("Select contacts", contacts_df["display_name"].tolist())
|
| 38 |
+
|
| 39 |
+
list_name = st.text_input("π Name this list")
|
| 40 |
+
tags_input = st.text_input("π· Optional tags (comma-separated)")
|
| 41 |
+
|
| 42 |
+
if st.button("πΎ Save List to Google Sheet"):
|
| 43 |
+
if not list_name:
|
| 44 |
+
st.warning("Please enter a list name.")
|
| 45 |
+
elif not selected_contacts:
|
| 46 |
+
st.warning("Please select at least one contact.")
|
| 47 |
+
else:
|
| 48 |
+
contact_csv = ",".join(selected_contacts)
|
| 49 |
+
tags = tags_input.strip()
|
| 50 |
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 51 |
+
sheet.append_row([list_name, contact_csv, tags, timestamp])
|
| 52 |
+
st.success(f"List '{list_name}' saved successfully!")
|
| 53 |
+
|
| 54 |
+
# Load and manage saved lists
|
| 55 |
+
st.markdown("---")
|
| 56 |
+
st.markdown("### π Load or Manage Saved Lists")
|
| 57 |
+
|
| 58 |
+
saved_lists = sheet.get_all_records()
|
| 59 |
+
if saved_lists:
|
| 60 |
+
list_names = [entry["list_name"] for entry in saved_lists]
|
| 61 |
+
selected_list_name = st.selectbox("π Select a list", list_names)
|
| 62 |
+
|
| 63 |
+
if selected_list_name:
|
| 64 |
+
entry = next((x for x in saved_lists if x["list_name"] == selected_list_name), None)
|
| 65 |
+
if entry:
|
| 66 |
+
st.markdown(f"**List Name:** {entry['list_name']}")
|
| 67 |
+
st.markdown(f"**Contacts:** {entry['contacts_csv']}")
|
| 68 |
+
st.markdown(f"**Tags:** {entry['tags']}")
|
| 69 |
+
st.markdown(f"**Saved on:** {entry['timestamp']}")
|
| 70 |
+
|
| 71 |
+
# Delete
|
| 72 |
+
if st.button("π Delete this list"):
|
| 73 |
+
all_values = sheet.get_all_values()
|
| 74 |
+
headers = all_values[0]
|
| 75 |
+
for idx, row in enumerate(all_values[1:], start=2):
|
| 76 |
+
if row[0] == selected_list_name:
|
| 77 |
+
sheet.delete_rows(idx)
|
| 78 |
+
st.success("List deleted. Please refresh.")
|
| 79 |
+
st.stop()
|
channel_matrix.xlsx
ADDED
|
Binary file (31.5 kB). View file
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
pandas
|
| 3 |
+
openpyxl
|
| 4 |
+
gspread
|
| 5 |
+
oauth2client
|
saved_lists_creds.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"type": "service_account",
|
| 3 |
+
"project_id": "skype-tool",
|
| 4 |
+
"private_key_id": "75bdbedee0d3e0a2579023488bffe325634a4b10",
|
| 5 |
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCiC8AV6sEwDajJ\nLfZ3AT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5SI0tEsuJd3kJUtSZoqYAat1+vEtp\nu1h6AkcIE+9jBUmXzjfpaBlF6LsWqnApsasA27vigYBRjHeWSI3duqhDivov+Z6Q\nsNVfdBZYLBhzx4bMwjuCmJga6k1f48SP+bxQah3rHw88Vh5D+mvr55ZabQKBgA3r\nR/vWj/S5sF+tdH6XjtirIXRl+NvQapXoRCXuzLTBJQDCbNz/YTI4o9lZuN9MpcGi\nJgVHi2YN6KVB0KWVxftNmB4IicekbhdLLvEO7h58ju7cZkEdSz3I1SkG9zyhQarL\nt5o9FRXUIdZyO7ZSNOn9rPJP2cHbNL3eHuVYu+PlAoGAegvctSGGUZdZb8JA3GU3\nQLAYNrr/2ARgAMfNakz+u56l7xobX+nABBc3R8nxfv1u1TpreirsvpztMllgCXay\nBboJW6FAla9tzFnaSdVqfjl1/e1Kd1kEd8UgiCV2NkmHuhi7EYdzJoKIIF6PeWLK\nOm61JTottodhyxJSR9MqArE=\n-----END PRIVATE KEY-----\n",
|
| 6 |
+
"client_email": "streamlit-sheets-access@skype-tool.iam.gserviceaccount.com",
|
| 7 |
+
"client_id": "116515866275003778406",
|
| 8 |
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
| 9 |
+
"token_uri": "https://oauth2.googleapis.com/token",
|
| 10 |
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
| 11 |
+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/streamlit-sheets-access%40skype-tool.iam.gserviceaccount.com",
|
| 12 |
+
"universe_domain": "googleapis.com"
|
| 13 |
+
}
|