New scripts for subs on yt and updates

This commit is contained in:
inigoortega 2020-03-08 13:32:21 +01:00
parent c501ea1cfc
commit 8946366a22
8 changed files with 100 additions and 9 deletions

View File

@ -4,4 +4,4 @@
[ "$url" = "" ] && notify-send "Tube.sh" "Nothing will be downloaded" && exit 0
mpv $MPV_FLAGS "$url"
$VIDEOPLAYER "$url"

View File

@ -8,4 +8,4 @@ xdotool key ctrl+c
# link="$(xclip -o -selection clipboard | sed -E 's|([^&]*)(&)(.*)|\1|')"
link="$(xclip -o | sed -E 's|([^&]*)(&)(.*)|\1|')"
mpv $MPV_FLAGS "$link"
$VIDEOPLAYER "$link"

View File

@ -0,0 +1,74 @@
#!/usr/bin/env sh
videos_file="/tmp/wlvfs_videos"
grep -vE '^#|^$' yt-subs | 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}')
if [ -z "$prev_upload_frequency" ]; then
echo "Preprocessing: $channel"
if [ -z "$last_video" ] || [ "$last_video" = "-" ]; then
new_last_video=$(youtube-dl --get-id \
"https://invidio.us/channel/$channel" 2>/dev/null \
| head -n 1)
[ -z "$new_last_video" ] && new_last_video="-"
new_upload_frequency=0
new_prev_upload_frequency=0
elif [ -z "$upload_frequency" ]; then
new_last_video="$last_video"
new_upload_frequency=0
new_prev_upload_frequency=0
else
new_last_video="$last_video"
new_upload_frequency="$upload_frequency"
new_prev_upload_frequency=0
fi
sed -E \
"s|($channel)(\t$last_video)?(\t$upload_frequency)?(\t$prev_upload_frequency)?|$channel\t$new_last_video\t$new_upload_frequency\t$new_prev_upload_frequency|" \
yt-subs -i
fi
done
grep -vE '^#|^$' yt-subs | sed -E 's|([^\t]+)(\t)([^\t]+)(\t)([^\t]+)(\t)([^\t]+)|\7\t\1\t\3\t\5|g' | sort -rg | while read line; do
channel=$(echo "$line" | awk '{print $2}')
last_video=$(echo "$line" | awk '{print $3}')
prev_upload_frequency=$(echo "$line" | awk '{print $1}')
upload_frequency=$(echo "$line" | awk '{print $4}')
echo "Processing: $channel"
temp="/tmp/wlvfs"
dash termscripts/channel-videos-after.sh \
"https://invidio.us/channel/$channel" "$last_video" | tee "$temp" | \
while read video; do
# $VIDEOPLAYER "ytdl://$video"
if [ ! -f "$videos_file" ]; then
printf "\tFound video: %s\n" "$video"
echo "ytdl://$video" >> $videos_file
(dash termscripts/play-videos-from-file.sh "$videos_file" && \
rm "$videos_file") &
else
echo "ytdl://$video" >> $videos_file
fi
done
new_last_video=$(head -n 1 "$temp")
[ -z "$new_last_video" ] && new_last_video="$last_video"
new_upload_frequency=$(( $(wc -l "$temp" | awk '{print $1}') + $upload_frequency ))
if [ $(( $(date +%V) % 3 )) -eq 0 ]; then
sed \
"s|$channel\t$last_video\t$upload_frequency\t$prev_upload_frequency|$channel\t$new_last_video\t0\t$new_upload_frequency|" \
yt-subs -i
else
sed \
"s|$channel\t$last_video\t$upload_frequency\t$prev_upload_frequency|$channel\t$new_last_video\t$new_upload_frequency\t$prev_upload_frequency|" \
yt-subs -i
fi
done

View File

@ -5,7 +5,7 @@ streamer="$(rofi -dmenu)"
if [ -n "$streamer" ]; then
if [ "$(youtube-dl -e "https://www.twitch.tv/$streamer" 2>/dev/null)" ]; then
notify-send "$streamer found"
mpv $MPV_FLAGS "https://www.twitch.tv/$streamer"
$VIDEOPLAYER "https://www.twitch.tv/$streamer"
else
notify-send "$streamer NOT FOUND or NOT STREAMING"
fi

View File

@ -25,4 +25,4 @@ else
fi
[ -n "$watch" ] && mpv $MPV_FLAGS "https://www.twitch.tv/$watch"
[ -n "$watch" ] && $VIDEOPLAYER "https://www.twitch.tv/$watch"

View File

@ -8,7 +8,7 @@ if [ -n "$search" ]; then
link="https://invidio.us/watch?v=$id"
mpv $MPV_FLAGS "$link" 1>&2
$VIDEOPLAYER "$link" 1>&2
printf "%b\n" "$link"

View File

@ -0,0 +1,17 @@
#!/usr/bin/env sh
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"
done
# youtube-dl --get-id "$channel" | grep -B 4 "$last_watched_video" | tee /home/initega/test/test -a &
# child_pid=$!
# echo test/test | entr -p kill $child_pid

View File

@ -11,10 +11,10 @@ do
video="$(sed "$current_video q;d" "$1")"
mpv $MPV_FLAGS "$video"
$VIDEOPLAYER "$video"
length="$(wc -l "$1" | awk '{print $1}')"
if [ "$length" -eq "$current_video" ]; then
sleep 5m
fi
# if [ "$length" -eq "$current_video" ]; then
# sleep 5m
# fi
done