Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KorryKatti committed Mar 13, 2024
1 parent f14d3ad commit ee78447
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 64 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
myenv/
instruct.txt
appfiles/data
appfiles/app_data.json
appfiles/app_data.json
data/
89 changes: 36 additions & 53 deletions appfiles/repup.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,51 @@
import requests
from bs4 import BeautifulSoup
import json
import time
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)
def fetch_data(url):
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
app_name = soup.find('h1', {'id': 'appName'}).text.strip()
icon_url = soup.find('h2', {'id': 'iconUrl'}).text.strip()
version = soup.find('h2', {'id': 'version'}).text.strip()
repo_url = soup.find('h2', {'id': 'repoUrl'}).text.strip()
main_file = soup.find('h2', {'id': 'mainFile'}).text.strip()

# 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
application_data = {
'app_name': app_name,
'icon_url': icon_url,
'version': version,
'repo_url': repo_url,
'main_file': main_file
}
return application_data
else:
print(f"Failed to fetch data from {url}. Status code: {response.status_code}")
return None

# Main function
def main():
# Fetch application data from HTML pages
application_data = fetch_all_application_data()
def check_for_updates():
url_base = 'https://korrykatti.github.io/thapps/apps/'
data_folder = '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()
if not os.path.exists(data_folder):
os.makedirs(data_folder)

# 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.")
for i in range(1, 100): # Assuming maximum of 99 files
url = f"{url_base}{i:05d}.html" # Pad number with leading zeros
data = fetch_data(url)
if data:
with open(f"{data_folder}/{i:05d}.json", 'w') as f:
json.dump(data, f, indent=4)
else:
break

def main():
while True:
check_for_updates()
time.sleep(60) # Check for updates every one minute

if __name__ == "__main__":
main()
60 changes: 50 additions & 10 deletions index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import customtkinter as ctk
import subprocess
import os
import json
from PIL import Image

# Set the appearance mode and default color theme
ctk.set_appearance_mode("dark") # Modes: system (default), light, dark
Expand All @@ -7,6 +11,10 @@
def quit(window):
window.destroy()

# Function to launch repup.py in the background
def launch_repup():
subprocess.Popen(["python", "appfiles/repup.py"])

# Create the main application window
app = ctk.CTk()
app.geometry("800x600")
Expand All @@ -32,43 +40,75 @@ 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 = ctk.CTkOptionMenu(frame, values=["Home", "Client Update", "Quit"],
command=optionmenu_callback)
command=optionmenu_callback)
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)
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)
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)
command=devmenu_callback)
devmenu.grid(row=0, column=4, padx=10, pady=0, sticky=ctk.W) # Align to the west (left)


# 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 scrollable frame
label = ctk.CTkLabel(scrollable_frame, text="This is the content frame")
label.pack()
# Function to create labels for each application data
def create_labels():
data_dir = "data"
for filename in os.listdir(data_dir):
if filename.endswith(".json"):
with open(os.path.join(data_dir, filename), "r") as f:
app_data = json.load(f)

# Create a label for the application name
name_label = ctk.CTkLabel(scrollable_frame, text=app_data.get("name", "Unknown"))
name_label.pack()

# Display the application icon
icon_url = app_data.get("icon_url", "")
if icon_url:
# Load the image
icon_image = Image.open(icon_url)

# Create a CTkImage object
ct_image = ctk.CTkImage(light_image=icon_image, dark_image=icon_image, size=(30, 30))

# Create a label to display the image
image_label = ctk.CTkLabel(scrollable_frame, image=ct_image, text="")
image_label.pack()

# Create a button for downloading the application
download_button = ctk.CTkButton(scrollable_frame, text="Download")
download_button.pack()

# Create a separator line
separator = ctk.CTkSeparator(scrollable_frame, orient="horizontal")
separator.pack(fill="x")

# Call the function to create labels
create_labels()

# Start the main event loop
app.mainloop()

# Launch repup.py in the background
launch_repup()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ customtkinter==5.2.2
darkdetect==0.8.0
idna==3.6
packaging==24.0
pillow==10.2.0
requests==2.31.0
soupsieve==2.5
urllib3==2.2.1

0 comments on commit ee78447

Please sign in to comment.