Browse code

add (U)RL and (I)D views for results

Jenga Phoenix authored on 2019-03-16 15:51:02
Showing 1 changed files
... ...
@@ -319,6 +319,24 @@ function result_formatted_url {
319 319
 
320 320
 # --------------------------------------
321 321
 
322
+# STRING --> STRING
323
+# Format a result-line into an ugly, simple, item URL
324
+function result_format_url {
325
+	local result_line="$1"
326
+	local url="$(result_formatted_url "$result_line")"
327
+
328
+	echo "$url"
329
+}
330
+
331
+# STRING --> STRING
332
+# Format a result-line into an repulsive, simple, item ID
333
+function result_format_id {
334
+	local result_line="$1"
335
+	local id="$(result_id "$result_line")"
336
+
337
+	echo "$id"
338
+}
339
+
322 340
 # STRING --> STRING
323 341
 # Format a result-line into a mediumly-pretty, one-line string~
324 342
 function result_format_compact {
... ...
@@ -541,6 +559,8 @@ function results_display {
541 559
 
542 560
 	for result in $result_lines; do
543 561
 		case "$format" in
562
+			"url") result_format_url "$result" ;;
563
+			"id") result_format_id "$result" ;;
544 564
 			"compact") result_format_compact "$result" ;;
545 565
 			"small") result_format_small "$result" ;;
546 566
 			"medium") result_format_medium "$result" ;;
... ...
@@ -556,37 +576,37 @@ function results_display {
556 576
 
557 577
 # Print playlist usage.
558 578
 function playlist_list_usage {
559
-	echo "usage: yt playlist --list [-csmb] url/id"
579
+	echo "usage: yt playlist --list [-UIcsmb] url/id"
560 580
 	exit 2
561 581
 }
562 582
 
563 583
 # Print playlist usage.
564 584
 function playlist_search_usage {
565
-	echo "usage: yt playlist --search [-csmb] search_query"
585
+	echo "usage: yt playlist --search [-UIcsmb] search_query"
566 586
 	exit 2
567 587
 }
568 588
 
569 589
 # Print playlist usage.
570 590
 function playlist_views_usage {
571
-	echo "usage: yt playlist --views url/id"
591
+	echo "usage: yt playlist views url/id"
572 592
 	exit 2
573 593
 }
574 594
 
575 595
 # Print playlist usage.
576 596
 function playlist_author_usage {
577
-	echo "usage: yt playlist --author [-un] url/id"
597
+	echo "usage: yt playlist author [-Un] url/id"
578 598
 	exit 2
579 599
 }
580 600
 
581 601
 # Print playlist usage.
582 602
 function playlist_date_usage {
583
-	echo "usage: yt playlist --date url/id"
603
+	echo "usage: yt playlist date url/id"
584 604
 	exit 2
585 605
 }
586 606
 
587 607
 # Print playlist usage.
588 608
 function playlist_title_usage {
589
-	echo "usage: yt playlist --title url/id"
609
+	echo "usage: yt playlist title url/id"
590 610
 	exit 2
591 611
 }
592 612
 
... ...
@@ -602,6 +622,8 @@ function playlist_list_invocation {
602 622
 	if test -n "$2"; then
603 623
 		local url="$2"
604 624
 		case "$1" in
625
+			"-U") local format="url" ;;
626
+			"-I") local format="id" ;;
605 627
 			"-c") local format="compact" ;;
606 628
 			"-s") local format="small" ;;
607 629
 			"-m") local format="medium" ;;
... ...
@@ -629,6 +651,8 @@ function playlist_search_invocation {
629 651
 	if test -n "$2"; then
630 652
 		local query="$2"
631 653
 		case "$1" in
654
+			"-U") local format="url" ;;
655
+			"-I") local format="id" ;;
632 656
 			"-c") local format="compact" ;;
633 657
 			"-s") local format="small" ;;
634 658
 			"-m") local format="medium" ;;
... ...
@@ -703,7 +727,7 @@ function playlist_author_invocation {
703 727
 		"--help")
704 728
 			playlist_author_usage ;;
705 729
 		"-h")	playlist_author_usage ;;
706
-		"-u")	view="url"
730
+		"-U")	view="url"
707 731
 			url="$2"
708 732
 			;;
709 733
 		"-n")	view="name"
... ...
@@ -734,25 +758,25 @@ function playlist_author_invocation {
734 758
 
735 759
 # Print video --search usage
736 760
 function video_search_usage {
737
-	echo "usage: yt video --search [-csmb] query"
761
+	echo "usage: yt video search [-UIcsmb] query"
738 762
 	exit 2
739 763
 }
740 764
 
741 765
 # Print video --desc usage
742 766
 function video_desc_usage {
743
-	echo "usage: yt video --desc url/id"
767
+	echo "usage: yt video desc url/id"
744 768
 	exit 2
745 769
 }
746 770
 
747 771
 # Print video --views usage
748 772
 function video_views_usage {
749
-	echo "usage: yt video --views url/id"
773
+	echo "usage: yt video views url/id"
750 774
 	exit 2
751 775
 }
752 776
 
753 777
 # Print video --author usage
754 778
 function video_author_usage {
755
-	echo "usage: yt video --author [-un] url/id"
779
+	echo "usage: yt video author [-Un] url/id"
756 780
 	exit 2
757 781
 }
758 782
 
... ...
@@ -768,6 +792,8 @@ function video_search_invocation {
768 792
 	if test -n "$2"; then
769 793
 		local query="$2"
770 794
 		case "$1" in
795
+			"-U") local format="url" ;;
796
+			"-I") local format="id" ;;
771 797
 			"-c") local format="compact" ;;
772 798
 			"-s") local format="small" ;;
773 799
 			"-m") local format="medium" ;;
... ...
@@ -842,7 +868,7 @@ function video_author_invocation {
842 868
 		"--help")
843 869
 			video_author_usage ;;
844 870
 		"-h")	video_author_usage ;;
845
-		"-u")	view="url"
871
+		"-U")	view="url"
846 872
 			url="$2"
847 873
 			;;
848 874
 		"-n")	view="name"