Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
|
|
| 1 |
import os, json, uuid, hashlib, sqlite3, subprocess, shutil, time, threading, re
|
| 2 |
from datetime import datetime
|
| 3 |
from pathlib import Path
|
| 4 |
from functools import wraps
|
| 5 |
-
from flask import Flask, request,
|
| 6 |
from werkzeug.utils import secure_filename
|
| 7 |
import cv2
|
| 8 |
import numpy as np
|
|
@@ -344,7 +345,7 @@ def get_thumbnail(video_id):
|
|
| 344 |
thumbnail_path = os.path.join(THUMBNAIL_DIR, f"{video_id}.jpg")
|
| 345 |
if os.path.exists(thumbnail_path):
|
| 346 |
return send_file(thumbnail_path, mimetype='image/jpeg')
|
| 347 |
-
return
|
| 348 |
|
| 349 |
@app.route('/api/hls/<video_id>/<path:filename>')
|
| 350 |
def get_hls_segment(video_id, filename):
|
|
@@ -735,7 +736,6 @@ HTML_TEMPLATE = '''
|
|
| 735 |
const response = await fetch('/api/categories');
|
| 736 |
const data = await response.json();
|
| 737 |
const filter = document.getElementById('categoryFilter');
|
| 738 |
-
const allBtn = filter.querySelector('.category-btn');
|
| 739 |
filter.innerHTML = '<button class="category-btn active" data-category="" onclick="filterCategory(\'\')">Все</button>';
|
| 740 |
data.categories.forEach(c => {
|
| 741 |
if (c.name && c.name !== 'other') {
|
|
@@ -866,16 +866,13 @@ HTML_TEMPLATE = '''
|
|
| 866 |
} catch(e) {}
|
| 867 |
}
|
| 868 |
|
| 869 |
-
// Check for video param on load
|
| 870 |
const urlParams = new URLSearchParams(window.location.search);
|
| 871 |
if (urlParams.get('v')) {
|
| 872 |
openPlayer(urlParams.get('v'));
|
| 873 |
}
|
| 874 |
|
| 875 |
-
// Load videos on start
|
| 876 |
loadVideos();
|
| 877 |
|
| 878 |
-
// Close modal on ESC
|
| 879 |
document.addEventListener('keydown', function(e) {
|
| 880 |
if (e.key === 'Escape') closePlayer();
|
| 881 |
});
|
|
@@ -885,4 +882,4 @@ HTML_TEMPLATE = '''
|
|
| 885 |
'''
|
| 886 |
|
| 887 |
if __name__ == '__main__':
|
| 888 |
-
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 1 |
+
# huggingvideo.py - Полный видеохостинг на Hugging Face Spaces
|
| 2 |
import os, json, uuid, hashlib, sqlite3, subprocess, shutil, time, threading, re
|
| 3 |
from datetime import datetime
|
| 4 |
from pathlib import Path
|
| 5 |
from functools import wraps
|
| 6 |
+
from flask import Flask, request, render_template_string, jsonify, send_file, abort, url_for, send_from_directory, stream_with_context, Response, redirect
|
| 7 |
from werkzeug.utils import secure_filename
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
|
|
|
| 345 |
thumbnail_path = os.path.join(THUMBNAIL_DIR, f"{video_id}.jpg")
|
| 346 |
if os.path.exists(thumbnail_path):
|
| 347 |
return send_file(thumbnail_path, mimetype='image/jpeg')
|
| 348 |
+
return '', 404
|
| 349 |
|
| 350 |
@app.route('/api/hls/<video_id>/<path:filename>')
|
| 351 |
def get_hls_segment(video_id, filename):
|
|
|
|
| 736 |
const response = await fetch('/api/categories');
|
| 737 |
const data = await response.json();
|
| 738 |
const filter = document.getElementById('categoryFilter');
|
|
|
|
| 739 |
filter.innerHTML = '<button class="category-btn active" data-category="" onclick="filterCategory(\'\')">Все</button>';
|
| 740 |
data.categories.forEach(c => {
|
| 741 |
if (c.name && c.name !== 'other') {
|
|
|
|
| 866 |
} catch(e) {}
|
| 867 |
}
|
| 868 |
|
|
|
|
| 869 |
const urlParams = new URLSearchParams(window.location.search);
|
| 870 |
if (urlParams.get('v')) {
|
| 871 |
openPlayer(urlParams.get('v'));
|
| 872 |
}
|
| 873 |
|
|
|
|
| 874 |
loadVideos();
|
| 875 |
|
|
|
|
| 876 |
document.addEventListener('keydown', function(e) {
|
| 877 |
if (e.key === 'Escape') closePlayer();
|
| 878 |
});
|
|
|
|
| 882 |
'''
|
| 883 |
|
| 884 |
if __name__ == '__main__':
|
| 885 |
+
app.run(host='0.0.0.0', port=7860, debug=True)
|