Added Requirements.txt using pipreqs

This commit is contained in:
rmilooo 2025-01-01 22:10:56 +01:00
parent b1fb83086d
commit 91db934f52
4 changed files with 26 additions and 19 deletions

1
generateRequirements.sh Normal file
View file

@ -0,0 +1 @@
pipreqs . --force --ignore .venv

View file

@ -1,3 +1,7 @@
import json
import subprocess
def read_file(path): def read_file(path):
assert isinstance(path, str), "Path must be a string" assert isinstance(path, str), "Path must be a string"
@ -9,3 +13,20 @@ def read_file(path):
return "Error: File not found." return "Error: File not found."
except Exception as e: except Exception as e:
return f"Error: {str(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
View file

@ -0,0 +1,3 @@
Flask==3.1.0
Requests==2.32.3
yt_dlp==2024.12.23

View file

@ -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/ ReviveMii Project: https://revivemii.fr.to/
""" """
import json
import os import os
import shutil import shutil
import subprocess import subprocess
@ -27,7 +26,7 @@ import requests
import yt_dlp import yt_dlp
from flask import Flask, request, render_template_string, send_file, Response, abort, jsonify 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__) app = Flask(__name__)
@ -241,23 +240,6 @@ def format_duration(seconds):
return f"{minutes}:{str(seconds).zfill(2)}" 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"]) @app.route("/watch", methods=["GET"])
def watch(): def watch():
video_id = request.args.get("video_id") video_id = request.args.get("video_id")