mirror of
https://github.com/ReviveMii/revivetube
synced 2025-04-29 04:29:25 -04:00
Added Requirements.txt using pipreqs
This commit is contained in:
parent
b1fb83086d
commit
91db934f52
4 changed files with 26 additions and 19 deletions
1
generateRequirements.sh
Normal file
1
generateRequirements.sh
Normal file
|
@ -0,0 +1 @@
|
|||
pipreqs . --force --ignore .venv
|
21
helper.py
21
helper.py
|
@ -1,3 +1,7 @@
|
|||
import json
|
||||
import subprocess
|
||||
|
||||
|
||||
def read_file(path):
|
||||
assert isinstance(path, str), "Path must be a string"
|
||||
|
||||
|
@ -9,3 +13,20 @@ def read_file(path):
|
|||
return "Error: File not found."
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
|
||||
def get_video_duration_from_file(video_path):
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['ffprobe', '-v', 'error', '-show_format', '-show_streams', '-of', 'json', video_path],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
|
||||
video_info = json.loads(result.stdout)
|
||||
|
||||
duration = float(video_info['format']['duration'])
|
||||
|
||||
return duration
|
||||
except Exception as e:
|
||||
print(f"Can't fetch Video-Duration: {str(e)}")
|
||||
return 0
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
Flask==3.1.0
|
||||
Requests==2.32.3
|
||||
yt_dlp==2024.12.23
|
|
@ -14,7 +14,6 @@ If you use this Code, you agree to https://revivemii.fr.to/revivetube/t-and-p.ht
|
|||
ReviveMii Project: https://revivemii.fr.to/
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
@ -27,7 +26,7 @@ import requests
|
|||
import yt_dlp
|
||||
from flask import Flask, request, render_template_string, send_file, Response, abort, jsonify
|
||||
|
||||
from helper import read_file
|
||||
from helper import read_file, get_video_duration_from_file
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
@ -241,23 +240,6 @@ def format_duration(seconds):
|
|||
return f"{minutes}:{str(seconds).zfill(2)}"
|
||||
|
||||
|
||||
def get_video_duration_from_file(video_path):
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['ffprobe', '-v', 'error', '-show_format', '-show_streams', '-of', 'json', video_path],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
|
||||
video_info = json.loads(result.stdout)
|
||||
|
||||
duration = float(video_info['format']['duration'])
|
||||
|
||||
return duration
|
||||
except Exception as e:
|
||||
print(f"Can't fetch Video-Duration: {str(e)}")
|
||||
return 0
|
||||
|
||||
|
||||
@app.route("/watch", methods=["GET"])
|
||||
def watch():
|
||||
video_id = request.args.get("video_id")
|
||||
|
|
Loading…
Add table
Reference in a new issue