Spaces:
Running
Running
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>HuggingTube</title> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet"> | |
<link href="https://vjs.zencdn.net/8.16.1/video-js.css" rel="stylesheet" /> | |
<style> :root { | |
--bg-primary: #0a0f18; | |
--bg-secondary: #141e2f; | |
--text-primary: #ffffff; | |
--text-secondary: #adbac7; | |
--accent: #2188ff; | |
} | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body { | |
font-family: Arial, sans-serif; | |
background-color: var(--bg-primary); | |
color: var(--text-primary); | |
} | |
header { | |
display: flex; | |
justify-content: space-between; | |
align-items: center; | |
padding: 0.5rem 1rem; | |
background-color: var(--bg-secondary); | |
position: fixed; | |
top: 0; | |
left: 0; | |
right: 0; | |
z-index: 1000; | |
} | |
.logo { | |
color: var(--text-primary); | |
font-size: 1.2rem; | |
font-weight: bold; | |
display: flex; | |
align-items: center; | |
} | |
.logo i { | |
color: var(--accent); | |
margin-right: 0.5rem; | |
} | |
.search-bar { | |
flex-grow: 1; | |
max-width: 600px; | |
margin: 0 1rem; | |
} | |
.search-bar input { | |
width: 100%; | |
padding: 0.5rem 1rem; | |
border-radius: 20px; | |
border: 1px solid var(--text-secondary); | |
background-color: var(--bg-primary); | |
color: var(--text-primary); | |
} | |
.user-actions i { | |
margin-left: 1rem; | |
cursor: pointer; | |
} | |
main { | |
margin-top: 56px; | |
display: flex; | |
padding: 1rem; | |
} | |
.video-container { | |
flex: 1; | |
margin-right: 1rem; | |
} | |
.video-player { | |
position: relative; | |
width: 100%; | |
background-color: black; | |
margin-bottom: 1rem; | |
} | |
.video-player img { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
object-fit: cover; | |
} | |
.video-info { | |
margin-bottom: 1rem; | |
} | |
.video-title { | |
font-size: 1.5rem; | |
margin-bottom: 0.5rem; | |
} | |
.video-stats { | |
display: flex; | |
justify-content: space-between; | |
align-items: center; | |
padding-bottom: 1rem; | |
border-bottom: 1px solid var(--bg-secondary); | |
} | |
.view-count { | |
color: var(--text-secondary); | |
} | |
.video-actions { | |
display: flex; | |
gap: 1rem; | |
} | |
.action-button { | |
display: flex; | |
align-items: center; | |
gap: 0.5rem; | |
background: none; | |
border: none; | |
color: var(--text-primary); | |
cursor: pointer; | |
} | |
.channel-info { | |
display: flex; | |
align-items: center; | |
padding-bottom: 1rem; | |
border-bottom: 1px solid var(--bg-secondary); | |
} | |
.channel-avatar { | |
width: 48px; | |
height: 48px; | |
border-radius: 50%; | |
background-color: var(--bg-secondary); | |
margin-right: 1rem; | |
} | |
.channel-details { | |
display: grid; | |
align-items: center; | |
} | |
.channel-name { | |
font-weight: bold; | |
} | |
.subscriber-count { | |
color: var(--text-secondary); | |
font-size: 0.9rem; | |
margin-bottom: 0.5rem; | |
} | |
.subscribe-button { | |
background-color: var(--accent); | |
color: var(--text-primary); | |
border: none; | |
padding: 0.5rem 1rem; | |
border-radius: 20px; | |
cursor: pointer; | |
font-weight: bold; | |
} | |
.video-description { | |
margin-top: 1rem; | |
color: var(--text-secondary); | |
white-space: pre-line; | |
} | |
.recommendations { | |
width: 400px; | |
} | |
.recommendation { | |
display: flex; | |
margin-bottom: 0.5rem; | |
cursor: pointer; | |
} | |
.recommendation-thumbnail { | |
width: 160px; | |
height: 90px; | |
background-color: var(--bg-secondary); | |
margin-right: 0.5rem; | |
flex-shrink: 0; | |
} | |
.recommendation-info h3 { | |
font-size: 0.9rem; | |
margin-bottom: 0.25rem; | |
} | |
.recommendation-info p { | |
font-size: 0.8rem; | |
color: var(--text-secondary); | |
} | |
.comments-section { | |
margin-top: 1rem; | |
} | |
.comments-header { | |
display: flex; | |
align-items: center; | |
margin-bottom: 1rem; | |
} | |
.comment-count { | |
margin-right: 1rem; | |
} | |
.sort-button { | |
display: flex; | |
align-items: center; | |
background: none; | |
border: none; | |
color: var(--text-primary); | |
cursor: pointer; | |
} | |
.comment { | |
display: flex; | |
margin-bottom: 1rem; | |
} | |
.comment-avatar { | |
width: 40px; | |
height: 40px; | |
border-radius: 50%; | |
background-color: var(--bg-secondary); | |
margin-right: 1rem; | |
} | |
.comment-content { | |
flex: 1; | |
} | |
.comment-header { | |
display: flex; | |
align-items: center; | |
margin-bottom: 0.25rem; | |
} | |
.comment-author { | |
font-weight: bold; | |
margin-right: 0.5rem; | |
} | |
.comment-timestamp { | |
color: var(--text-secondary); | |
font-size: 0.9rem; | |
} | |
@media (max-width: 1200px) { | |
.recommendations { | |
width: 300px; | |
} | |
} | |
@media (max-width: 1000px) { | |
main { | |
flex-direction: column; | |
} | |
.video-container { | |
margin-right: 0; | |
margin-bottom: 1rem; | |
} | |
.recommendations { | |
width: 100%; | |
} | |
.recommendation { | |
width: 100%; | |
} | |
} | |
@media (max-width: 768px) { | |
.logo span { | |
display: none; | |
} | |
.user-actions { | |
display: none; | |
} | |
.video-stats { | |
flex-direction: column; | |
align-items: flex-start; | |
} | |
.video-actions { | |
margin-top: 0.5rem; | |
} | |
.recommendation-thumbnail { | |
width: 120px; | |
height: 68px; | |
} | |
}</style> | |
</head> | |
<body> | |
<header> | |
<div class="logo"> | |
<i class="fab fa-youtube"></i> | |
<a href="index.html" style="color: white; text-decoration: none;">HuggingTube</a> | |
</div> | |
<div class="search-bar"> | |
<input type="text" placeholder="Search"> | |
</div> | |
<div class="user-actions"> | |
<i class="fas fa-video"></i> | |
<i class="fas fa-bell"></i> | |
<i class="fas fa-user-circle"></i> | |
</div> | |
</header> | |
<main> | |
<div class="video-container"> | |
<video | |
id="my-video" | |
class="video-js" | |
controls | |
preload="auto" | |
width="640" | |
height="264" | |
data-setup="{}" | |
> | |
<track src="output.vtt" kind="subtitles" srclang="en" label="English" default> | |
<source id="video-troll" src="" type="video/mp4" /> | |
<p class="vjs-no-js"> | |
To view this video please enable JavaScript, and consider upgrading to a | |
web browser that | |
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a> | |
</p> | |
</video> | |
</div> | |
<div class="video-info"> | |
<h1 class="video-title" id="video-title">Loading...</h1> | |
<div class="video-stats"> | |
<span class="view-count" id="view-count">Loading...</span> | |
<div class="video-actions"> | |
<button class="action-button"> | |
<i class="fas fa-share"></i> Share | |
</button> | |
<button class="action-button" id="download-button"> | |
<i class="fas fa-download"></i> Download | |
</button> | |
</div> | |
</div> | |
</div> | |
<div class="channel-info"> | |
<div class="channel-avatar"></div> | |
<div class="channel-details"> | |
<span class="channel-name" id="channel-name">Loading...</span> | |
</div> | |
</div> | |
<div class="video-description" id="video-description"> | |
Loading description... | |
</div> | |
</main> | |
<script src="https://vjs.zencdn.net/8.16.1/video.min.js"></script> | |
<script> | |
document.addEventListener("DOMContentLoaded", function () { | |
const jsonUrl = localStorage.getItem("video_to_watch"); | |
if (jsonUrl) { | |
fetch(jsonUrl) | |
.then(response => { | |
if (!response.ok) { | |
throw new Error(`HTTP error! status: ${response.status}`); | |
} | |
return response.json(); | |
}) | |
.then(data => { | |
document.getElementById("video-title").innerText = data.title; | |
const date = new Date(data.uploadTimestamp); | |
document.getElementById("view-count").innerText = `Uploaded on ${date.toLocaleString('en-US', { month: 'long' })} ${date.getDate()}, ${date.getFullYear()} at ${date.toLocaleTimeString()}`; | |
document.getElementById("channel-name").innerText = data.uploader; | |
document.getElementById("video-description").innerText = data.description; | |
document.title = data.title + " - HuggingTube"; | |
const baseUrl = 'https://huggingface.co/spaces/vericudebuget/ok4231/resolve/main/'; | |
const videoElement = document.getElementById("video-troll"); | |
if (videoElement) { | |
const fileLocation = data.fileLocation.split('/').pop(); | |
const videoUrl = `${baseUrl}videos/${encodeURIComponent(fileLocation)}?download=true`; | |
// Determine the file extension and set the type accordingly | |
const fileExtension = fileLocation.split('.').pop().toLowerCase(); | |
let videoType = ''; | |
switch (fileExtension) { | |
case 'mp4': | |
videoType = 'video/mp4'; | |
break; | |
case 'webm': | |
videoType = 'video/webm'; | |
break; | |
case 'ogg': | |
videoType = 'video/ogg'; | |
break; | |
default: | |
console.error("Unsupported video format:", fileExtension); | |
return; // Exit if the format is unsupported | |
} | |
console.log("Video URL:", videoUrl); | |
console.log("Video Type:", videoType); | |
// Set the source using an object | |
videoElement.src = videoUrl; | |
videoElement.setAttribute('type', videoType); | |
videoElement.load(); // Ensure the video element reloads the new source | |
} | |
}) | |
.catch(error => { | |
console.error("Error fetching or parsing the JSON data:", error); | |
}); | |
} else { | |
console.error("No JSON file link found in localStorage"); | |
} | |
document.getElementById("download-button").addEventListener("click", function() { | |
const videoElement = document.getElementById("video-troll"); | |
const videoUrl = videoElement.src; | |
const fileName = videoUrl.split('/').pop().split('?')[0]; | |
// Create a link element dynamically | |
const link = document.createElement('a'); | |
link.href = videoUrl; | |
link.setAttribute('download', fileName); | |
link.style.display = 'none'; | |
// Add the link to the DOM and simulate a click | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); // Remove the link after click | |
}); | |
}); | |
</script> | |
</body> | |
</html> | |