Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from flask import render_template
|
|
3 |
import sqlite3
|
4 |
import os
|
5 |
import uuid
|
6 |
-
|
7 |
import json
|
8 |
import base64
|
9 |
import unittest
|
@@ -77,34 +77,7 @@ def up_fa():
|
|
77 |
|
78 |
|
79 |
|
80 |
-
def get_video_url(video_url):
|
81 |
-
ydl_opts = {
|
82 |
-
'format': 'best', # Выбирает лучшее качество
|
83 |
-
'quiet': True, # Не выводить информацию в консоль
|
84 |
-
}
|
85 |
-
|
86 |
-
try:
|
87 |
-
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
88 |
-
info_dict = ydl.extract_info(video_url, download=False)
|
89 |
-
video_url = info_dict.get('url', None)
|
90 |
-
except yt_dlp.utils.DownloadError as e:
|
91 |
-
return str(e)
|
92 |
-
|
93 |
-
return video_url
|
94 |
-
|
95 |
-
@app.route('/tutub')
|
96 |
-
def indextutub():
|
97 |
-
return render_template('tutub.html')
|
98 |
-
|
99 |
-
@app.route('/play', methods=['POST'])
|
100 |
-
def play():
|
101 |
-
video_url = request.form['video_url']
|
102 |
-
stream_url = get_video_url(video_url)
|
103 |
-
|
104 |
-
if "Unsupported URL" in stream_url:
|
105 |
-
return jsonify({"error": "Unsupported URL"}), 400
|
106 |
|
107 |
-
return render_template('player.html', stream_url=stream_url)
|
108 |
|
109 |
|
110 |
|
|
|
3 |
import sqlite3
|
4 |
import os
|
5 |
import uuid
|
6 |
+
|
7 |
import json
|
8 |
import base64
|
9 |
import unittest
|
|
|
77 |
|
78 |
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
|
|
81 |
|
82 |
|
83 |
|