Compare commits
2 Commits
mp860cx-#2
...
main
Author | SHA1 | Date | |
---|---|---|---|
25e0b9a0c8 | |||
b08c47476d |
@ -53,6 +53,7 @@ async function fetchVideoUrl(word) {
|
||||
return data.video_url;
|
||||
}
|
||||
|
||||
|
||||
// Function to load video sequence by words using Supabase
|
||||
async function loadVideoSequenceByWords() {
|
||||
const words = inputText.value.trim().split(' ');
|
||||
@ -103,29 +104,6 @@ async function loadVideoSequenceByLetters() {
|
||||
currentIndex = 0;
|
||||
}
|
||||
|
||||
// Function to highlight the current word or letter in the textarea
|
||||
function highlightCurrentText(index) {
|
||||
let wordsOrLetters = currentTranslationMode === 'words' ? inputText.value.trim().split(' ') : inputText.value.trim().split('');
|
||||
|
||||
// Reset the highlighted text in the textarea
|
||||
inputText.value = '';
|
||||
inputText.setSelectionRange(0, 0);
|
||||
|
||||
let startIndex = 0;
|
||||
wordsOrLetters.forEach((item, i) => {
|
||||
if (i < index) {
|
||||
startIndex += item.length + (currentTranslationMode === 'words' ? 1 : 0);
|
||||
}
|
||||
});
|
||||
|
||||
let endIndex = startIndex + wordsOrLetters[index].length;
|
||||
inputText.value = wordsOrLetters.join(currentTranslationMode === 'words' ? ' ' : '');
|
||||
|
||||
// Highlight the current word or letter
|
||||
inputText.setSelectionRange(startIndex, endIndex);
|
||||
inputText.focus();
|
||||
}
|
||||
|
||||
// Function to play video at a specific index
|
||||
function playVideoAtIndex(index) {
|
||||
if (index < 0 || index >= videoSequence.length) return;
|
||||
@ -134,9 +112,6 @@ function playVideoAtIndex(index) {
|
||||
videoPlayer.play();
|
||||
currentIndex = index;
|
||||
|
||||
// Highlight the current word or letter
|
||||
highlightCurrentText(currentIndex);
|
||||
|
||||
// Update the title with the current word or letter
|
||||
const currentLabel = videoSequence[index].split('/').pop().split('.')[0];
|
||||
document.getElementById('currentLetter').innerText = currentLabel.toUpperCase();
|
||||
@ -219,4 +194,4 @@ inputText.addEventListener('input', () => {
|
||||
} else {
|
||||
translateBtn.disabled = true; // Disable the translate button if the text is empty
|
||||
}
|
||||
});
|
||||
});
|
34
storage_to_db.py
Normal file
34
storage_to_db.py
Normal file
@ -0,0 +1,34 @@
|
||||
from supabase import create_client, Client
|
||||
|
||||
# RLS policy permissions required:
|
||||
# buckets table permissions: select
|
||||
# objects table permissions: none
|
||||
|
||||
url: str = ""
|
||||
key: str = ""
|
||||
supabase: Client = create_client(url, key)
|
||||
|
||||
|
||||
# List all objects in the 'video' bucket
|
||||
# .from("bucket_name")
|
||||
# .list("folder_name")
|
||||
response = supabase.storage.from_("video").list("",{"limit": 1000})
|
||||
|
||||
|
||||
for video in response:
|
||||
video_name = video['name'].replace('.mp4', '')
|
||||
video_url = f"{url}/storage/v1/object/public/video/{video_name}.mp4"
|
||||
|
||||
# print the video name and url with tabs
|
||||
print(video_name, video_url, sep="\t")
|
||||
|
||||
response = (
|
||||
# .table("table_name")
|
||||
# .insert({"column_name": value})
|
||||
# .execute SQL query
|
||||
supabase.table("Videa")
|
||||
.insert({"label": video_name, "video_url": video_url})
|
||||
.execute()
|
||||
)
|
||||
# print(response)
|
||||
|
@ -153,13 +153,6 @@ h1 {
|
||||
background-color: #357ae8;
|
||||
}
|
||||
|
||||
/* Zvýraznenie pre aktuálne slovo/písmeno */
|
||||
.highlight {
|
||||
background-color: #ffeb3b; /* Svetložltá farba na zvýraznenie */
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.video {
|
||||
position: relative;
|
||||
width: 45%;
|
||||
|
Loading…
Reference in New Issue
Block a user