Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
Added ffmpeg updater
Browse files Browse the repository at this point in the history
  • Loading branch information
rogama25 committed Jan 30, 2020
1 parent a753a29 commit edf9b2e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,48 @@ def download_ffmpeg():
shutil.rmtree("ffmpeg-"+version+"-win32-static")
zip.close()
os.remove("ffmpeg.zip")
else:
import urllib.request
import subprocess
import re
import zipfile
import shutil
version = urllib.request.urlopen("https://raw.githubusercontent.com/rogama25/audiosToTwitter/master/latest-ffmpeg.txt").read() # Get the last ffmpeg version from my repo
version = version.decode("UTF-8")
result = subprocess.run("ffmpeg -version", capture_output=True)
oldversion = re.search("(?<=ffmpeg version )[^ ]*", str(result.stdout))
oldversion = oldversion.group(0)
if version > oldversion:
import requests
import progress.bar
import sys
print("New ffmpeg version available. Installed: " + oldversion + " New version: " + version)
char = input("Do you want to update ffmpeg now? This will download around 60MiB of data. [y/n] ")
while True:
if char.lower() == "n":
sys.exit(1)
if char.lower() == "y":
break
char = input("[y/n] ")
print("Downloading FFMPEG. Please wait...")
url = "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-" + version + "-win32-static.zip"
with requests.get(url, stream=True) as r:
r.raise_for_status()
with open("ffmpeg.zip", 'wb') as f:
file_size = int(r.headers["Content-Length"])
with progress.bar.Bar("Downloading... " + str(round(file_size/1024/1024,2)) + " MiB", suffix="%(percent)d%% ETA: %(eta)ds") as progress_bar:
for chunk in r.iter_content(chunk_size=8192):
progress_bar.next(1/(float(file_size)/8192)*100)
if chunk:
f.write(chunk)
zip = zipfile.ZipFile("ffmpeg.zip") # Extract zip
zip.extract("ffmpeg-"+version+"-win32-static/bin/ffmpeg.exe")
os.remove("ffmpeg.exe")
os.rename("ffmpeg-"+version+"-win32-static/bin/ffmpeg.exe", "ffmpeg.exe")
shutil.rmtree("ffmpeg-"+version+"-win32-static")
zip.close()
os.remove("ffmpeg.zip")



def get_version():
Expand Down

0 comments on commit edf9b2e

Please sign in to comment.