update invcli and modem-manager

This commit is contained in:
Mid Favila 2021-12-24 11:42:30 -04:00
parent 3dbe769423
commit b6f6640a83
2 changed files with 14 additions and 5 deletions

17
invcli
View File

@ -6,9 +6,11 @@ search()
query_sanitized="$(printf "%s\n" "$1"|sed -e 's/ */%20/g')" query_sanitized="$(printf "%s\n" "$1"|sed -e 's/ */%20/g')"
curl --output /tmp/invidious_results "https://vid.puffyan.us/search?q=$query_sanitized" curl --output /tmp/invidious_results "https://vid.puffyan.us/search?q=$query_sanitized"
} }
extract_names() extract_names()
{ {
sed -ne 's/<p dir.*>\(.*\)<\/p>/\1/p' /tmp/invidious_results|sed 's/ *//' viable=$(grep watch /tmp/invidious_results|grep youtube|expr $(wc -l) - 1)
sed -ne 's/<p dir.*>\(.*\)<\/p>/\1/p' /tmp/invidious_results|sed -ne 's/ *//' -e '/^$/d' -e p|sed ${viable}q
} }
extract_urls() extract_urls()
@ -21,7 +23,7 @@ extract_urls()
watch_vid() watch_vid()
{ {
curl -v "https://vid.puffyan.us/latest_version?id=$id&itag=$itag" 2>>/dev/stdout|sed -ne 's/< Location: \(.*\)/\1/p' ffplay "https://vid.puffyan.us/latest_version?id=$id&itag=$itag" 2>>/dev/stdout|sed -ne 's/< Location: \(.*\)/\1/p'
} }
fetch_itag() fetch_itag()
@ -37,12 +39,18 @@ fetch_id()
generate_locations() generate_locations()
{ {
for itag in 22 #$(fetch_itag $(extract_urls|sed $chosen_video!d)|sed $chosen_video!d) # 18 is for 360p, 22 is for 720p
for itag in 18 #$(fetch_itag $(extract_urls|sed $chosen_video!d)|sed $chosen_video!d)
do do
watch_vid watch_vid
done done
} }
#Use this snippet to only retrieve URLs that are actually in the results...
#grep 'watch?v=' /tmp/invidious_results|grep youtube
#
#Hopefully this is the key to fixing the weird interactions between extract_names and fetch_itag
main() main()
{ {
printf "Enter your search terms: " printf "Enter your search terms: "
@ -54,11 +62,12 @@ main()
printf "Attempting to retrieve primary source for: " printf "Attempting to retrieve primary source for: "
printf "\"%s\"" "$(extract_names|sed $chosen_video!d)" printf "\"%s\"" "$(extract_names|sed $chosen_video!d)"
printf "...\nPlease wait.\n\n" printf "...\nPlease wait.\n\n"
chosen_video=$(expr $chosen_video - 1)
itag=$(echo $(fetch_itag $(extract_urls|sed $chosen_video!d))|cut -f$chosen_video -d' ') itag=$(echo $(fetch_itag $(extract_urls|sed $chosen_video!d))|cut -f$chosen_video -d' ')
id=$(fetch_id) id=$(fetch_id)
media="$(generate_locations|sed 1!d)" media="$(generate_locations|sed 1!d)"
printf "Loading %s...\n" "$media" printf "Loading %s...\n" "$media"
ffplay -autoexit "$media" # ffplay -autoexit "$media"
} }
main main

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# We need root to configure interface properties. # We need root to configure interface properties.
if [ "${USER}" != root ] if [ "$(whoami)" != root ]
then printf "We need root!\n" then printf "We need root!\n"
exit exit
else else