idle,
@idle@158436977.xyz avatar

Keep in mind they are hacked together and were not meant for mass consumption. Here is an example of one of the scripts that contacts the gitea api and inserts the most recent 10 issues into Flames database with a specific category.

`import sqlite3 from datetime import datetime import requests import re import json from datetime import datetime, timezone

def insert_bookmark(name, url, category_id, order_id): conn = sqlite3.connect(‘/app/db.sqlite’) cursor = conn.cursor()

<pre style="background-color:#ffffff;">
<span style="color:#323232;">cursor.execute("SELECT MAX(id) FROM bookmarks")
</span><span style="color:#323232;">result = cursor.fetchone()
</span><span style="color:#323232;">max_id = result[0] if result[0] else 0
</span><span style="color:#323232;">
</span><span style="color:#323232;">current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f %z')
</span><span style="color:#323232;">values = (name, url, category_id, "", current_time, current_time, 0, order_id)
</span><span style="color:#323232;">
</span><span style="color:#323232;">cursor.execute("INSERT INTO bookmarks (name, url, categoryId, icon, createdAt, updatedAt, isPublic, orderId) VALUES (?, ?, ?, ?, ?, ?, ?, ?);", values)
</span><span style="color:#323232;">
</span><span style="color:#323232;">max_id += 1
</span><span style="color:#323232;">
</span><span style="color:#323232;">conn.commit()
</span><span style="color:#323232;">conn.close()
</span><span style="color:#323232;">
</span><span style="color:#323232;">return max_id
</span>

def delete_bookmark(category_id): conn = sqlite3.connect(‘/app/db.sqlite’) cursor = conn.cursor() cursor.execute(“DELETE FROM bookmarks WHERE categoryId = ?”, (category_id,)) # Commit the changes and close the connection conn.commit() conn.close()

def get_recently_updated_issues(repo_urls, user_name, api_token): headers = { “Authorization”: f"token {api_token}“, “Content-Type”: “application/json” }

<pre style="background-color:#ffffff;">
<span style="color:#323232;">all_issues = []
</span><span style="color:#323232;">
</span><span style="color:#323232;">for repo_url, repo_name in repo_urls:
</span><span style="color:#323232;">    api_url = repo_url
</span><span style="color:#323232;">
</span><span style="color:#323232;">    # Query the Gitea API to get the issues
</span><span style="color:#323232;">    response = requests.get(api_url, headers=headers, params={"state": "all"})
</span><span style="color:#323232;">    response.raise_for_status()
</span><span style="color:#323232;">
</span><span style="color:#323232;">    issues = response.json()
</span><span style="color:#323232;">
</span><span style="color:#323232;">    sorted_issues = sorted(issues, key=lambda x: x["updated_at"], reverse=True)
</span><span style="color:#323232;">
</span><span style="color:#323232;">    all_issues.extend(sorted_issues[:5])
</span><span style="color:#323232;">
</span><span style="color:#323232;">sorted_all_issues = sorted(all_issues, key=lambda x: x["updated_at"], reverse=True)
</span><span style="color:#323232;">
</span><span style="color:#323232;">recent_issue_titles = []
</span><span style="color:#323232;">recent_issue_links = []
</span><span style="color:#323232;">recent_timestamps = []
</span><span style="color:#323232;">
</span><span style="color:#323232;">for issue in sorted_all_issues[:10]:
</span><span style="color:#323232;">    title = issue["title"]
</span><span style="color:#323232;">    link = issue["html_url"]
</span><span style="color:#323232;">    timestamp = issue["updated_at"]
</span><span style="color:#323232;">
</span><span style="color:#323232;">    recent_issue_titles.append(title)
</span><span style="color:#323232;">    recent_issue_links.append(link)
</span><span style="color:#323232;">    recent_timestamps.append(timestamp)
</span><span style="color:#323232;">
</span><span style="color:#323232;">return recent_issue_titles, recent_issue_links, recent_timestamps
</span>

repo_urls = [ (”gitea.example.com/api/v1/repos/user1/…/issues“, “repo1”), (”gitea.example.com/api/v1/repos/user1/…/issues", “repo2”) ] user_name = “user1” api_token = “example token”

delete_bookmark(8) order_id = 1

recent_issue_titles, recent_issue_links, recent_timestamps = get_recently_updated_issues(repo_urls, user_name, api_token)

for title, link, timestamp in zip(recent_issue_titles, recent_issue_links, recent_timestamps): print(“Issue Title:”, title) print(“Issue Link:”, link) print(“Last Updated:”, timestamp) print() bookmark_id = insert_bookmark(title, link, 8, order_id) order_id += 1`

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • wartaberita
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • TheResearchGuardian
  • Ask_kbincafe
  • KbinCafe
  • Testmaggi
  • Socialism
  • feritale
  • oklahoma
  • SuperSentai
  • KamenRider
  • All magazines