From 5dc05242f5c44dac651babb01a826965f3d253a0 Mon Sep 17 00:00:00 2001 From: Jade Levesque Date: Sun, 19 Feb 2017 01:02:37 -0600 Subject: [PATCH] Greatly improved yt-meta command parsing --- lib/yt-meta | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/lib/yt-meta b/lib/yt-meta index 310d8b0..0e91e91 100755 --- a/lib/yt-meta +++ b/lib/yt-meta @@ -1,3 +1,5 @@ +#!/bin/sh + ##################### # Name: yt-meta.sh # Date: 2016-12-10 @@ -9,15 +11,45 @@ # Usage: yt-meta.sh $video_id -if echo "$1" | grep "youtube.com" +optnum=0 + +for argument in $@ +do + case $argument in + -c) + options="$options c" + optnum=$((optnum+1)) + ;; + -d) # duration + options="$options d" + optnum=$((optnum+1)) + ;; + -D) # date + options="$options D" + optnum=$((optnum+1)) + ;; + -v) + options="$options v" + optnum=$((optnum+1)) + ;; + -t) + options="$options t" + optnum=$((optnum+1)) + ;; + *) + preid="$argument" + esac +done + +if echo "$preid" | grep "youtube.com" then id="$(echo $1 | sed 's/.*video_id=//')" -elif [ -z $1 ] +elif [ -z $preid ] then echo "No video specified." exit 1 else - id="$1" + id="$preid" fi if [ -e "./lib/yt-meta" ] @@ -51,3 +83,20 @@ duration="$(grep "