Ethscriptions commited on
Commit
e3a9baf
·
1 Parent(s): c16d3c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -25,7 +25,7 @@ my_style = '''
25
  }
26
 
27
  .tag:hover {
28
- background-color: #cffd51; /* 鼠标经过时的背景颜色 */
29
  }
30
 
31
  .tag:active {
@@ -39,6 +39,10 @@ config.read(rarbg_config_file)
39
  searches_value = config['searches']['value']
40
 
41
 
 
 
 
 
42
  # 图片Base64
43
  def image_to_base64(img_path):
44
  with open(img_path, "rb") as image_file:
@@ -87,14 +91,14 @@ def convert_size(size_in_bytes):
87
  def download_link(df, filename="search_results.csv"):
88
  csv = df.to_csv(index=False)
89
  b64 = base64.b64encode(csv.encode()).decode()
90
- href = f'<a href="data:file/csv;base64,{b64}" download="{filename}">下载搜索结果</a>'
91
  return href
92
 
93
 
94
  st.set_page_config(page_title="RARBG Database Search", page_icon="🌞", layout='centered', initial_sidebar_state='auto')
95
-
96
  # 首页
97
- st.markdown(f'# <a href="https://www.rarbg.quest/" target="_self"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("rarbg.png"))}" alt="Image" width="48px" height="48px" style="border-radius: 8px; box-shadow: 3px 3px 10px rgba(0,0,0,0.1);"/></a> :blue[RARBG 搜索]', unsafe_allow_html=True)
98
 
99
  # 搜索框
100
  keyword = st.text_input("输入你想搜索的关键词:")
@@ -111,7 +115,7 @@ if st.button("搜索"):
111
  df['size'] = df['size'].apply(convert_size)
112
  df = df.rename(columns={'hash': '链接', 'title': '标题', 'size': '文件大小 (GB)', 'dt': '日期'})
113
  df = df[['标题', '链接', '文件大小 (GB)', '日期']]
114
-
115
  # 显示结果
116
  st.dataframe(df, hide_index=False, use_container_width=True)
117
 
@@ -129,13 +133,17 @@ if st.button("搜索"):
129
  with open(rarbg_config_file, 'w') as configfile:
130
  config.write(configfile)
131
  else:
132
- st.warning("没有找到记录。")
133
  else:
134
- st.error("请输入一些关键词。")
135
-
136
- st.success(f'''##### 广告位
137
- 😭 接不到广告,我太穷了。请联系我 Telegram: @NervosCKB,用户搜索总次数:{searches_value}''')
138
- st.error('''##### 温馨提示
139
- 本站不提供任何包含反动、淫秽、色情、暴力、侮辱、诽谤等不良信息。当你浏览本网站时,请自觉遵守法律法规,对自己的行为承担全部责任。''')
140
- st.info('''##### 使用说明
141
- 请在文本框内输入关键词,仅限英文,并点击搜索按钮进行查询。若需输入多个关键词,可用空格进行分隔;若希望某个关键词不在搜索结果中出现,可在关键词前加上 "-" 符号。''')
 
 
 
 
 
25
  }
26
 
27
  .tag:hover {
28
+ background-color: #8FACFF; /* 鼠标经过时的背景颜色 */
29
  }
30
 
31
  .tag:active {
 
39
  searches_value = config['searches']['value']
40
 
41
 
42
+ def get_style(content):
43
+ return f'<span class="tag">{content}</span>'
44
+
45
+
46
  # 图片Base64
47
  def image_to_base64(img_path):
48
  with open(img_path, "rb") as image_file:
 
91
  def download_link(df, filename="search_results.csv"):
92
  csv = df.to_csv(index=False)
93
  b64 = base64.b64encode(csv.encode()).decode()
94
+ href = f'<span class="tag"><a href="data:file/csv;base64,{b64}" download="{filename}" style="text-decoration: none;">下载搜索结果</a></span>'
95
  return href
96
 
97
 
98
  st.set_page_config(page_title="RARBG Database Search", page_icon="🌞", layout='centered', initial_sidebar_state='auto')
99
+ st.markdown(f'{my_style}', unsafe_allow_html=True)
100
  # 首页
101
+ st.markdown(f'# <a href="https://www.rarbg.quest/" target="_self"><img src="data:image/jpeg;base64,{image_to_base64(os.path.join("rarbg.png"))}" alt="Image" width="64px" height="64px" style="border-radius: 8px; box-shadow: 3px 3px 10px rgba(0,0,0,0.1);"/></a> :blue[RARBG 磁力搜索]', unsafe_allow_html=True)
102
 
103
  # 搜索框
104
  keyword = st.text_input("输入你想搜索的关键词:")
 
115
  df['size'] = df['size'].apply(convert_size)
116
  df = df.rename(columns={'hash': '链接', 'title': '标题', 'size': '文件大小 (GB)', 'dt': '日期'})
117
  df = df[['标题', '链接', '文件大小 (GB)', '日期']]
118
+ st.toast("搜索完成。", icon="👌")
119
  # 显示结果
120
  st.dataframe(df, hide_index=False, use_container_width=True)
121
 
 
133
  with open(rarbg_config_file, 'w') as configfile:
134
  config.write(configfile)
135
  else:
136
+ st.toast("没有找到记录。", icon="🔔")
137
  else:
138
+ st.toast("请输入一些关键词。", icon="❌")
139
+
140
+
141
+ st.divider()
142
+ st.markdown(f'''##### 广告捐赠
143
+ 😭 接不到广告,我太穷了。请联系我 <span class="tag"><a href="https://t.me/NervosCKB" target="_blank" style="text-decoration: none;"><img src="data:image/svg+xml;base64,{image_to_base64(os.path.join("telegram.svg"))}" alt="Image" width="20px" height="20px" style="border-radius: 3px;" /> @NervosCKB</a></span>,用户搜索总次数:{get_style(searches_value)}。''', unsafe_allow_html=True)
144
+ st.markdown('''##### 温馨提示
145
+ 本站不提供任何包含反动、淫秽、色情、暴力、侮辱、诽谤等不良信息。当你浏览本网站时,请自觉遵守法律法规,对自己的行为承担全部责任。''', unsafe_allow_html=True)
146
+ st.markdown(f'''##### 使用说明
147
+ 请在文本框内输入 {get_style("英文")} 关键词,并点击{get_style("搜索")}按钮进行查询。
148
+ - 若需输入多个关键词,可用 {get_style("空格")} 进行分隔;
149
+ - 若希望某个关键词不在搜索结果中出现,可在关键词前加上 {get_style("-")} 符号。''', unsafe_allow_html=True)