Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
import requests
|
| 3 |
-
import
|
| 4 |
-
from googleapiclient.discovery import build
|
| 5 |
from bs4 import BeautifulSoup
|
|
|
|
|
|
|
|
|
|
| 6 |
from openai import OpenAI
|
| 7 |
|
| 8 |
# Function to fetch all videos from a YouTube playlist
|
|
@@ -95,6 +96,19 @@ def set_bg_hack(main_bg_url, logo_url):
|
|
| 95 |
def get_restricted_video_link(video_id):
|
| 96 |
return f"https://www.youtube.com/embed/{video_id}?autoplay=1"
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
# Function to scrape live football scores from a website
|
| 99 |
def scrape_live_scores():
|
| 100 |
URL = "https://www.goal.com/en-tza/live-scores"
|
|
@@ -143,14 +157,14 @@ def main():
|
|
| 143 |
# Set background image and logo
|
| 144 |
set_bg_hack("https://huggingface.co/spaces/Nkuku/FVGC/blob/main/cover.png", "https://huggingface.co/spaces/Nkuku/FVGC/blob/main/logo.jpg")
|
| 145 |
|
| 146 |
-
st.title("
|
| 147 |
|
| 148 |
# Create a search input for users to search for a specific match
|
| 149 |
search_input = st.text_input("Search for a match (e.g., Man City vs Arsenal):")
|
| 150 |
|
| 151 |
# Create horizontal menu
|
| 152 |
st.markdown("<div class='logo'></div>", unsafe_allow_html=True)
|
| 153 |
-
st.markdown("<ul class='menu'><li><a href='#' onclick='
|
| 154 |
|
| 155 |
# Dictionary containing channel IDs and their corresponding playlist IDs
|
| 156 |
channel_playlist_ids = {
|
|
@@ -201,51 +215,49 @@ def main():
|
|
| 201 |
# Handle adding/uploading videos
|
| 202 |
handle_video_upload()
|
| 203 |
|
| 204 |
-
# JavaScript function
|
| 205 |
st.markdown(
|
| 206 |
"""
|
| 207 |
<script>
|
| 208 |
-
function
|
| 209 |
const appElement = document.querySelector('.stApp');
|
| 210 |
appElement.innerHTML = ''; // Clear app content
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
const
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
// Add logic to display latest videos fetched from YouTube
|
| 217 |
-
// Example:
|
| 218 |
-
const videoContainer = document.createElement('div');
|
| 219 |
-
videoContainer.setAttribute('id', 'videoContainer');
|
| 220 |
-
appElement.appendChild(videoContainer);
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
appElement.appendChild(uploadedVideosHeader);
|
| 227 |
|
| 228 |
-
const
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
}
|
| 232 |
</script>
|
| 233 |
""",
|
| 234 |
unsafe_allow_html=True
|
| 235 |
)
|
| 236 |
|
| 237 |
-
# Function to handle video upload
|
| 238 |
-
def handle_video_upload():
|
| 239 |
-
st.subheader("Upload Video")
|
| 240 |
-
uploaded_file = st.file_uploader("Choose a video file", type=["mp4", "avi"])
|
| 241 |
-
|
| 242 |
-
if uploaded_file is not None:
|
| 243 |
-
st.write(f"Video '{uploaded_file.name}' uploaded successfully!")
|
| 244 |
-
# You can save the uploaded file or its information as needed
|
| 245 |
-
|
| 246 |
-
# Display the uploaded video link on the home page
|
| 247 |
-
uploaded_video_item = f"<li><a href='#'>{uploaded_file.name}</a></li>"
|
| 248 |
-
st.markdown(f"<script>document.getElementById('uploadedVideoList').innerHTML += `{uploaded_video_item}`;</script>", unsafe_allow_html=True)
|
| 249 |
-
|
| 250 |
if __name__ == "__main__":
|
| 251 |
main()
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
+
import streamlit as st
|
|
|
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
+
from googleapiclient.discovery import build
|
| 5 |
+
import base64
|
| 6 |
+
from datetime import datetime, timedelta
|
| 7 |
from openai import OpenAI
|
| 8 |
|
| 9 |
# Function to fetch all videos from a YouTube playlist
|
|
|
|
| 96 |
def get_restricted_video_link(video_id):
|
| 97 |
return f"https://www.youtube.com/embed/{video_id}?autoplay=1"
|
| 98 |
|
| 99 |
+
# Function to handle adding/uploading videos
|
| 100 |
+
def handle_video_upload():
|
| 101 |
+
st.subheader("Add and Upload Videos")
|
| 102 |
+
st.write("Use this interface to add and upload videos.")
|
| 103 |
+
|
| 104 |
+
video_title = st.text_input("Video Title")
|
| 105 |
+
video_url = st.text_input("YouTube Video URL")
|
| 106 |
+
|
| 107 |
+
if st.button("Upload Video"):
|
| 108 |
+
if video_title and video_url:
|
| 109 |
+
st.write(f"Video '{video_title}' added successfully! Video URL: {video_url}")
|
| 110 |
+
# Here you could add logic to store the video information, e.g., in a database or file
|
| 111 |
+
|
| 112 |
# Function to scrape live football scores from a website
|
| 113 |
def scrape_live_scores():
|
| 114 |
URL = "https://www.goal.com/en-tza/live-scores"
|
|
|
|
| 157 |
# Set background image and logo
|
| 158 |
set_bg_hack("https://huggingface.co/spaces/Nkuku/FVGC/blob/main/cover.png", "https://huggingface.co/spaces/Nkuku/FVGC/blob/main/logo.jpg")
|
| 159 |
|
| 160 |
+
st.title("Wellcome To Football Videos goals clips Channels")
|
| 161 |
|
| 162 |
# Create a search input for users to search for a specific match
|
| 163 |
search_input = st.text_input("Search for a match (e.g., Man City vs Arsenal):")
|
| 164 |
|
| 165 |
# Create horizontal menu
|
| 166 |
st.markdown("<div class='logo'></div>", unsafe_allow_html=True)
|
| 167 |
+
st.markdown("<ul class='menu'><li><a href='#' onclick='handleHomeClick()'>Home</a></li><li>About</li><li>Videos</li><li><a href='https://www.fotmob.com/'>Matches</a></li><li><a href='https://www.fotmob.com/'>Live Games</a></li><li><a href='https://t.me/skysports_goals'>Popular</a></li></ul>", unsafe_allow_html=True)
|
| 168 |
|
| 169 |
# Dictionary containing channel IDs and their corresponding playlist IDs
|
| 170 |
channel_playlist_ids = {
|
|
|
|
| 215 |
# Handle adding/uploading videos
|
| 216 |
handle_video_upload()
|
| 217 |
|
| 218 |
+
# Handle JavaScript function for clicking "Home"
|
| 219 |
st.markdown(
|
| 220 |
"""
|
| 221 |
<script>
|
| 222 |
+
function handleHomeClick() {
|
| 223 |
const appElement = document.querySelector('.stApp');
|
| 224 |
appElement.innerHTML = ''; // Clear app content
|
| 225 |
+
const addVideoTitle = document.createElement('h2');
|
| 226 |
+
addVideoTitle.textContent = 'Add and Upload Videos';
|
| 227 |
+
appElement.appendChild(addVideoTitle);
|
| 228 |
|
| 229 |
+
const videoTitleInput = document.createElement('input');
|
| 230 |
+
videoTitleInput.setAttribute('type', 'text');
|
| 231 |
+
videoTitleInput.setAttribute('placeholder', 'Video Title');
|
| 232 |
+
appElement.appendChild(videoTitleInput);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
|
| 234 |
+
const videoUrlInput = document.createElement('input');
|
| 235 |
+
videoUrlInput.setAttribute('type', 'text');
|
| 236 |
+
videoUrlInput.setAttribute('placeholder', 'YouTube Video URL');
|
| 237 |
+
appElement.appendChild(videoUrlInput);
|
|
|
|
| 238 |
|
| 239 |
+
const uploadButton = document.createElement('button');
|
| 240 |
+
uploadButton.textContent = 'Upload Video';
|
| 241 |
+
uploadButton.addEventListener('click', () => {
|
| 242 |
+
const videoTitle = videoTitleInput.value;
|
| 243 |
+
const videoUrl = videoUrlInput.value;
|
| 244 |
+
if (videoTitle && videoUrl) {
|
| 245 |
+
const uploadedMessage = document.createElement('p');
|
| 246 |
+
uploadedMessage.textContent = `Video '${videoTitle}' added successfully! Video URL: ${videoUrl}`;
|
| 247 |
+
appElement.appendChild(uploadedMessage);
|
| 248 |
+
} else {
|
| 249 |
+
const errorAlert = document.createElement('p');
|
| 250 |
+
errorAlert.textContent = 'Please provide both video title and YouTube video URL.';
|
| 251 |
+
errorAlert.style.color = 'red';
|
| 252 |
+
appElement.appendChild(errorAlert);
|
| 253 |
+
}
|
| 254 |
+
});
|
| 255 |
+
appElement.appendChild(uploadButton);
|
| 256 |
}
|
| 257 |
</script>
|
| 258 |
""",
|
| 259 |
unsafe_allow_html=True
|
| 260 |
)
|
| 261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
if __name__ == "__main__":
|
| 263 |
main()
|