Eine kleine Spielerei mit Pyhton (bin darin noch etwas ungbegabt), falls jemand bock hat kann er den Code gerne erweitern oder nutzen.
Derzeit kann diese Spielerei nur Themen-Links verkürzen und besitzt einen "Kürzen" und "Kopieren" Button.
Welche tadellos funktionieren.
Code: Forumsshortner
import tkinter as tk
import re
def shorten_link(long_link):
# Search
match = re.search(r"index\.php\?thread/(\d+)", long_link)
# Short
if match:
thread_id = match.group(1)
short_link = f"horst.to/t/{thread_id}"
return short_link
# Falsereturn
else:
return long_link
def on_button_click():
long_link = entry.get()
window.clipboard_clear()
short_link = shorten_link(long_link)
label_short_link.config(text=short_link)
window.clipboard_append(short_link)
def copy_link():
window.clipboard_clear()
short_link = label_short_link.cget("text")
window.clipboard_append(short_link)
window = tk.Tk()
window.title("Forumshilfe V 0.01")
window.geometry("400x150")
entry = tk.Entry(window)
entry.pack(padx=10, pady=10)
button_kürzen = tk.Button(window, text="Kürzen", command=on_button_click)
button_kürzen.pack(side=tk.LEFT, padx=10)
button_kopieren = tk.Button(window, text="Kopieren", command=copy_link)
button_kopieren.pack(side=tk.LEFT, padx=10)
label_short_link = tk.Label(window, text="")
label_short_link.pack(padx=10, pady=10)
# GUI start
window.mainloop()
Alles anzeigen