Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial setup script for windows users #12

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions windows_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from urllib.request import urlretrieve
import zipfile
import subprocess
import os

curdir = os.getcwd()

print("Downloading ffmpeg to ffmpeg.zip...")
urlretrieve("https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip", "ffmpeg.zip")
print("Done!")

print("Unzipping ffmpeg.zip...")
with zipfile.ZipFile("ffmpeg.zip", 'r') as zip_ref:
zip_ref.extractall()
folder = f"{curdir}\\{zip_ref.namelist()[0][:-1]}\\bin"
print("Done!")

def add_to_system_path(directory) -> None:
# Get the current system-wide PATH
current_path = os.environ.get('PATH', '')

if "ffmpeg" in current_path:
print("ffmpeg is already present in your system PATH!")
return

# Append the new directory to the PATH, separated by a semicolon
new_path = f"{current_path};{directory}"

# Set the modified PATH variable for the current session
os.environ['PATH'] = new_path

try:
# Use setx command to set the PATH persistently
subprocess.run(['setx', 'PATH', new_path], check=True)
print(f"Added {directory} to the system-wide PATH permanently.")
except subprocess.CalledProcessError as e:
print(f"Failed to set the PATH permanently: {e}")

directory_to_add = folder
add_to_system_path(directory_to_add)
Loading