From 410a1416157afd78d2e3ddafcb44ca9584847a0e Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Tue, 26 Feb 2019 21:53:17 -0700 Subject: prep for travis-based deployment --- sources.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'sources.py') diff --git a/sources.py b/sources.py index f15f3b3..a8a1611 100644 --- a/sources.py +++ b/sources.py @@ -1,5 +1,6 @@ import glob import json +import os import subprocess import tempfile import threading @@ -15,6 +16,30 @@ def has_ytdl(): return False +def update_ytdl(parent_win): + try: + youtube_dl_found = subprocess.run(['where', 'youtube-dl'], stdout=subprocess.PIPE, text=True) + except FileNotFoundError: + youtube_dl_found = subprocess.run(['which', 'youtube-dl'], stdout=subprocess.PIPE, text=True) + if youtube_dl_found.returncode != 0: + def poll(): + answer = wx.MessageBox("Could not find youtube-dl. Open vidslice README?", "Error", wx.YES_NO, parent_win) + if answer == wx.YES: + import webbrowser + webbrowser.open("https://github.com/boringcactus/vidslice/blob/master/README.md") + return + + wx.CallAfter(poll) + youtube_dl_path = youtube_dl_found.stdout.split("\n")[0] + old_mtime = os.stat(youtube_dl_path).st_mtime + proc = subprocess.run(["youtube-dl", "-U"], stdout=subprocess.PIPE, text=True) + if not proc.stdout.startswith("youtube-dl is up-to-date"): + while os.stat(youtube_dl_path).st_mtime == old_mtime: + from time import sleep + sleep(0.25) + wx.CallAfter(lambda: wx.MessageBox("Updated youtube-dl successfully", "Complete", wx.OK, parent_win)) + + class SourcesPanel(wx.Panel): """ A Panel representing source info -- cgit v1.2.3