diff options
author | Melody Horn <melody@boringcactus.com> | 2019-02-26 21:53:17 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2019-02-26 21:53:17 -0700 |
commit | 410a1416157afd78d2e3ddafcb44ca9584847a0e (patch) | |
tree | b6082a15c65a7d09e7e70b275163e9b39a3337d3 /sources.py | |
parent | 64a371f232052e550d3c4832545fcfb6dab11d8e (diff) | |
download | vidslice-410a1416157afd78d2e3ddafcb44ca9584847a0e.tar.gz vidslice-410a1416157afd78d2e3ddafcb44ca9584847a0e.zip |
prep for travis-based deployment
Diffstat (limited to 'sources.py')
-rw-r--r-- | sources.py | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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 |