1
1
mirror of https://github.com/neosubhamoy/pytubepp.git synced 2025-12-20 03:29:36 +05:30

(feat): added nodejs and ffmpeg installation checks

This commit is contained in:
2025-01-19 19:16:00 +05:30
parent b994372c7c
commit 6b9fe938cc
2 changed files with 26 additions and 1 deletions

View File

@@ -3,7 +3,7 @@ from tabulate import tabulate
from .config import get_temporary_directory, load_config, update_config, reset_config
from .download import download_progressive, download_nonprogressive, download_audio, progress
from .postprocess import merge_audio_video, convert_to_mp3
from .utils import get_version, clear_temp_files, is_valid_url, network_available
from .utils import get_version, clear_temp_files, is_valid_url, network_available, ffmpeg_installed, nodejs_installed
import appdirs, os, re, sys, argparse, json
class YouTubeDownloader:
@@ -43,6 +43,11 @@ class YouTubeDownloader:
print('\nRequest timeout! Please check your network and try again...!!')
sys.exit()
if not nodejs_installed():
print("\nWarning: Node.js is not installed or not found in PATH!")
print("BotGuard poToken generation will not work properly without Node.js environment")
print("Please install Node.js from https://nodejs.org/en/download\n")
if is_valid_url(link):
link = is_valid_url(link).group(1)
self.video = YouTube(link, 'WEB', on_progress_callback=progress)
@@ -251,6 +256,12 @@ class YouTubeDownloader:
print(f'\nTitle: {self.title}\nSelected Stream: {resolution_map.get(chosen_stream, "Unknown")}\n')
def download_stream(self, link, chosen_stream, chosen_caption=None):
if not ffmpeg_installed():
print("\nWarning: FFmpeg is not installed or not found in PATH!")
print("Some core functionalities like video processing will not work properly without FFmpeg")
print("Please install FFmpeg, read https://github.com/neosubhamoy/pytubepp#%EF%B8%8F-installation for instructions\n")
sys.exit()
if self.set_video_info(link):
allowed_streams = self.get_allowed_streams(link)
allowed_captions = self.get_allowed_captions(link)

View File

@@ -15,6 +15,20 @@ def network_available():
except subprocess.CalledProcessError:
return False
def nodejs_installed():
try:
subprocess.run(['node', '--version'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def ffmpeg_installed():
try:
subprocess.run(['ffmpeg', '-version'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def get_version():
try:
return version('pytubepp')