-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (57 loc) · 2.37 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import tkinter as tk
import requests
import json
import urllib.parse
import webbrowser
results = []
def searchstore(query):
request = requests.get("https://storeedgefd.dsx.mp.microsoft.com/v9.0/pages/searchResults?market=US&locale=en-US&deviceFamily=windows.desktop&query=" + urllib.parse.quote(query))
response = request.text
json_response = json.loads(response)
searchresults = []
for i in json_response[1]["Payload"]["SearchResults"]:
searchresults.append({"id": i["ProductId"], "title": i["Title"]})
return searchresults
def search():
query = entry.get()
print(f"Searching for: {query}")
results = searchstore(query)
results_listbox.delete(0, tk.END)
for result in results:
results_listbox.insert(tk.END, result["title"] + " - ID=" + result["id"])
root = tk.Tk()
root.title("AltMSStore")
frame = tk.Frame(root)
frame.pack(pady=10)
entry = tk.Entry(frame, width=50)
entry.pack(side=tk.LEFT, padx=10)
search_button = tk.Button(frame, text="Search", command=search)
search_button.pack(side=tk.LEFT)
# results
results_frame = tk.Frame(root)
results_frame.pack(pady=10)
results_listbox = tk.Listbox(results_frame, width=100, height=20)
results_listbox.pack(side=tk.LEFT, fill=tk.BOTH)
scrollbar = tk.Scrollbar(results_frame)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
results_listbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=results_listbox.yview)
button_frame = tk.Frame(root)
button_frame.pack(pady=10)
def install_selected_item():
selected_index = results_listbox.curselection()
if selected_index:
selected_item = results_listbox.get(selected_index)
item_id = selected_item.split(" - ID=")[-1]
print(f"Installing item with ID: {item_id}")
def details_selected():
selected_index = results_listbox.curselection()
if selected_index:
selected_item = results_listbox.get(selected_index)
item_id = selected_item.split(" - ID=")[-1]
webbrowser.open("https://apps.microsoft.com/detail/" + item_id)
install_button = tk.Button(button_frame, text="Donwload", command=install_selected_item, background="#00FF00", font="Serif", activebackground="#00FF00", activeforeground="#00FF00", width=50)
install_button.pack(side=tk.LEFT, padx=5)
details_button = tk.Button(button_frame, text="Details", command=details_selected)
details_button.pack(side=tk.LEFT, padx=5)
root.mainloop()