From 10b93638d61487ef1297b5970e3de707c84506aa Mon Sep 17 00:00:00 2001 From: inigoortega Date: Sun, 29 Mar 2020 16:56:08 +0200 Subject: [PATCH] scripts changes --- scripts/select-videos-to-watch.sh | 1 + scripts/watch-last-videos-from-subs.sh | 20 +++++++---- scripts/watch-select-twitch.sh | 2 +- termscripts/channel-videos-after.sh | 2 -- termscripts/kernel-update.sh | 46 +++++++++++++++----------- termscripts/play-videos-from-file.sh | 2 +- 6 files changed, 43 insertions(+), 30 deletions(-) diff --git a/scripts/select-videos-to-watch.sh b/scripts/select-videos-to-watch.sh index 5a615b4..9f0f8eb 100644 --- a/scripts/select-videos-to-watch.sh +++ b/scripts/select-videos-to-watch.sh @@ -26,6 +26,7 @@ do if [ -n "$link" -a -z "$(printf "%b\n" "$links" | grep "$link")" ]; then links="$links\n$link" fi + echo "$link" done # Get first link and download diff --git a/scripts/watch-last-videos-from-subs.sh b/scripts/watch-last-videos-from-subs.sh index 544a218..7e9c0ae 100644 --- a/scripts/watch-last-videos-from-subs.sh +++ b/scripts/watch-last-videos-from-subs.sh @@ -32,7 +32,7 @@ while getopts ":uf:" option; do done shift $((OPTIND-1)) -videos_file="/tmp/wlvfs_videos" +videos_file="$HOME/.local/share/wlvfs_videos" if [ -z "$subs_file" ]; then if [ -z "$YT_SUBS" ]; then @@ -94,28 +94,34 @@ fi # Processing + rm $videos_file 2> /dev/null - grep -vE '^#|^$|^!' "$subs_file" | sort -rg -k 4 -k 3 -k 5 | while read line; do + grep -vE '^#|^$|^!' "$subs_file" | sort -rg -k 5 -k 4 -k 3 | while read line; do channel=$(echo "$line" | awk '{print $1}') last_video=$(echo "$line" | awk '{print $2}') upload_frequency=$(echo "$line" | awk '{print $3}') prev_upload_frequency=$(echo "$line" | awk '{print $4}') + manual_preference=$(echo "$line" | awk '{print $5}') - echo "Processing: $channel on Preference: $prev_upload_frequency" + echo "Processing: $channel on Preference: $manual_preference - $prev_upload_frequency" temp="/tmp/wlvfs" - dash termscripts/channel-videos-after.sh \ - "https://invidio.us/channel/$channel" "$last_video" | tee "$temp" | \ + dash $TSCRIPTS/channel-videos-after.sh "https://youtube.com/channel/$channel" "$last_video" | tee "$temp" | \ while read video; do printf "\tFound video: %s\n" "$video" if [ ! -f "$videos_file" ]; then echo "ytdl://$video" >> $videos_file if [ -z "$play_at_the_end" ]; then - (dash termscripts/play-videos-from-file.sh "$videos_file"&& \ - rm "$videos_file") & + (dash $TSCRIPTS/play-videos-from-file.sh "$videos_file"&& + rm "$videos_file") & fi else echo "ytdl://$video" >> $videos_file + { + sleep 5 + [ ! -f "$videos_file" ] && echo "ytdl://$video" >> \ + $videos_file + } & fi done new_last_video=$(head -n 1 "$temp") diff --git a/scripts/watch-select-twitch.sh b/scripts/watch-select-twitch.sh index 9934ca8..f1fb4a5 100644 --- a/scripts/watch-select-twitch.sh +++ b/scripts/watch-select-twitch.sh @@ -2,4 +2,4 @@ watch="$(cat $FAV_STREAMERS | rofi -dmenu -matching fuzzy)" -[ -n "$watch" ] && mpv "https://www.twitch.tv/$watch" +[ -n "$watch" ] && $VIDEOPLAYER "https://www.twitch.tv/$watch" diff --git a/termscripts/channel-videos-after.sh b/termscripts/channel-videos-after.sh index 8174a5c..265737e 100644 --- a/termscripts/channel-videos-after.sh +++ b/termscripts/channel-videos-after.sh @@ -3,8 +3,6 @@ channel="$1" last_watched_video="$2" -videos="" - youtube-dl --get-id "$channel" 2>/dev/null | while read line && [ "$line" != "$last_watched_video" ]; do echo "$line" diff --git a/termscripts/kernel-update.sh b/termscripts/kernel-update.sh index 4f29e4e..1132a41 100644 --- a/termscripts/kernel-update.sh +++ b/termscripts/kernel-update.sh @@ -1,25 +1,33 @@ #!/usr/bin/env sh +update_kernel () { + emerge -v --update --deep --with-bdeps=y --newuse \ + sys-kernel/gentoo-sources && + + next_number="$(($(eselect kernel list | wc -l) - 1))" && + + echo "New kernel: $(eselect kernel list | tail -n 1)" && + + eselect kernel set $next_number && + + cp $old_config /usr/src/linux/.config && + + cd /usr/src/linux && + + make syncconfig && + make modules_prepare && + emerge -v @module-rebuild && + make -j2 && + make modules_install && + make install && + + grub-mkconfig -o /grub/libreboot_grub.cfg +} + old_config="$KERNEL_CONFIGS/kernel-config-`uname -r`" && cp /usr/src/linux/.config $old_config && -emerge -v --update --deep --with-bdeps=y --newuse \ - sys-kernel/gentoo-sources && - -next_number="$(($(eselect kernel list | wc -l) - 1))" && - -eselect kernel set $next_number && - -cp $old_config /usr/src/linux/.config && - -cd /usr/src/linux && - -make syncconfig && -make modules_prepare && -emerge -v @module-rebuild && -make -j2 && -make modules_install && -make install && - -grub-mkconfig -o /grub/libreboot_grub.cfg +export old_config +export -f update_kernel +su -c update_kernel diff --git a/termscripts/play-videos-from-file.sh b/termscripts/play-videos-from-file.sh index 861a219..a1c06a9 100644 --- a/termscripts/play-videos-from-file.sh +++ b/termscripts/play-videos-from-file.sh @@ -11,7 +11,7 @@ do video="$(sed "$current_video q;d" "$1")" - dash -c "$VIDEOPLAYER '$video'" + $VIDEOPLAYER "$video" length="$(wc -l "$1" | awk '{print $1}')" # if [ "$length" -eq "$current_video" ]; then