Better arg handling yt-meta
This commit is contained in:
parent
5dc05242f5
commit
7e8764ddb8
71
lib/yt-meta
71
lib/yt-meta
|
@ -15,35 +15,45 @@ 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))
|
||||
;;
|
||||
*)
|
||||
if echo $argument | grep "^-" > /dev/null
|
||||
then
|
||||
charcount=$(echo "$argument" | echo "$(wc -c) - 1" | bc)
|
||||
while [ $charcount -gt 0 ]
|
||||
do
|
||||
character=$(echo "$argument" | head -c1)
|
||||
argument=$(echo "$argument" | sed 's/^.//')
|
||||
case $character 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)) ;;
|
||||
i)
|
||||
options="$options i"
|
||||
optnum=$((optnum+1)) ;;
|
||||
-) ;;
|
||||
esac
|
||||
charcount=$((charcount-1))
|
||||
done
|
||||
else
|
||||
preid="$argument"
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
if echo "$preid" | grep "youtube.com"
|
||||
|
||||
if echo "$preid" | grep "youtube.com" > /dev/null
|
||||
then
|
||||
id="$(echo $1 | sed 's/.*video_id=//')"
|
||||
id="$(echo $preid | sed 's/.*v=//')"
|
||||
elif [ -z $preid ]
|
||||
then
|
||||
echo "No video specified."
|
||||
|
@ -81,8 +91,11 @@ author="$(grep "\"author\":\"" $video_file | sed 's/.*"author":"//' | sed 's/".*
|
|||
views="$(grep "\"view_count\":\"" $video_file | sed 's/.*"view_count":"//' | sed 's/".*//')"
|
||||
duration="$(grep "<a href=\"/watch?v=$1" $video_file.1 | sed 's/.*Duration: //' | sed 's/\..*//')"
|
||||
date="$(grep "datePublished" $video_file | sed 's/.*"datePublished" content="//' | sed 's/".*//')"
|
||||
echo "$title"
|
||||
echo "$author | $views | $duration | $date | $1"
|
||||
|
||||
if [ $optnum -eq 0 ]
|
||||
then
|
||||
echo "$author | $views | $duration | $date | $id"
|
||||
fi
|
||||
|
||||
for option in $options
|
||||
do
|
||||
|
@ -92,11 +105,13 @@ do
|
|||
d) printf "$duration" ;;
|
||||
D) printf "$date" ;;
|
||||
v) printf "$views" ;;
|
||||
i) printf "$id" ;;
|
||||
esac
|
||||
if [ $optnum -ge 2 ]
|
||||
then
|
||||
printf " | "
|
||||
optnum=$((optnum-1))
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
done
|
||||
cp $video_file /tmp/mateo
|
||||
|
|
48
shelltube
48
shelltube
|
@ -5,20 +5,27 @@
|
|||
# Lisc: ISC
|
||||
# Main: jadedctrl
|
||||
# Desc: Full-shell YT client that avoids the YT API.
|
||||
Vers=0.5.1
|
||||
Vers=0.5.2
|
||||
#####################
|
||||
|
||||
# Roadmap:
|
||||
# v1.0 - [X] Playlist support
|
||||
# Roadmap 1.0:
|
||||
# yt-meta:
|
||||
# [X] Args for specific info
|
||||
# [X] Better argument handling
|
||||
# yt-playlist:
|
||||
# [X] Playlist support
|
||||
# [ ] Better argument handling
|
||||
# yt-channel:
|
||||
# [X] Channel support
|
||||
# [ ] Audio dl/stream
|
||||
# [ ] Show related videos
|
||||
# [ ] Better argument handling
|
||||
# yt-search:
|
||||
# [|] Channel & Playlist search
|
||||
# [ ] Search filters
|
||||
# [ ] Search & Channel sort-by
|
||||
# [X] Config video player, etc
|
||||
# [ ] Overall better interface
|
||||
# [x] Cli args as commands
|
||||
# [ ] Better argument handling
|
||||
# general:
|
||||
# [|] Config video player, etc
|
||||
# [|] Cli args as commands
|
||||
|
||||
|
||||
if [ -e "$HOME/.config/shelltube" ]
|
||||
then
|
||||
|
@ -151,7 +158,14 @@ parse() {
|
|||
queue | lq )
|
||||
cat /tmp/yt-queue | while IFS='' read -r CUR_LINE
|
||||
do
|
||||
yt-meta "$CUR_LINE"
|
||||
if [ $row -eq 1 ]
|
||||
then
|
||||
printf '\033[1;34m%s\n' "$CUR_LINE"
|
||||
row=0
|
||||
else
|
||||
printf '\033[1;31m%s\n' "$CUR_LINE"
|
||||
row=1
|
||||
fi
|
||||
done
|
||||
;;
|
||||
cqueue | cq )
|
||||
|
@ -161,16 +175,22 @@ parse() {
|
|||
dqueue | dq )
|
||||
for LINE in $(cat /tmp/yt-queue)
|
||||
do
|
||||
yt-down -D "$LINE"
|
||||
grep -v "$LINE" /tmp/yt-queue > /tmp/yt-queue.tmp
|
||||
itemid="$(echo "$LINE" | sed 's/.*\| //')"
|
||||
echo $itemid
|
||||
sleep 3
|
||||
yt-down -D "$itemid"
|
||||
grep -v "$itemid" /tmp/yt-queue > /tmp/yt-queue.tmp
|
||||
mv /tmp/yt-queue.tmp /tmp/yt-queue
|
||||
done
|
||||
;;
|
||||
squeue | sq )
|
||||
for LINE in $(cat /tmp/yt-queue)
|
||||
do
|
||||
yt-down -S "$LINE"
|
||||
grep -v "$LINE" /tmp/yt-queue > /tmp/yt-queue.tmp
|
||||
itemid="$(echo "$LINE" | sed 's/.*| //')"
|
||||
echo $itemid
|
||||
sleep 3
|
||||
yt-down -S "$itemid"
|
||||
grep -v "$itemid" /tmp/yt-queue > /tmp/yt-queue.tmp
|
||||
mv /tmp/yt-queue.tmp /tmp/yt-queue
|
||||
done
|
||||
;;
|
||||
|
|
Reference in New Issue