Browse code

BURN EVERYTHING TO THE GROUND

Jade Levesque authored on 2017-06-18 00:41:18
Showing 10 changed files
1 1
deleted file mode 100644
... ...
@@ -1,4 +0,0 @@
1
-Simple. Just move the "shelltube" script along with
2
-the scripts in lib/ into your PATH.
3
-Then-- boom, installed.
4
-Groovy.
5 0
deleted file mode 100644
... ...
@@ -1,102 +0,0 @@
1
-![Shelltube](https://cloud.githubusercontent.com/assets/7250745/21452795/52fcd6ea-c901-11e6-871b-bd646f2d7c49.png)
2
-
3
-shellTube is a collection of (pretty POSIX) shell scripts to
4
-browse YouTube quickly, efficiently, and without the bloat
5
-most command-line clients require.
6
-
7
-shellTube is written in pure shell; its only dependencies
8
-are any modern shell (pdksh, bash, zsh), curl/wget, and
9
-vlc/mplayer/kaffeine.
10
-
11
-Even these dependencies, though, can easily be changed. If,
12
-for example, you don't have vlc, you can just modify a
13
-single line and be good-to-go using another player.
14
-
15
-Also, shellTube doesn't use the YouTube API at all. This
16
-avoids the annoying red-tapey stuff that goes with it -- IDs,
17
-registration, quotas -- but has some disadvantages. We'll
18
-power through the downsides, though! :)
19
-
20
-
21
-Usage
22
-shellTube is quite simple to use; this tutorial will go over
23
-the usage of the wrapper script, `shelltube`.
24
-When running the script, you'll see a prompt:
25
-
26
-```
27
- >>
28
-```
29
-
30
-In this prompt you can type any of the following commands:
31
-
32
-| (short) command syntax | description |
33
-| --- | --- |
34
-| (`!`) `about` | View the about page. |
35
-| (`cls`) `clear` | Clear the screen. |
36
-| (`dl`) `download [URL] ` | Download the selected/specified video. |
37
-| `exit` | Exit Shelltube. |
38
-| (`?`) `help` | Display this message. |
39
-| (`md`) `metadata [URL]` | Display selected/specified video's metadata. |
40
-| (`//`) `playlist URL` `playlist ID` | View playlist based on `URL` or `ID`. |
41
-| (`/`) `search TERM` | Perform a search for `TERM`. |
42
-| (`str`) `stream [URL]` | Stream the selected/specified video. |
43
-| (`sel`) `video URL` `video ID` | Select video based on `URL` or `ID`. |
44
-| (`lq`) `queue` | Lists all videos in the queue. |
45
-| (`sq`) `squeue` | Streams all videos in the queue. |
46
-| (`dq`) `dqueue` | Downloads all videos in the queue. |
47
-
48
-In [brackets], optional arguments are written.
49
-
50
-You can use shellTube in one of two ways (or both):
51
-
52
-1. By selecting a video and then doing something with it
53
-2. By doing something and specifying the video
54
-
55
-Method A entails using either the `video` or `search`
56
-command to select a video, which will then be displayed
57
-before the prompt like so:
58
-
59
-```
60
-$VIDEO-ID-HERE >>
61
-```
62
-
63
-When a video is selected, you use the `download`, `stream`,
64
-or `metadata` commands without arguments to act on the
65
-video.
66
-
67
-Method B entails just using the `download`, `stream`, or
68
-`metadata` commands while using a URL or video ID as an
69
-argument.
70
-
71
-For example:
72
-
73
-```
74
- >> download $VIDEO-ID-HERE
75
-```
76
-
77
-You can also download or stream multiple videos in a row
78
-without user input with the queue.
79
-The queue is a list of video IDs in the file `/tmp/yt-queue`
80
-You can add to the queue manually or while looking at
81
-search results, playlist videos, or channel videos by inputting
82
-`*` rather than a number when prompted. This adds every video 
83
-listed to the queue.
84
-When you're back at the main prompt, you can enter `lq`, `dq`,
85
-or `sq` to list, download, or stream the queued videos.
86
-
87
-You could opt to not use this interactive wrapper script and
88
-instead just use the `yt-down`, `yt-search`, and
89
-`yt-metadata` scripts on their own.
90
-
91
-They are each pretty simple, and you can read their USAGE
92
-messages at the top of each script.
93
-
94
-
95
-Licensing
96
-All of ST is released under the
97
-[ISC](https://opensource.org/licenses/ISC) license.
98
-
99
-Except for the `y-down` script, which is released under the
100
-[GPLv2](https://www.gnu.org/licenses/gpl-2.0.html).
101 0
deleted file mode 100755
... ...
@@ -1,23 +0,0 @@
1
-#!/bin/sh
2
-#####################
3
-# Name: st-download.sh
4
-# Lisc: ISC
5
-# Main: jadedctrl
6
-# Desc: No beer and no TV
7
-#       make   Homer   go
8
-#       something-something
9
-#       Cxu ne?
10
-#####################
11
-
12
-if test -z "$download_cmd"
13
-then
14
-    if command -v wget > /dev/null
15
-    then
16
-        wget -q "$1" -O "$2" 
17
-    elif command -v curl > /dev/null
18
-    then
19
-        curl -s "$1" -o "$2"
20
-    fi
21
-else
22
-    $download_cmd
23
-fi
24 0
deleted file mode 100755
... ...
@@ -1,28 +0,0 @@
1
-#!/bin/sh
2
-#####################
3
-# Name: st-video.sh
4
-# Date: 2016-12-22
5
-# Lisc: ISC
6
-# Main: jadedctrl
7
-# Desc: Does a thing with
8
-#       a video-thingy thing
9
-#       dsfgbvesrht fd
10
-#####################
11
-
12
-if [ -e "$HOME/.config/shelltube" ]
13
-then
14
-    . "$HOME/.config/shelltube"
15
-fi
16
-
17
-if test -z "$player_cmd"
18
-then
19
-    if command -v vlc > /dev/null
20
-    then
21
-        vlc --play-and-exit "${1}"
22
-    elif command -v mplayer > /dev/null
23
-    then
24
-        mplayer --quiet "${1}"
25
-    fi
26
-else
27
-    $player_cmd "${1}"
28
-fi
29 0
deleted file mode 100755
... ...
@@ -1,191 +0,0 @@
1
-#!/bin/sh
2
-#####################
3
-# Name: yt-channel.sh
4
-# Lisc: ISC
5
-# Main: jadedctrl
6
-# Desc: Display a channel's videos
7
-#       or details in easy-to-read
8
-#       and easy-to-parse results.
9
-#####################
10
-
11
-# Usage: yt-channel.sh [-uci] userid||channel
12
-
13
-if [ -e "$HOME/.config/shelltube" ]
14
-then
15
-    . "$HOME/.config/shelltube"
16
-else
17
-    results=21
18
-fi
19
-
20
-if [ -e "./lib/yt-meta" ]
21
-then
22
-    alias yt-channel="./lib/yt-channel"
23
-    alias yt-search="./lib/yt-down"
24
-    alias yt-meta="./lib/yt-meta"
25
-    alias yt-search="./lib/yt-search"
26
-    alias yt-down="./lib/yt-channel"
27
-    alias st-download="./lib/st-download"
28
-    alias st-video="./lib/st-video"
29
-fi
30
-
31
-interactive_mode=0
32
-channel_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
33
-
34
-# I really need to work out a better way to take flags.
35
-# This is just awful.
36
-# ... I'll cross that bridge later.
37
-
38
-
39
-if [ "$1" = "-u" ]
40
-then
41
-    type="user"
42
-    st-download "https://youtube.com/user/$2/videos" "$channel_file"
43
-elif [ "$1" = "-iu" ]
44
-then
45
-    output="$3"
46
-    interactive_mode=1
47
-    type="user"
48
-    st-download "https://youtube.com/user/$2/videos" "$channel_file"
49
-elif [ "$1" = "-c" ]
50
-then
51
-    type="channel"
52
-    st-download "https://youtube.com/channel/$2/videos" "$channel_file"
53
-elif [ "$1" = "-ic" ]
54
-then
55
-    output="$3"
56
-    interactive_mode=1
57
-    type="channel"
58
-    st-download "https://youtube.com/channel/$2/videos" "$channel_file"
59
-elif [ "$1" = "-uc" ] || [ -k "$2" ] 
60
-then
61
-    echo "Usage: yt-channel.sh [-uci] userid||channel [output]"
62
-    echo "Make sure to use either the -u flag or the -c flag--"
63
-    echo "*not* both! Also, specify a userid or channel name."
64
-    exit 1
65
-else
66
-    echo "Usage: yt-channel.sh [-uc] userid||channel"
67
-    exit 1
68
-fi
69
-
70
-get_input() {
71
-    printf '\033[0;32m>>>\033[0m '
72
-    read -r n
73
-
74
-    if [ "$n" = "exit" ]
75
-    then
76
-        exit
77
-    fi
78
-    if [ "$n" == "*" ]
79
-    then
80
-        cat $temp_file | while IFS='' read -r CUR_LINE
81
-        do
82
-            echo "$CUR_LINE" | sed 's/.*href="\/watch?v=//' | sed 's/".*//' >> $output
83
-        done
84
-        cp $output /tmp/yt-queue
85
-#    test $n -ge 0
86
-    elif [ $? -gt 1 ] 
87
-    then
88
-        echo "Bad input, mate. Type in a valid number or 'exit'."
89
-        get_input
90
-    elif [ $n -gt 20 ]
91
-    then
92
-        echo "Out of range. Type in a valid number or 'exit'."
93
-        get_input
94
-    elif [ $n -gt 0 ] && [ $n -lt 20 ]
95
-    then
96
-        sed -n "${n}p" "$temp_file" | sed 's/.*href="\/watch?v=//' | sed 's/".*//' > "$output"
97
-    else
98
-        echo "Bad input, mate. Type in a valid number or 'exit'."
99
-        get_input
100
-    fi
101
-}
102
-
103
-
104
-row=0
105
-
106
-# Now for displaying the search results
107
-temp_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
108
-
109
-grep "href=\"\/watch?v=" "$channel_file" | grep "title=" | grep -v \
110
-     "<span class=\"yt-thumb-simple\"" > "$temp_file"
111
-item_num=0
112
-cat "$temp_file" | while IFS='' read -r CUR_LINE 
113
-do 
114
-    item_num=$((item_num+1)) 
115
-    LINE="$(echo "$CUR_LINE" | sed 's/<span class=\"yt-badge \" >.*//')"
116
-    LINE="$(echo "$LINE" | sed 's/views<\/li>.*//')"
117
-    LINE="$(echo "$LINE" | sed 's/title="Verified"//')"
118
-
119
-    if [ $row -eq 1 ]
120
-    then
121
-        #color='\033[1;34m'
122
-        #color2='\033[1;34m'
123
-        printf '\033[1;34m'
124
-        row=0
125
-    elif [ $row -eq 0 ]
126
-    then
127
-        #color='\033[1;31m'
128
-        #color2='\033[1;31m'
129
-        printf '\033[1;31m'
130
-        row=1
131
-    fi
132
-
133
-    if echo "$LINE" | grep "View full playlist" > /dev/null
134
-    then
135
-        type="Playlist"
136
-        title=$(echo "$LINE" | sed 's/.*title="//' | sed 's/".*//')
137
-        items=$(echo "$LINE" | sed 's/.*View full playlist (//' | sed 's/).*//')
138
-        if [ $item_num -ge $((results+1)) ]
139
-        then
140
-            break
141
-        elif [ $item_num -lt 10 ]
142
-        then
143
-            printf '%s.  ' "$item_num"
144
-        else
145
-            printf '%s. ' "$item_num"
146
-        fi
147
-        printf '%s' "$title"
148
-        printf '    '
149
-        printf '%s | %s' "$type" "$items"
150
-        printf '    '
151
-    else
152
-        type="Video"
153
-        duration=$(echo "$LINE" | sed 's/.*Duration: //' | sed 's/\..*//')
154
-        itemid=$(echo "$LINE" | sed 's/.*href="\/watch?v=//' | sed 's/".*//')
155
-        title=$(echo "$LINE" | sed 's/.* title="//' | sed 's/".*//')
156
-
157
-        if [ $item_num -ge $((results+1)) ]
158
-        then
159
-            break
160
-        elif [ $item_num -lt 10 ]
161
-        then
162
-            printf '%s.  ' "$item_num"
163
-        else
164
-            printf '%s. ' "$item_num"
165
-        fi
166
-        echo "$title"
167
-        printf '    '
168
-        i=0
169
-        while [ $i -lt 9 ]
170
-        do
171
-            i=$((i+1))
172
-            char=$(echo "$duration" | cut -c$i)
173
-            if [ -z "$char" ]
174
-            then
175
-                printf ' '
176
-            else
177
-                printf '%s' "$char"
178
-            fi
179
-        done
180
-        printf ' | %s\n' "$itemid"
181
-    fi
182
-done
183
-
184
-if [ $interactive_mode -eq 1 ]
185
-then
186
-    get_input
187
-fi
188
-
189
-printf '\033[0m'
190
-
191
-rm "$temp_file"
192 0
deleted file mode 100755
... ...
@@ -1,140 +0,0 @@
1
-#!/bin/sh
2
-#####################
3
-# Name: yt-down
4
-# Lisc: GPLv2
5
-# Auth: iluaster
6
-# Main: jadedctrl
7
-# Desc: Fetches YT videos.
8
-#####################
9
-
10
-# Based on https://github.com/iluaster/Youtube_downloader
11
-
12
-# Usage: yt-down -[sSD] $video_id
13
-# -s for stream; -S for stream and skip prompt; 
14
-# -D for download and skip prompt; No arg for download.
15
-
16
-
17
-if [ "$1" = "-s" ]
18
-then
19
-    stream_mode=1
20
-    id=$2
21
-elif [ "$1" = "-S" ]
22
-then
23
-    stream_mode=1
24
-    skip_prompt=1
25
-    id=$2
26
-elif [ "$1" = "-D" ]
27
-then
28
-    stream_mode=0
29
-    skip_prompt=1
30
-    id=$2
31
-else
32
-    stream_mode=0
33
-    id=$1
34
-fi
35
-
36
-if [ -e "./lib/yt-meta" ]
37
-then
38
-    alias yt-channel="./lib/yt-channel"
39
-    alias yt-search="./lib/yt-down"
40
-    alias yt-meta="./lib/yt-meta"
41
-    alias yt-search="./lib/yt-search"
42
-    alias yt-down="./lib/yt-channel"
43
-    alias st-download="./lib/st-download"
44
-    alias st-video="./lib/st-video"
45
-fi
46
-
47
-
48
-if echo "$id" | grep "youtube.com"
49
-then 
50
-    id="$(echo "$id" | sed 's/.*video_id=//')"
51
-elif [ -z "$id" ]
52
-then
53
-    echo "No video specified."
54
-    exit 1
55
-else
56
-    id="$id"
57
-fi
58
-    
59
-name="http://www.youtube.com/get_video_info?video_id=$id"
60
-
61
-declare -i line=0 2> /dev/null
62
-
63
-if $? 2> /dev/null
64
-then
65
-    echo > /dev/null
66
-else
67
-    line=0
68
-fi
69
-
70
-select_option ()
71
-{
72
-    echo "Formats:"
73
-    cat /tmp/video_type_option.txt | while IFS='' read -r i
74
-    do
75
-        line=$((line+1)) 
76
-        # Replace this pipe method so $line isn't lost
77
-        echo "${line}. $i"
78
-    done
79
-    if [ $skip_prompt -eq 0 ]
80
-    then
81
-        printf '\033[0;32m>>>\033[0m '
82
-        IFS=''
83
-        read -r n
84
-    else
85
-        n=1
86
-    fi
87
-
88
-    if [ $n -le 5 ];
89
-    then
90
-        head -n "$n" /tmp/tmp3.txt | tail -n 1 > /tmp/tmp4.txt
91
-    else
92
-        echo "$line $n"
93
-        echo "Input Error!"
94
-        line=0
95
-        select_option
96
-    fi
97
-}
98
-
99
-
100
-st-download "$name" "/tmp/${id}_url.txt"
101
-
102
-# Cut and filter mp4 url
103
-
104
-cp "/tmp/${id}_url.txt" /tmp/tmp2.txt
105
-sed -e 's/&/\n/g' /tmp/tmp2.txt| grep 'url_encoded_fmt_stream_map'> /tmp/tmp3.txt
106
-sed -i -e 's/%2C/,/g' /tmp/tmp3.txt 
107
-sed -i -e 's/,/\n/g' /tmp/tmp3.txt
108
-
109
-# Print out total video format name and quality
110
-perl -ne 'print "$2,$1\n" if /quality%3D(.*?)%.*video%252F(.*?)(%|\n)/' /tmp/tmp3.txt > /tmp/video_type_option.txt
111
-
112
-# If video format name is prior to quality
113
-perl -ne 'print "$1,$2\n" if /video%252F(.*?)%.*quality%3D(.*?)(%|\n)/' /tmp/tmp3.txt >> /tmp/video_type_option.txt
114
-sed -i -e 's/x-flv/flv/g' /tmp/video_type_option.txt
115
-
116
-select_option
117
-  
118
-# Set file extension name variable and video quality variable
119
-extension_name=$(head -n "$n" /tmp/video_type_option.txt | tail -n 1 | cut -d "," -f 1)
120
-quality_name=$(head -n "$n" /tmp/video_type_option.txt | tail -n 1 | cut -d "," -f 2)
121
-
122
-sed -i -e 's/%26/\&/g' /tmp/tmp4.txt
123
-sed -i -e 's/&/\n/g' /tmp/tmp4.txt
124
-grep 'http' /tmp/tmp4.txt > /tmp/tmp5.txt
125
-grep 'sig%3D' /tmp/tmp4.txt >> /tmp/tmp5.txt
126
-perl -pe 's/\n//g' /tmp/tmp5.txt | sed -e 's/sig%3D/\&signature%3D/g' > /tmp/tmp6.txt
127
-sed -i -e 's/url%3D//g' /tmp/tmp6.txt
128
-# url decoding
129
-cat /tmp/tmp6.txt | sed -e 's/%25/%/g' -e 's/%25/%/g' -e 's/%3A/:/g' -e 's/%2F/\//g' -e 's/%3F/\?/g' -e 's/%3D/=/g' -e 's/%26/\&/g' > /tmp/tmp7.txt
130
-
131
-
132
-if [ $stream_mode -eq 1 ]
133
-then
134
-    st-video "$(cat /tmp/tmp7.txt)"
135
-else
136
-    st-download "$(cat /tmp/tmp7.txt)" "${id}_${quality_name}.${extension_name}"
137
-fi
138
-  
139
- 
140
-rm -f /tmp/tmp[2-7].txt "/tmp/${id}_url.txt" /tmp/video_type_option.txt
141 0
deleted file mode 100755
... ...
@@ -1,117 +0,0 @@
1
-#!/bin/sh
2
-
3
-#####################
4
-# Name: yt-meta.sh
5
-# Date: 2016-12-10
6
-# Lisc: ISC
7
-# Main: jadedctrl
8
-# Desc: Fetches metadata about
9
-#       a specific YT video.
10
-#####################
11
-
12
-# Usage: yt-meta.sh $video_id
13
-
14
-optnum=0
15
-
16
-for argument in $@
17
-do
18
-    if echo $argument | grep "^-" > /dev/null
19
-    then
20
-        charcount=$(echo "$argument" | echo "$(wc -c) - 1" | bc)
21
-        while [ $charcount -gt 0 ]
22
-        do
23
-            character=$(echo "$argument" | head -c1)
24
-            argument=$(echo "$argument" | sed 's/^.//')
25
-            case $character in
26
-                c)
27
-                    options="$options c"
28
-                    optnum=$((optnum+1)) ;;
29
-                d) # duration
30
-                    options="$options d"
31
-                    optnum=$((optnum+1)) ;;
32
-                D) # date
33
-                    options="$options D"
34
-                    optnum=$((optnum+1)) ;;
35
-                v)
36
-                    options="$options v"
37
-                    optnum=$((optnum+1)) ;;
38
-                t)
39
-                    options="$options t"
40
-                    optnum=$((optnum+1)) ;;
41
-                i)
42
-                    options="$options i"
43
-                    optnum=$((optnum+1)) ;;
44
-                -)  ;;
45
-            esac
46
-            charcount=$((charcount-1))
47
-        done
48
-    else
49
-        preid="$argument"
50
-    fi
51
-done 
52
-
53
-
54
-if echo "$preid" | grep "youtube.com" > /dev/null
55
-then 
56
-    id="$(echo $preid | sed 's/.*v=//')"
57
-elif [ -z $preid ]
58
-then
59
-    echo "No video specified."
60
-    exit 1
61
-else
62
-    id="$preid"
63
-fi
64
-
65
-if [ -e "./lib/yt-meta" ]
66
-then
67
-    alias yt-channel="./lib/yt-channel"
68
-    alias yt-search="./lib/yt-down"
69
-    alias yt-meta="./lib/yt-meta"
70
-    alias yt-search="./lib/yt-search"
71
-    alias yt-down="./lib/yt-channel"
72
-    alias st-download="./lib/st-download"
73
-    alias st-video="./lib/st-video"
74
-fi
75
-
76
-
77
-video_file="/tmp/$(mktemp -u yt-video_XXXXXX)"
78
-if type "wget" &> /dev/null
79
-then
80
-    wget -q https://youtube.com/watch?v=$id -O $video_file
81
-    wget -q https://youtube.com/results?search_query=$id -O $video_file.1
82
-elif type "curl" &> /dev/null
83
-then
84
-    curl -s https://youtube.com/watch?v=$id -o $video_file
85
-    curl -s https://youtube.com/results?search_query=$id -o $video_file.1
86
-fi
87
-
88
-# Now for displaying the metadata
89
-title="$(grep "\"title\":\"" $video_file | sed 's/.*"title":"//' | sed 's/".*//')"
90
-author="$(grep "\"author\":\"" $video_file | sed 's/.*"author":"//' | sed 's/".*//')"
91
-views="$(grep "\"view_count\":\"" $video_file | sed 's/.*"view_count":"//' | sed 's/".*//')"
92
-duration="$(grep "<a href=\"/watch?v=$1" $video_file.1 | sed 's/.*Duration: //' | sed 's/\..*//')"
93
-date="$(grep "datePublished" $video_file | sed 's/.*"datePublished" content="//' | sed 's/".*//')"
94
-
95
-if [ $optnum -eq 0 ]
96
-then
97
-    echo "$author | $views | $duration | $date | $id"
98
-fi
99
-
100
-for option in $options
101
-do
102
-    case $option in
103
-        c) printf "$author" ;;
104
-        t) printf "$title" ;;
105
-        d) printf "$duration" ;;
106
-        D) printf "$date" ;;
107
-        v) printf "$views" ;;
108
-        i) printf "$id" ;;
109
-    esac
110
-    if [ $optnum -ge 2 ]
111
-    then
112
-        printf " | "
113
-        optnum=$((optnum-1))
114
-    else
115
-        printf "\n"
116
-    fi
117
-done
118 0
deleted file mode 100755
... ...
@@ -1,156 +0,0 @@
1
-#####################
2
-# Name: yt-playlist
3
-# Lisc: ISC
4
-# Main: jadedctrl
5
-# Desc: List a playlist's videos
6
-#       in easy-to-read and easy-to
7
-#       -parse results
8
-#####################
9
-
10
-# Usage: yt-playlist "$playlist_ID"
11
-
12
-if [ -e $HOME/.config/shelltube ]
13
-then
14
-    . $HOME/.config/shelltube
15
-else
16
-    results=21
17
-fi
18
-
19
-if [ -e "./lib/yt-meta" ]
20
-then
21
-    alias yt-channel="./lib/yt-channel"
22
-    alias yt-search="./lib/yt-down"
23
-    alias yt-meta="./lib/yt-meta"
24
-    alias yt-search="./lib/yt-search"
25
-    alias yt-down="./lib/yt-channel"
26
-    alias st-download="./lib/st-download"
27
-    alias st-video="./lib/st-video"
28
-fi
29
-
30
-row=0
31
-
32
-if [ "$1" == "-i" ]
33
-then
34
-    interactive_mode=1
35
-    plist="$(echo "$2" | sed 's/ /+/g')"
36
-    output="$3"
37
-else
38
-    interactive_mode=0
39
-    plist="$(echo "$1" | sed 's/ /+/g')"
40
-fi
41
-
42
-function get_input() {
43
-    printf '\033[0;32m>>>\033[0m '
44
-    read -r n
45
-
46
-    if [ "$n" == "exit" ]
47
-    then
48
-        exit
49
-    fi
50
-
51
-    if [ "$n" == "*" ]
52
-    then
53
-        cat $temp_file | while IFS='' read -r CUR_LINE
54
-        do
55
-            echo $CUR_LINE | sed 's/.*data-video-id="//' | sed 's/".*//' >> $output
56
-            cp $output /tmp/yt-queue
57
-        done
58
-#    test $n -ge 0 &> /dev/null
59
-    elif [ $? -gt 1 ] 
60
-    then
61
-        echo "Bad input, mate. Type in a valid number or 'exit'."
62
-        get_input
63
-    elif [ $n -gt 20 ]
64
-    then
65
-        echo "Out of range. Type in a valid number or 'exit'."
66
-        get_input
67
-    elif [ $n -gt 0 ] && [ $n -lt 20 ]
68
-    then
69
-        sed -n ${n}p $temp_file | sed 's/.*data-video-id="//' | sed 's/".*//' > $output
70
-    else
71
-        echo "Bad input, mate. Type in a valid number or 'exit'."
72
-        get_input
73
-    fi
74
-}
75
-
76
-# If Google adds any extra features or changes the webpage
77
-# layout, this script'll break immediately, haha.
78
-# ... But at least we aren't using their API, right?
79
-
80
-plist_file="/tmp/$(mktemp -u yt-search_XXXXXX)"
81
-
82
-st-download https://youtube.com/playlist?list=$plist $plist_file
83
-
84
-# Now for displaying the search results
85
-temp_file="/tmp/$(mktemp -u yt-result_XXXXXX)"
86
-grep "<tr class=\"pl-video yt-uix-tile \"" $plist_file > $temp_file
87
-
88
-item_num=0
89
-cat $temp_file | while IFS='' read -r CUR_LINE
90
-do 
91
-    item_num=$(($item_num+1))
92
-
93
-    if [ $row -eq 1 ]
94
-    then
95
-        #color='\033[1;34m'
96
-        #color2='\033[1;34m'
97
-        printf '\033[1;34m'
98
-        row=0
99
-    elif [ $row -eq 0 ]
100
-    then
101
-        #color='\033[1;31m'
102
-        #color2='\033[1;31m'
103
-        printf '\033[1;31m'
104
-        row=1
105
-    fi
106
-
107
-    itemid=$(echo "$CUR_LINE" | sed 's/.*data-video-id="//' | sed 's/".*//')
108
-    title=$(echo "$CUR_LINE" | sed 's/.*data-title="//' | sed 's/".*//')
109
-    author=$(grep -C3 "      $(echo $title)" "$plist_file" | grep "by <a href=" | sed 's/by.* >//' | sed 's/<\/a>.*//')
110
-    duration=$(grep -C9 "      $(echo $title)" "$plist_file" | grep "<td class=\"pl-video-badges\">" | sed 's/.*">//' | sed 's^</span>.*^^')
111
-
112
-    if [ $item_num -ge $((results+1)) ]
113
-    then
114
-        break
115
-    elif [ $item_num -lt 10 ]
116
-    then
117
-        printf '%s.  ' "$item_num"
118
-    else
119
-        printf '%s. ' "$item_num"
120
-    fi
121
-    printf '%s\n' "$title"
122
-    printf '    '
123
-    i=0
124
-        while [ $i -lt 16 ]
125
-        do
126
-            i=$((i+1))
127
-            char=$(echo $author | cut -c$i)
128
-            if [ -z $char ]
129
-            then
130
-                printf ' '
131
-            else
132
-                printf '%s' "$char"
133
-            fi
134
-        done
135
-        printf ' | '
136
-        i=0
137
-        while [ $i -lt 5 ]
138
-        do
139
-            i=$((i+1))
140
-            char=$(echo $duration | cut -c$i)
141
-            if [ -z $char ]
142
-            then
143
-                printf ' '
144
-            else
145
-                printf '%s' "$char"
146
-            fi
147
-        done
148
-        printf ' | %s\n' "$itemid"
149
-done
150
-
151
-printf '\033[0m'
152
-
153
-if [ $interactive_mode -eq 1 ]
154
-then
155
-    get_input
156
-fi
157 0
deleted file mode 100755
... ...
@@ -1,190 +0,0 @@
1
-#####################
2
-# Name: yt-result.sh
3
-# Date: 2016-12-10
4
-# Lisc: ISC
5
-# Main: jadedctrl
6
-# Desc: Search YT videos and display
7
-#       in easy-to-read and easy-to #       -parse results
8
-#####################
9
-
10
-# Usage: yt-search.sh "$search_string"
11
-
12
-if [ -e $HOME/.config/shelltube ]
13
-then
14
-    . $HOME/.config/shelltube
15
-else
16
-    results=21
17
-fi
18
-
19
-if [ -e "./lib/yt-meta" ]
20
-then
21
-    alias yt-channel="./lib/yt-channel"
22
-    alias yt-search="./lib/yt-down"
23
-    alias yt-meta="./lib/yt-meta"
24
-    alias yt-search="./lib/yt-search"
25
-    alias yt-down="./lib/yt-channel"
26
-    alias st-download="./lib/st-download"
27
-    alias st-video="./lib/st-video"
28
-fi
29
-
30
-row=0
31
-
32
-if [ "$1" == "-i" ]
33
-then
34
-    interactive_mode=1
35
-    query="$(echo "$2" | sed 's/ /+/g')"
36
-    output="$3"
37
-else
38
-    interactive_mode=0
39
-    query="$(echo "$1" | sed 's/ /+/g')"
40
-fi
41
-
42
-function get_input() {
43
-    printf '\033[0;32m>>>\033[0m '
44
-    read -r n
45
-
46
-    if [ "$n" == "exit" ]
47
-    then
48
-        exit
49
-    elif [ "$n" == "*" ]
50
-    then
51
-        cat $temp_file | while IFS='' read -r CUR_LINE
52
-        do
53
-            echo "$CUR_LINE" | sed 's/.*<a href="\/watch?v=//' | sed 's/".*//' >> $output
54
-        done
55
-        cp $output /tmp/yt-queue
56
-    #test $n -ge 0 &> /dev/null
57
-    elif [ $? -gt 1 ] 
58
-    then
59
-        echo "Bad input, mate. Type in a valid number or 'exit'."
60
-        get_input
61
-    elif [ $n -gt 20 ]
62
-    then
63
-        echo "Out of range. Type in a valid number or 'exit'."
64
-        get_input
65
-    elif [ $n -gt 0 ] && [ $n -lt 20 ]
66
-    then
67
-        if sed -n ${n}p $temp_file | grep "View full playlist" > /dev/null
68
-        then
69
-           sed -n ${n}p $temp_file | sed 's/.*&amp;list=//' | sed 's/".*//' > $output
70
-        else
71
-            sed -n ${n}p $temp_file | sed 's/.*<a href="\/watch?v=//' | sed 's/".*//' > $output
72
-        fi
73
-    else
74
-        echo "Bad input, mate. Type in a valid number or 'exit'."
75
-        get_input
76
-    fi
77
-}
78
-
79
-# If Google adds any extra features or changes the webpage
80
-# layout, this script'll break immediately, haha.
81
-# ... But at least we aren't using their API, right?
82
-
83
-search_file="/tmp/$(mktemp -u yt-search_XXXXXX)"
84
-
85
-st-download https://youtube.com/results?search_query=$query $search_file
86
-
87
-# Now for displaying the search results
88
-temp_file="/tmp/$(mktemp -u yt-result_XXXXXX)"
89
-grep "<a href=\"\/watch?v=" $search_file | grep -v "<span class=\"yt-thumb-simple\"" > $temp_file
90
-item_num=0
91
-cat $temp_file | while IFS='' read -r CUR_LINE
92
-do 
93
-    item_num=$(($item_num+1))
94
-    # These tags trip up 'title=' and '" >' queries later on. Strip 'em.
95
-    LINE="$(echo $CUR_LINE | sed 's/<span class=\"yt-badge \" >.*//')"
96
-    LINE="$(echo $LINE | sed 's/views<\/li>.*//')"
97
-    LINE="$(echo $LINE | sed 's/title="Verified"//')"
98
-
99
-    if [ $row -eq 1 ]
100
-    then
101
-        #color='\033[1;34m'
102
-        #color2='\033[1;34m'
103
-        printf '\033[1;34m'
104
-        row=0
105
-    elif [ $row -eq 0 ]
106
-    then
107
-        #color='\033[1;31m'
108
-        #color2='\033[1;31m'
109
-        printf '\033[1;31m'
110
-        row=1
111
-    fi
112
-
113
-    if echo "$LINE" | grep "View full playlist" > /dev/null
114
-    then
115
-        type="Playlist"
116
-        title=$(echo "$LINE" | sed 's/.*title="//' | sed 's/".*//')
117
-        items=$(echo "$LINE" | sed 's/.*View full playlist (//' | sed 's/).*//')
118
-        itemid=$(echo "$LINE" | sed 's/.*&amp;list=//' | sed 's/".*//')
119
-        if [ $item_num -ge $((results+1)) ]
120
-        then
121
-            break
122
-        elif [ $item_num -lt 10 ]
123
-        then
124
-            printf '%s.  ' "$item_num"
125
-        else
126
-            printf '%s. ' "$item_num"
127
-        fi
128
-        printf '%s\n' "$title"
129
-        printf '    '
130
-        printf '%s | %s | %s\n' "$type" "$items" "$itemid"
131
-    else
132
-        type="Video"
133
-        duration=$(echo "$LINE" | sed 's/.*Duration: //' | sed 's/\..*//')
134
-        itemid=$(echo "$LINE" | sed 's/.*<a href="\/watch?v=//' | sed 's/".*//')
135
-        title=$(echo "$LINE" | sed 's/.* title="//' | sed 's/".*//')
136
-        if echo "$LINE" | grep /channel/ > /dev/null
137
-        then
138
-            # For /channel/ users
139
-            author=$(echo "$LINE" | sed 's/.*" >//' | sed 's/<\/a>.*//')
140
-        else
141
-            # For /user/ users
142
-            author=$(echo "$LINE" | sed 's/.*\/user\///' | sed 's/".*//')
143
-        fi
144
-
145
-        if [ $item_num -ge $((results+1)) ]
146
-        then
147
-            break
148
-        elif [ $item_num -lt 10 ]
149
-        then
150
-            printf '%s.  ' "$item_num"
151
-        else
152
-            printf '%s. ' "$item_num"
153
-        fi
154
-        printf '%s\n' "$title"
155
-        printf '    '
156
-    i=0
157
-    while [ $i -lt 16 ]
158
-    do
159
-        i=$((i+1))
160
-        char=$(echo $author | cut -c$i)
161
-        if [ -z $char ]
162
-        then
163
-            printf ' '
164
-        else
165
-            printf '%s' "$char"
166
-        fi
167
-    done
168
-    printf ' | '
169
-    i=0
170
-    while [ $i -lt 5 ]
171
-    do
172
-        i=$((i+1))
173
-        char=$(echo $duration | cut -c$i)
174
-        if [ -z $char ]
175
-        then
176
-            printf ' '
177
-        else
178
-            printf '%s' "$char"
179
-        fi
180
-    done
181
-    printf ' | %s\n' "$itemid"
182
-    fi
183
-done
184
-
185
-printf '\033[0m'
186
-
187
-if [ $interactive_mode -eq 1 ]
188
-then
189
-    get_input
190
-fi
191 0
deleted file mode 100755
... ...
@@ -1,229 +0,0 @@
1
-#!/bin/sh
2
-
3
-####################
4
-# Name: shelltube.sh
5
-# Lisc: ISC
6
-# Main: jadedctrl
7
-# Desc: Full-shell YT client that avoids the YT API.
8
-  Vers=0.5.2
9
-#####################
10
-
11
-# Roadmap 1.0:
12
-#   yt-meta:
13
-#        [X] Args for specific info
14
-#        [X] Better argument handling
15
-#   yt-playlist:
16
-#        [X] Playlist support
17
-#        [ ] Better argument handling
18
-#   yt-channel:
19
-#        [X] Channel support
20
-#        [ ] Better argument handling
21
-#   yt-search:
22
-#        [|] Channel & Playlist search
23
-#        [ ] Search filters
24
-#        [ ] Better argument handling
25
-#   general:
26
-#        [|] Config video player, etc
27
-#        [|] Cli args as commands
28
-
29
-
30
-if [ -e "$HOME/.config/shelltube" ]
31
-then
32
-    . "$HOME/.config/shelltube"
33
-fi
34
-
35
-if [ -e "./lib/yt-meta" ]
36
-then
37
-    alias yt-channel="./lib/yt-channel"
38
-    alias yt-meta="./lib/yt-meta"
39
-    alias yt-playlist="./lib/yt-playlist"
40
-    alias yt-search="./lib/yt-search"
41
-    alias yt-down="./lib/yt-down"
42
-    alias st-download="./lib/st-download"
43
-    alias st-video="./lib/st-video"
44
-fi
45
-
46
-search() {
47
-    output="$(mktemp -u /tmp/yt_XXXXXX)"
48
-    yt-search -i "$1" "$output"
49
-    if sed -n ${1}p "$output" | grep "^PL" > /dev/null
50
-    then
51
-        playlist "$(sed -n ${1}p "$output")"
52
-    else
53
-        selected_video="$(sed -n ${1}p "$output")"
54
-        yt-meta "$selected_video"
55
-    fi
56
-}
57
-
58
-playlist() {
59
-    output="$(mktemp -u /tmp/yt_XXXXXX)"
60
-    yt-playlist -i "$1" "$output"
61
-    selected_video="$(sed -n ${1}p "$output")"
62
-    yt-meta "$selected_video"
63
-}
64
-
65
-channel() {
66
-    output="$(mktemp -u /tmp/yt-channel_XXXXXX)"
67
-    case "$1" in
68
-    UC* )
69
-        yt-channel -ic "$1" "$output"
70
-        ;;
71
-    * )
72
-        yt-channel -iu "$1" "$output"
73
-        ;;
74
-    esac
75
-    selected_video="$(sed -n 1p "$output")"
76
-    yt-meta "$selected_video"
77
-}
78
-
79
-about() {
80
-    printf '\n \033[1mshell\033[41m Tube \033[0;1;30m v%s\033[m\n\n' "$Vers"
81
-    printf '\033[32mDesc: \033[0;34mYT client written in shell.\033[m\n'
82
-    printf '\033[32mMain: \033[0;34mjadedml@openmailbox.org\033[m\n'
83
-    printf '\033[32mLisc: \033[0;34mISC; yt-down GPLv2\033[m\n'
84
-}
85
-
86
-help() {
87
-    printf "\
88
-about    | !        View the about page.
89
-clear    | cls      Clear the screen.
90
-download | dl       Download the selected video.
91
-exit     | ctrl+c   Exit Shelltube.
92
-help     | ?        Display this message.
93
-metadata | md       Display selected video's metadata.
94
-playlist | //       Display a playlist's videos.
95
-search   | /        Perform a search.
96
-channel  | chan     Show newest videos of a channel.
97
-stream   | str      Stream the selected video.
98
-video | sel | url   Select video based on URL or ID.
99
-queue    | lq       List videos in the queue.
100
-squeue   | sq       Stream all videos in the queue.
101
-dqueue   | dq       Download all videos in the queue.
102
-
103
-Note about usage:
104
-Both 'video ID; download' and 'download ID' are valid.  You don't need to
105
-select a video to run commands on it, but if you use metadata, download, or
106
-stream on an unselected video you must specify the ID or URL after the command.
107
-"
108
-}
109
-
110
-parse() {
111
-    command="$1" argument="$2"
112
-
113
-    case "$command" in
114
-    help | '?' )
115
-        help
116
-        ;;
117
-    playlist )
118
-        playlist "$argument"
119
-        ;;
120
-    //* )
121
-        playlist "${command#//}"
122
-        ;;
123
-    search )
124
-        search "$argument"
125
-        ;;
126
-    /* )
127
-        search "${command#/} $argument"
128
-        ;;
129
-    channel )
130
-        channel "$argument"
131
-        ;;
132
-    chan )
133
-        channel "$argument"
134
-        ;;
135
-    video | sel | url )
136
-        case "$argument" in
137
-        *youtube.com* )
138
-            selected_video="$argument"
139
-            ;;
140
-        *)
141
-            selected_video="$argument"
142
-            ;;
143
-        esac
144
-        yt-meta "$selected_video"
145
-        ;;
146
-    metadata | md )
147
-        selected_video="${argument:-$selected_video}"
148
-        yt-meta "$selected_video"
149
-        ;;
150
-    download | dl )
151
-        selected_video="${argument:-$selected_video}"
152
-        yt-down "$selected_video"
153
-        ;;
154
-    stream | str )
155
-        selected_video="${argument:-$selected_video}"
156
-        yt-down -s "$selected_video"
157
-        ;;
158
-    queue | lq )
159
-        cat /tmp/yt-queue | while IFS='' read -r CUR_LINE
160
-        do
161
-            if [ $row -eq 1 ]
162
-            then
163
-                printf '\033[1;34m%s\n' "$CUR_LINE"
164
-                row=0
165
-            else
166
-                printf '\033[1;31m%s\n' "$CUR_LINE"
167
-                row=1
168
-            fi
169
-        done
170
-        ;;
171
-    cqueue | cq )
172
-        rm /tmp/yt-queue
173
-        touch /tmp/yt-queue
174
-        ;;
175
-    dqueue | dq )
176
-        for LINE in $(cat /tmp/yt-queue)
177
-        do
178
-            itemid="$(echo "$LINE" | sed 's/.*\|  //')"
179
-            echo $itemid
180
-            sleep 3
181
-            yt-down -D "$itemid"
182
-            grep -v "$itemid" /tmp/yt-queue > /tmp/yt-queue.tmp
183
-            mv /tmp/yt-queue.tmp /tmp/yt-queue
184
-        done
185
-        ;;
186
-    squeue | sq )
187
-        for LINE in $(cat /tmp/yt-queue)
188
-        do
189
-            itemid="$(echo "$LINE" | sed 's/.*|  //')"
190
-            echo $itemid
191
-            sleep 3
192
-            yt-down -S "$itemid"
193
-            grep -v "$itemid" /tmp/yt-queue > /tmp/yt-queue.tmp
194
-            mv /tmp/yt-queue.tmp /tmp/yt-queue
195
-        done
196
-        ;;
197
-    about | ! )
198
-        about
199
-        ;;
200
-    clear | cls )
201
-        printf '\033[H\033[J'
202
-        ;;
203
-    exit )
204
-        rm -f "/tmp/yt-$$"
205
-        exit
206
-        ;;
207
-    '' ) ;;
208
-    * )
209
-        echo "Unknown command: \"$command\""
210
-        echo "Try \"help\" or \"?\""
211
-        ;;
212
-    esac
213
-}
214
-
215
-if [ "$#" -gt 0 ]
216
-then
217
-    for arg in "$@"
218
-    do
219
-        parse "${arg%% *}" "${arg#* }"
220
-    done
221
-else
222
-    printf '\n \033[1mshell\033[41m Tube \033[0;1;30m v%s\033[m\n\n' "$Vers"
223
-
224
-    while printf '\033[0;34m%s \033[0;32m>>\033[m ' "$selected_video"
225
-    do
226
-        read -r command argument
227
-        parse "$command" "$argument"
228
-    done
229
-fi