From a115c7f4238b45f9dbed3d1beb6ab4acf57bc734 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Sun, 24 Jul 2016 13:47:50 -0700 Subject: [PATCH] Tweaking some mailcap definitions. --- mailcap | 3 ++- rtv/mime_parsers.py | 2 +- rtv/terminal.py | 12 ++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mailcap b/mailcap index 3e0ec03..178bc11 100644 --- a/mailcap +++ b/mailcap @@ -24,6 +24,7 @@ image/*; feh -g 640x480 '%s'; test=test -n "$DISPLAY" # Youtube videos are assigned a custom mime-type, which can be streamed with # vlc or youtube-dl. video/x-youtube; vlc '%s'; test=test -n "$DISPLAY" +video/x-youtube; youtube-dl -q -o - '%s' | mpv -; test=test -n "$DISPLAY" # Mpv is a simple and effective video streamer video/webm; mpv '%s'; test=test -n "$DISPLAY" @@ -43,6 +44,6 @@ image/x-imgur-album; echo image/*; curl -s '%s' | convert - jpg:/tmp/rtv.jpg && img2txt -f utf8 /tmp/rtv.jpg; needsterminal; copiousoutput # Ascii videos -video/x-youtube; youtube-dl -q -o - "%s" | mplayer -cache 8192 -quiet - +video/x-youtube; youtube-dl -q -o - '%s' | mplayer -cache 8192 -vo caca -quiet -; needsterminal video/*; wget '%s' -O - | mplayer -cache 8192 -vo caca -quiet -; needsterminal diff --git a/rtv/mime_parsers.py b/rtv/mime_parsers.py index 4b50567..dcac6bf 100644 --- a/rtv/mime_parsers.py +++ b/rtv/mime_parsers.py @@ -156,7 +156,7 @@ class ImgurAlbumMIMEParser(BaseMIMEParser): urls.append('http:' + div.find('img').get('src')) if urls: - return "' '".join(urls), 'image/x-imgur-album' + return " ".join(urls), 'image/x-imgur-album' else: return url, None diff --git a/rtv/terminal.py b/rtv/terminal.py index a78f7a6..1c81d99 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -354,21 +354,25 @@ class Terminal(object): return self.open_browser(url) _logger.info('Executing command: %s', command) - if 'copiousoutput' in entry: - # TODO: open in pager - pass - elif 'needsterminal' in entry: + needs_terminal = 'needsterminal' in entry + copious_output = 'copiousoutput' in entry + + if needs_terminal or copious_output: # Blocking, pause rtv until the process returns with self.suspend(): + os.system('clear') p = subprocess.Popen( [command], stderr=subprocess.PIPE, universal_newlines=True, shell=True) code = p.wait() + if copious_output: + six.moves.input('Press any key to continue') if code != 0: _, stderr = p.communicate() _logger.warning(stderr) self.show_notification( 'Program exited with status=%s\n%s' % (code, stderr)) + else: # Non-blocking, open a background process with self.loader('Opening page', delay=0):