From 51d49250ca01b6545fc6d0515d696b9f157b85bc Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Wed, 31 Jan 2018 09:12:45 +1030 Subject: added gifv to videos. added ability to detect urls, currently detecting youtube links as videos --- urlopen.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'urlopen.py') diff --git a/urlopen.py b/urlopen.py index ee16a13..21bd78c 100755 --- a/urlopen.py +++ b/urlopen.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2.7 import sys, os; - +from urlparse import urlparse; def run(process, arg): L = []; for each in process: @@ -10,11 +10,13 @@ def run(process, arg): def main(args): images = ["jpg", "png"]; imageapp = ["feh"]; - videos = ["gif", "webm", "mp4"]; videoapp = ["mpv", "--loop"]; + videos = ["gif", "gifv", "webm", "mp4"]; videoapp = ["mpv", "--loop"]; pdf = ["pdf"]; pdfapp = ["mupdf"]; defaultapp = ["/home/daniel_j/compiled/waterfox/waterfox"]; x = 0; for each in args: + parsed_uri = urlparse(each) + domain = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri) if (each.endswith(tuple(images))): print("image {}".format(each)); run(imageapp, each); @@ -24,6 +26,9 @@ def main(args): elif (each.endswith(tuple(pdf))): print("pdf {}".format(each)); run(pdfapp, each); + elif ("youtube.com" or "youtu.be" in domain): + print("video {}".format(each)); + run(videoapp, each); else: print("running with default application {}".format(each)); run(defaultapp, each); -- cgit v1.2.3