acecalisto3 commited on
Commit
acb1e2e
·
verified ·
1 Parent(s): f5f63d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -13
app.py CHANGED
@@ -11,6 +11,7 @@ import logging
11
  from typing import Optional, Dict, List, Any
12
  from pathlib import Path
13
  from shot_scraper import shotscraper # importing shot-scraper
 
14
 
15
  # set up logging
16
  logging.basicConfig(level=logging.INFO)
@@ -301,22 +302,49 @@ def show_download_links(subdir: str) -> None:
301
  else:
302
  st.write(f"File not found: {file}")
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  def main() -> None:
305
- """main application function."""
306
- st.sidebar.title("infinite dataset hub")
307
- st.sidebar.subheader("available urls")
 
 
308
 
309
- # Add a title to the app
310
- st.title("Music Download App")
 
 
 
 
311
 
312
- for name, url in urls.items():
313
- if st.sidebar.button(name):
314
- st.write(f"downloading content from {url}")
315
- download_html_and_files(url, name.replace(" ", "_"))
316
 
317
- # Initialize history
318
- initialize_history()
 
 
319
 
320
  if __name__ == "__main__":
321
- main()
322
- st.write("debugging: app launched successfully.")
 
11
  from typing import Optional, Dict, List, Any
12
  from pathlib import Path
13
  from shot_scraper import shotscraper # importing shot-scraper
14
+ import feedgenerator # Import RSS feed generator
15
 
16
  # set up logging
17
  logging.basicConfig(level=logging.INFO)
 
302
  else:
303
  st.write(f"File not found: {file}")
304
 
305
+ # Generate RSS feed
306
+ def generate_rss_feed():
307
+ feed = feedgenerator.Rss201rev2Feed(
308
+ title="Infinite Dataset Hub Updates",
309
+ link="https://huggingface.co/spaces/infinite-dataset-hub/infinite-dataset-hub",
310
+ description="Latest updates from the Infinite Dataset Hub",
311
+ language="en"
312
+ )
313
+
314
+ for i, line in enumerate(urls):
315
+ dataset_name = line
316
+ feed.add_item(
317
+ title=dataset_name,
318
+ link=urls[dataset_name],
319
+ description=f"Link to {dataset_name}",
320
+ pubdate=time.gmtime(time.time() - 86400 * i)
321
+ )
322
+
323
+ return feed.writeString('utf-8')
324
+
325
  def main() -> None:
326
+ """main app"""
327
+ st.title("RSS Feed and Content Downloader")
328
+
329
+ # Initialize history
330
+ initialize_history()
331
 
332
+ # RSS Feed Section
333
+ st.header("RSS Feed")
334
+ if st.button("Generate RSS Feed"):
335
+ rss_feed = generate_rss_feed()
336
+ st.success("RSS Feed generated successfully!")
337
+ st.markdown(rss_feed, unsafe_allow_html=True)
338
 
339
+ # Content Downloader Section
340
+ st.header("Content Downloader")
341
+ selected_url = st.selectbox("Select a URL to download content from:", list(urls.keys()))
342
+ subdir = st.text_input("Enter subdirectory name to save files:", "downloads")
343
 
344
+ if st.button("Download Content"):
345
+ download_html_and_files(urls[selected_url], subdir)
346
+ st.success("Content downloaded successfully!")
347
+ show_download_links(subdir)
348
 
349
  if __name__ == "__main__":
350
+ main()