Compare commits

...

2 Commits

Author SHA1 Message Date
0bea8c6e0b new publish
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 6m25s
2025-07-05 10:59:29 +01:00
5b0243ab93 auto complete steam names
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 3m7s
2025-07-05 10:57:19 +01:00
4 changed files with 68 additions and 32 deletions

View File

@ -2,46 +2,44 @@ name: Build and Publish Docker Image
on:
push:
branches: [main]
tags: ['*'] # triggers on any tag push
branches:
- main
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.REGISTRY }}/${{ secrets.USERNAME }}/ktv-ui
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Registry
run: echo "${{ secrets.PASSWORD }}" | docker login ${{ secrets.REGISTRY }} -u "${{ secrets.USERNAME }}" --password-stdin
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
- name: Build and Push Docker Images
run: |
IMAGE_NAME="ktv-ui"
REGISTRY="${{ secrets.REGISTRY }}"
USERNAME="${{ secrets.USERNAME }}"
IMAGE_LATEST="$REGISTRY/$USERNAME/$IMAGE_NAME:latest"
# Always build and tag as latest
echo "🔧 Building $IMAGE_LATEST"
docker build -t $IMAGE_LATEST .
echo "📤 Pushing $IMAGE_LATEST"
docker push $IMAGE_LATEST
# If this is a tag push, tag the image accordingly
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
GIT_TAG="${GITHUB_REF#refs/tags/}"
IMAGE_TAGGED="$REGISTRY/$USERNAME/$IMAGE_NAME:$GIT_TAG"
echo "🏷️ Also tagging as $IMAGE_TAGGED"
docker tag $IMAGE_LATEST $IMAGE_TAGGED
echo "📤 Pushing $IMAGE_TAGGED"
docker push $IMAGE_TAGGED
fi
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

11
app.py
View File

@ -4,7 +4,7 @@ from flask_caching import Cache
import requests.auth
import os
from lib.datetime import filter_accounts_next_30_days, filter_accounts_expired
from lib.reqs import get_urls, get_user_accounts, add_user_account, delete_user_account, get_user_accounts_count
from lib.reqs import get_urls, get_user_accounts, add_user_account, delete_user_account, get_user_accounts_count, get_stream_names
from flask import send_from_directory
import requests
import base64
@ -164,6 +164,15 @@ def delete_account():
return redirect(url_for("user_accounts"))
@app.route("/get_stream_names", methods=["GET"])
def stream_names():
if not session.get("logged_in"):
return redirect(url_for("home"))
base_url = app.config["BASE_URL"]
stream_names = get_stream_names(base_url, session["auth_credentials"])
return jsonify(stream_names)
@app.route('/OCRupload', methods=['POST'])
def OCRupload():
if 'image' not in request.files:

View File

@ -105,3 +105,19 @@ def get_user_accounts_count(base_url: str, auth: str) -> int:
response = requests.request("GET", url, headers=headers, data=payload)
res_json = json.loads(response.text)
return res_json['count']
def get_stream_names(base_url: str, auth: str) -> List[str]:
"""Get a list of stream names from the API.
Args:
base_url (str): The base URL of the API.
auth (str): The authorization token.
Returns:
List[str]: A list of stream names.
"""
url = f"{base_url}/getStreamNames"
headers = {"Authorization": f"Basic {auth}"}
response = requests.get(url, headers=headers)
return json.loads(response.text)

View File

@ -7,6 +7,7 @@
<title>Add Account - KTVManager</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.css" />
<style>
/* Hide the spinner by default */
#loadingSpinner,
@ -90,6 +91,7 @@
<footer class="bg-dark text-white text-center py-3 mt-5">
<p></p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.js"></script>
<script>
function showLoading() {
document.getElementById("submitButton").disabled = true;
@ -101,6 +103,17 @@
document.getElementById("ocrLoadingSpinner").style.display = "inline-block";
document.getElementById("ocrButtonText").textContent = "Processing...";
}
document.addEventListener("DOMContentLoaded", function() {
var streamInput = document.getElementById("stream");
var awesomplete = new Awesomplete(streamInput);
fetch('/get_stream_names')
.then(response => response.json())
.then(data => {
awesomplete.list = data.map(item => item.streamName);
});
});
</script>
</body>
</html>