diff options
author | daniel-Jones <daniel@danieljon.es> | 2018-01-31 09:12:45 +1030 |
---|---|---|
committer | daniel-Jones <daniel@danieljon.es> | 2018-01-31 09:12:45 +1030 |
commit | 51d49250ca01b6545fc6d0515d696b9f157b85bc (patch) | |
tree | 6cb34c5b7aa8756869b29eb5098040525e88d6f9 | |
parent | 0d0c62f6f5f7ae99c8204c82bf942432e796a270 (diff) | |
download | urlopen-51d49250ca01b6545fc6d0515d696b9f157b85bc.tar.gz urlopen-51d49250ca01b6545fc6d0515d696b9f157b85bc.zip |
added gifv to videos. added ability to detect urls, currently detecting youtube links as videos
-rwxr-xr-x | urlopen.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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); |