Skip to content

Commit

Permalink
file data fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
KorryKatti committed Mar 13, 2024
1 parent a6883f7 commit f14d3ad
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
myenv/
instruct.txt
instruct.txt
appfiles/data
appfiles/app_data.json
68 changes: 68 additions & 0 deletions appfiles/repup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import requests
from bs4 import BeautifulSoup
import json
import os

# Define the URL pattern for the HTML pages
url_pattern = "https://korrykatti.github.io/thapps/apps/{:05d}.html"

# Function to fetch application data from HTML pages
def fetch_application_data(num):
url = url_pattern.format(num)
response = requests.get(url)
print(f"Fetching data from {url}. Status code: {response.status_code}")
if response.status_code == 200:
soup = BeautifulSoup(response.content, 'html.parser')
app_name = soup.find('h1', {'id': 'appName'})
icon_url = soup.find('h2', {'id': 'iconUrl'})
version = soup.find('h2', {'id': 'version'})
repo_url = soup.find('h2', {'id': 'repoUrl'})
main_file = soup.find('h2', {'id': 'mainFile'})
if all((app_name, icon_url, version, repo_url, main_file)):
return {
'app_name': app_name.text.strip(),
'icon_url': icon_url.text.strip(),
'version': version.text.strip(),
'repo_url': repo_url.text.strip(),
'main_file': main_file.text.strip()
}
return None

# Fetch application data for all HTML pages
def fetch_all_application_data():
app_data = {}
num = 1
while True:
data = fetch_application_data(num)
if data is None:
break
app_data[num] = data
num += 1
return app_data

# Main function
def main():
# Fetch application data from HTML pages
application_data = fetch_all_application_data()

# Print the fetched data
for num, data in application_data.items():
print(f"Application {num}:")
print(f"Name: {data['app_name']}")
print(f"Icon URL: {data['icon_url']}")
print(f"Version: {data['version']}")
print(f"Repo URL: {data['repo_url']}")
print(f"Main File: {data['main_file']}")
print()

# Save application data to a file
file_path = os.path.join(os.path.dirname(__file__), 'app_data.json')
if application_data:
with open(file_path, 'w') as f:
json.dump(application_data, f, indent=4)
print("Application data saved to app_data.json")
else:
print("No application data fetched. No JSON file created.")

if __name__ == "__main__":
main()
69 changes: 54 additions & 15 deletions index.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,73 @@
import customtkinter
import customtkinter as ctk

# Set the appearance mode and default color theme
customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark
customtkinter.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green
ctk.set_appearance_mode("dark") # Modes: system (default), light, dark
ctk.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green

def quit(window):
window.destroy()

# Create the main application window
app = customtkinter.CTk()
app.geometry("400x240")
app = ctk.CTk()
app.geometry("800x600")
app.resizable(True, True)
app.title("Thunder 🗲")

#functions for optionmenu
def quit(window):
window.destroy()

# Create a frame inside the main window for organizing widgets
frame = ctk.CTkFrame(app)
frame.pack(fill=ctk.BOTH, expand=True, padx=20, pady=20) # Pack the frame to fill the window

# Define the callback function for the optionmenu
def optionmenu_callback(choice):
print("Optionmenu dropdown clicked:", choice)
if choice == "Quit":
quit(app)

# Create a frame inside the main window for organizing widgets
frame = customtkinter.CTkFrame(app)
frame.pack(fill=customtkinter.BOTH, expand=True, padx=20, pady=20) # Pack the frame to fill the window
# Callback Function for Libmenu
def libmenu_callback():
pass

# CallBack function for commenu

def commenu_callback():
pass

# CallBack function for devmenu

def devmenu_callback():
pass

# Create the optionmenu widget
optionmenu = customtkinter.CTkOptionMenu(frame, values=["Home", "Check For Updates", "Quit"],
optionmenu = ctk.CTkOptionMenu(frame, values=["Home", "Client Update", "Quit"],
command=optionmenu_callback)
optionmenu.grid(row=0, column=2, padx=10, pady=10, sticky=customtkinter.W) # Align to the west (left)
optionmenu.grid(row=0, column=1, padx=10, pady=0, sticky=ctk.W) # Align to the west (left)

# Create the library menu widget
libmenu = ctk.CTkOptionMenu(frame, values=["Library", "Apps Update"],
command=libmenu_callback)
libmenu.grid(row=0, column=2, padx=10, pady=0, sticky=ctk.W) # Align to the west (left)

# Create the Commmunity Widget
commenu = ctk.CTkOptionMenu(frame, values=["Community", "Image Board", "Thunder Halls"],
command=commenu_callback)
commenu.grid(row=0, column=3, padx=10, pady=0, sticky=ctk.W) # Align to the west (left)

# Create DevBlogs Widget
devmenu = ctk.CTkOptionMenu(frame,values=["Dev Blog", "Changelogs"],
command=devmenu_callback)
devmenu.grid(row=0, column=4, padx=10, pady=0, sticky=ctk.W) # Align to the west (left)


# Create a new frame inside the existing frame to display contents
content_frame = customtkinter.CTkFrame(frame)
content_frame.grid(row=1, column=0, columnspan=3, padx=10, pady=10, sticky="nsew") # Span across all columns, fill horizontally
# Create a scrollable frame inside the existing frame to display contents
scrollable_frame = ctk.CTkScrollableFrame(frame, width=750, height=750, corner_radius=0, fg_color="transparent")
scrollable_frame.grid(row=3, column=0, columnspan=33, sticky="nsew")

# Add widgets to the content frame
label = customtkinter.CTkLabel(content_frame, text="This is the content frame")
# Add widgets to the scrollable frame
label = ctk.CTkLabel(scrollable_frame, text="This is the content frame")
label.pack()

# Start the main event loop
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def compare_versions():
label.pack(pady=20)

# Close the window after 7 seconds
app.after(7000, close_window, app)
app.after(3000, close_window, app)

app.mainloop()

Expand Down

0 comments on commit f14d3ad

Please sign in to comment.