Spaces:
Running
Running
Alejandro Cremades
commited on
Commit
•
82e5d3a
1
Parent(s):
46fce67
Show 20 top results as Scrufall links
Browse files- Middle_School_Card_List.py +15 -5
Middle_School_Card_List.py
CHANGED
@@ -1,8 +1,18 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
mslist_path = "output/middleschool.csv"
|
5 |
-
|
6 |
|
7 |
st.write(
|
8 |
"""
|
@@ -24,7 +34,7 @@ results_ja_df = mslist_df[
|
|
24 |
results_df = results_en_df.merge(results_ja_df, how="outer")
|
25 |
if name_input:
|
26 |
st.write(results_df.shape[0], f'cards found by "{name_input}"')
|
27 |
-
results_df[
|
28 |
-
|
29 |
-
)
|
30 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import urllib.parse
|
4 |
+
|
5 |
+
|
6 |
+
def compose_scryfall_url(x):
|
7 |
+
return f"https://scryfall.com/search?q=prefer%3Aoldest%20!%22{urllib.parse.quote_plus(x)}%22"
|
8 |
+
|
9 |
+
|
10 |
+
def row_to_link(x):
|
11 |
+
st.markdown(f"- [{x['name']} / {x.name_ja}]({x.link})")
|
12 |
+
|
13 |
|
14 |
mslist_path = "output/middleschool.csv"
|
15 |
+
number_shown_results = 20
|
16 |
|
17 |
st.write(
|
18 |
"""
|
|
|
34 |
results_df = results_en_df.merge(results_ja_df, how="outer")
|
35 |
if name_input:
|
36 |
st.write(results_df.shape[0], f'cards found by "{name_input}"')
|
37 |
+
if results_df.shape[0] > number_shown_results:
|
38 |
+
st.write(f"Top {number_shown_results} results:")
|
39 |
+
results_df["link"] = results_df["name"].apply(compose_scryfall_url)
|
40 |
+
results_df[:number_shown_results].transpose().apply(row_to_link)
|