Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Tim Johnson Newsgroups: comp.lang.python Subject: Re: Using subprocess to capture a progress line Date: Tue, 10 Nov 2015 14:51:02 -0900 Organization: AkWebsoft Lines: 42 Message-ID: References: <20151110224756.GA1944@mail.akwebsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.uni-berlin.de hCaeo2lXadEY/YTwzkeSSAZ4Zo51RYJvPyJCvL8zSOxw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'error:': 0.05; 'elegant': 0.07; 'finished.': 0.07; 'welcome.': 0.07; 'wed,': 0.15; 'buffering': 0.16; 'carriage': 0.16; 'guessing': 0.16; 'investigate': 0.16; 'module).': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subprocess': 0.16; 'wrote:': 0.16; 'tests': 0.18; '>>>': 0.20; '2015': 0.20; 'suggested': 0.20; '(the': 0.22; 'am,': 0.23; "haven't": 0.24; 'tried': 0.24; 'import': 0.24; 'implemented': 0.24; 'tim': 0.24; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'install': 0.25; "i've": 0.25; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'error': 0.27; 'executing': 0.27; 'issue,': 0.27; 'function': 0.28; 'command- line': 0.29; 'code': 0.30; "i'd": 0.31; 'run': 0.33; 'downloading': 0.33; 'point,': 0.33; "i'll": 0.33; 'i.e.': 0.35; 'nov': 0.35; 'problem.': 0.35; 'but': 0.36; 'needed': 0.36; 'possible': 0.36; '(and': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'johnson': 0.37; 'charset:us- ascii': 0.37; 'progress': 0.38; 'reports': 0.38; 'skip:- 60': 0.39; 'to:addr:python.org': 0.40; 'suitable': 0.61; 'more': 0.63; 'times': 0.63; 'numerous': 0.66; 'reply': 0.68; 'sounds': 0.76; 'researched': 0.84; 'subject:Using': 0.84; 'dealt': 0.91; 'skip:y 40': 0.93 Mail-Followup-To: python-list@python.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98622 * Chris Angelico [151110 14:35]: > On Wed, Nov 11, 2015 at 9:47 AM, Tim Johnson wrote: > > I've written a command-line "wrapper" for youtube-dl, executing > > youtube-dl as a subprocess. > > > > ------------------------------------------------------------------ > > youtube-dl reports download progress on one line. I.E. the line is > > overwritten numerous times with no carriage return until the > > downloading is finished. > > ------------------------------------------------------------------ > > > > Sounds to me like a possible buffering problem. But since youtube-dl > is implemented in Python, you might find it easier to "pip install > youtube_dl" and work with the methods directly: > > >>> import youtube_dl > >>> youtube_dl.YoutubeDL().download(["m39ydsOPSww"]) Frankly, I'd prefer - in the long run - to use youtube_dl (the module). But, when I do as you have suggested (and have tried previously) I get the following: youtube_dl.utils.DownloadError: ERROR: no suitable InfoExtractor I've briefly researched the error and so far haven't come up with an solution - guessing that other setup code is needed ... As for the buffering issue, at this point, I'll try using a lower-level function like sys.stdout.write when the line tests for '[download]' and 'ETA'. :) more elegant solutions welcome. I do intend to investigate using youtube_dl, once subprocess has been dealt with. thanks for the quick reply -- Tim http://www.akwebsoft.com, http://www.tj49.com