Skip to content

Commit

Permalink
Merge pull request #1646 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Mar 31, 2024
2 parents 88d0552 + c2de47d commit 1218719
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 73 deletions.
8 changes: 2 additions & 6 deletions srv/http/assets/js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,12 +1189,8 @@ function renderLibraryCounts() {
var $this = $( el );
var mode = $this.data( 'mode' );
var v = C[ mode ];
if ( v ) {
$this.removeClass( 'nodata' );
if ( ! [ 'nas', 'sd', 'usb' ].includes( mode ) ) $( '#mode-'+ mode ).find( 'gr' ).html( v ? v.toLocaleString() : '' );
} else {
$this.addClass( 'nodata' );
}
$this.toggleClass( 'nodata', ! v );
if ( typeof v !== 'boolean' ) $( '#mode-'+ mode ).find( 'gr' ).html( v ? v.toLocaleString() : '' );
} );
if ( D.albumyear ) $( '#mode-album' ).find( 'gr' ).html( C.albumyear.toLocaleString() );
}
Expand Down
4 changes: 2 additions & 2 deletions srv/http/bash/albumthumbnail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo Path: '<a class="cc">'$fullpath'</a>'
echo

[[ ! -w "$fullpath" ]] && warningWrite "$fullpath" && exit

# --------------------------------------------------------------------
SECONDS=0

albumfile=/srv/http/data/mpd/album
Expand All @@ -31,7 +31,7 @@ fi
unsharp=0x.5

[[ ! $mpdpathlist ]] && echo "$padw No albums found in database." && exit

# --------------------------------------------------------------------
count=$( wc -l <<< $mpdpathlist )
while read mpdpath; do
(( i++ ))
Expand Down
8 changes: 4 additions & 4 deletions srv/http/bash/audiocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
. /srv/http/bash/common.sh

[[ -e $dirshm/eject ]] && exit

# --------------------------------------------------------------------
if [[ $1 == on ]]; then
notify audiocd 'Audio CD' 'USB CD On'
touch $dirshm/audiocd
ln -s $dirmpdconf/{conf/,}cdio.conf
systemctl restart mpd
pushRefresh player
exit
# --------------------------------------------------------------------
fi

audioCDplClear

if [[ $1 == eject || $1 == off || $1 == ejecticonclick ]]; then # eject/off : remove tracks from playlist
Expand All @@ -29,14 +29,14 @@ if [[ $1 == eject || $1 == off || $1 == ejecticonclick ]]; then # eject/off : re
pushData audiocd '{ "type": "clear" }'
pushRefresh player
exit
# --------------------------------------------------------------------
fi

cddiscid=( $( cd-discid 2> /dev/null ) ) # ( discid total_tracks offset0(lead-in) offset1(track1) ... total_seconds(last track) )
if [[ ! $cddiscid ]]; then
notify audiocd 'Audio CD' 'CD contains no tracks length'
exit
# --------------------------------------------------------------------
fi

discid=${cddiscid[0]}
trackL=${cddiscid[1]} # also = offset last index (offsets: +1 lead-in)

Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/cmd-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ if [[ $song == 0 ]]; then
done
updateDone
exit
# --------------------------------------------------------------------
fi

##### album
albumList() {
mpclistall=$( mpc -f '%album%^^[%albumartist%|%artist%]^^%date%^^%file%' listall 2> /dev/null ) # include no album tag
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/cmd-skipdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [[ 'http rtmp rtp: rtsp' =~ ${fileheader,,} ]]; then
urlname=${file//\//|}
path=$( find $dirwebradio -name $urlname )
[[ ! $path ]] && exit
# --------------------------------------------------------------------
readarray -t station_sampling < "$path"
station=${station_sampling[0]}
sampling=${station_sampling[1]}
Expand Down
47 changes: 28 additions & 19 deletions srv/http/bash/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,22 @@ webradioM3uPlsVerify() {
url=$( curl -s $url 2> /dev/null | grep -m1 ^File | cut -d= -f2 )
fi
[[ ! $url ]] && echo 'No valid URL found in:'$url && exit
# --------------------------------------------------------------------
}
webRadioSampling() {
local bitrate data file kb rate sample samplerate url
url=$1
file=$2
timeout 3 curl -sL $url -o /tmp/webradio
[[ ! $( awk NF /tmp/webradio ) ]] && echo 'Cannot be streamed:' && exit
# --------------------------------------------------------------------
data=( $( ffprobe -v quiet -select_streams a:0 \
-show_entries stream=sample_rate \
-show_entries format=bit_rate \
-of default=noprint_wrappers=1:nokey=1 \
/tmp/webradio ) )
[[ ! $data ]] && 'No stream data found:' && exit
# --------------------------------------------------------------------
samplerate=${data[0]}
bitrate=${data[1]}
sample="$( calc 1 $samplerate/1000 ) kHz"
Expand All @@ -228,7 +229,7 @@ albumignore )
bookmarkadd )
bkfile="$dirbookmarks/${NAME//\//|}"
[[ -e $bkfile ]] && echo -1 && exit
# --------------------------------------------------------------------
echo "$DIR" > "$bkfile"
if [[ -e $dirsystem/order.json ]]; then
order=$( jq '. + ["'$DIR'"]' $dirsystem/order.json )
Expand Down Expand Up @@ -321,8 +322,8 @@ audiocd
$discid
CMD ARTIST ALBUM MODE DISCID" &> /dev/null &
exit
# --------------------------------------------------------------------
fi

rm -f "$COVERFILE" "$dir/{coverart,thumb}".* $dirshm/{embedded,local}/*
backupfile=$( ls -p "$dir"/*.backup | head -1 )
if [[ -e $backupfile ]]; then
Expand Down Expand Up @@ -367,7 +368,7 @@ display )
[[ -e $dirsystem/vumeter ]] && prevvumeter=1
grep -q -m1 vumeter.*true $dirsystem/display.json && touch $dirsystem/vumeter && vumeter=1
[[ $prevvumeter == $vumeter ]] && exit
# --------------------------------------------------------------------
if [[ $vumeter ]]; then
[[ ! -e $dirmpdconf/fifo.conf ]] && $dirsettings/player-conf.sh
else
Expand Down Expand Up @@ -424,16 +425,20 @@ librandom )
fi
pushData option '{ "librandom": '$TF' }'
;;
librarynas )
mountpoints=$( awk '/.mnt.MPD.NAS/ {print $2}' /etc/fstab \
lsmntmpd )
readarray -t mountpoints <<< $( awk '/.mnt.MPD.NAS/ {print $2}' /etc/fstab \
| grep -v /mnt/MPD/NAS/data \
| sed 's/\\040/ /g' )
dirs=false
for m in "${mountpoints[@]}"; do
if ! grep -qs "$( basename "$m" )" /mnt/MPD/NAS/.mpdignore && timeout 0.1 test -e "$m"; then
echo 1
exit
fi
grep -qs "$( basename "$m" )" /mnt/MPD/NAS/.mpdignore && continue

timeout 0.1 ls "$m" &> /dev/null && dirs=true && break
# --------------------------------------------------------------------
done
[[ $( ls -1d /mnt/MPD/SD/*/ 2> /dev/null ) ]] && dirs+=', true' || dirs+=', false'
[[ $( ls -1d /mnt/MPD/USB/*/ 2> /dev/null ) ]] && dirs+=', true' || dirs+=', false'
echo [ $dirs ]
;;
lyrics )
name="$ARTIST - $TITLE"
Expand All @@ -453,9 +458,9 @@ lyrics )
file="/mnt/MPD/$file"
lyrics=$( kid3-cli -c "select \"$file\"" -c "get lyrics" )
[[ $lyrics ]] && echo "$lyrics" && exit
# --------------------------------------------------------------------
fi
fi

artist=$( sed -E 's/^A |^The |\///g' <<< $ARTIST )
title=${TITLE//\/}
query=$( tr -d " '\-\"\!*\(\);:@&=+$,?#[]." <<< "$artist/$title" )
Expand Down Expand Up @@ -531,7 +536,7 @@ mpcoption )
mpcplayback )
if [[ ! $ACTION ]]; then
! playerActive mpd && playerstop && exit
# --------------------------------------------------------------------
if statePlay; then
grep -q -m1 webradio=true $dirshm/status && ACTION=stop || ACTION=pause
else
Expand All @@ -556,6 +561,7 @@ mpcplayback )
mpc -q $ACTION
fi
[[ ! -e $dirsystem/snapclientserver ]] && exit
# --------------------------------------------------------------------
# snapclient
if [[ $ACTION == play ]]; then
sleep 2 # fix stutter
Expand Down Expand Up @@ -607,7 +613,7 @@ mpcsimilar )
| jq .similartracks.track \
| sed -n '/"name": "/ {s/.*": "\|",$//g; p}' )
[[ ! $lines ]] && echo 'No similar tracks found in database.' && exit
# --------------------------------------------------------------------
while read line; do
if [[ $title ]]; then
file=$( mpc find artist "$line" title "$title" )
Expand All @@ -618,7 +624,7 @@ mpcsimilar )
fi
done <<< $lines
[[ ! $list ]] && echo 'No similar tracks found in Library.' 5000 && exit
# --------------------------------------------------------------------
plLprev=$( mpc status %length% )
awk NF <<< $list | mpc -q add
pushPlaylist
Expand Down Expand Up @@ -675,6 +681,8 @@ mpdignore )
dir=$( basename "$DIR" )
mpdpath=$( dirname "$DIR" )
echo $dir >> "/mnt/MPD/$mpdpath/.mpdignore"
[[ ! $( mpc ls "$mpdpath" 2> /dev/null ) ]] && exit
# --------------------------------------------------------------------
pushData mpdupdate '{ "type": "mpd" }'
echo "$mpdpath" > $dirmpd/updating
mpc -q update "$mpdpath" #1 get .mpdignore into database
Expand Down Expand Up @@ -729,8 +737,8 @@ savedpledit ) # $DATA: remove - file, add - position-file, move - from-to
savedplrename )
if [[ ! $REPLACE ]]; then
mpc lsplaylists | grep -q "$NEWNAME" && echo -1 && exit
# --------------------------------------------------------------------
fi

mpc renplaylist "$NAME" "$NEWNAME"
pushSavedPlaylist
;;
Expand All @@ -741,8 +749,8 @@ savedplsave )
elif [[ -e "$plfile" ]]; then
echo -1
exit
# --------------------------------------------------------------------
fi

mpc -q save "$NAME"
chmod 777 "$plfile"
savedPlCount
Expand Down Expand Up @@ -794,6 +802,7 @@ webradioadd )
[[ $DIR ]] && file+="/$DIR"
file+="/$urlname"
[[ -e $file ]] && echo 'Already exists as <wh>'$( head -1 "$file" )'</wh>:' && exit
# --------------------------------------------------------------------
echo "\
$NAME
Expand Down Expand Up @@ -825,7 +834,7 @@ webradioedit )
sampling=$( sed -n 2p "$prevfile" )
else
[[ -e $newfile ]] && echo 'URL exists:' && exit
# --------------------------------------------------------------------
webradioM3uPlsVerify $NEWURL
rm "$prevfile"
# stationcover
Expand All @@ -850,7 +859,7 @@ $CHARSET" > "$newfile"
wrdirdelete )
file="$dirdata/$MODE/$NAME"
[[ ! $CONFIRM && $( ls -A "$file" ) ]] && echo -1 && exit
# --------------------------------------------------------------------
rm -rf "$file"
webradio=$( find -L $dirwebradio -type f ! -path '*/img/*' | wc -l )
sed -i -E 's/( "webradio": ).*/\1'$webradio'/' $dirmpd/counts
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/dab-scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if ! grep -q ^audioservice $dirshm/dabscan; then
notify dabradio 'DAB Radio' 'No stations found.'
rm $dirshm/{dabscan,updatingdab}
exit
# --------------------------------------------------------------------
fi

mv $dirdabradio/img $dirshm &> /dev/null
rm -rf $dirdabradio
mkdir -p $dirdabradio/img
Expand Down
6 changes: 3 additions & 3 deletions srv/http/bash/lcdchar.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
lcd.write_string( val.replace( '\n', RN ) )
lcd.close()
sys.exit()
# --------------------------------------------------------------------
import math
import time

Expand All @@ -117,7 +117,7 @@ def backlightOff():
lcd.backlight_enabled = False
lcd.close()
sys.exit()
# --------------------------------------------------------------------
def second2hhmmss( sec ):
hh = math.floor( sec / 3600 )
mm = math.floor( ( sec % 3600 ) / 60 )
Expand Down Expand Up @@ -198,7 +198,7 @@ def normalize( str ):
if backlight and state != 'play': backlightOff()

if state != 'play': sys.exit()

# --------------------------------------------------------------------
row = rows - 1
starttime = time.time()
elapsed += round( starttime - timestamp / 1000 )
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/power.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if systemctl -q is-active nfs-server; then # server rAudio
ipclients=$( grep -v $ipserver $filesharedip )
if [[ $ipclients ]]; then
[[ ! $2 ]] && echo -1 && exit # $2 confirm proceed
# --------------------------------------------------------------------
[[ $reboot ]] && msg='Reboot ...' || msg='Power off ...'
for ip in $ipclients; do
notify -ip $ip 'networks blink' 'Server rAudio' "$msg"
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/relays-timer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ while sleep 60; do
else
i=$( < $timerfile )
(( $i == 1 )) && $dirbash/relays.sh off && exit
# --------------------------------------------------------------------
(( i-- ))
echo $i > $timerfile
(( $i > 1 )) && continue
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/settings/system-storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if [[ $nas ]]; then
, "mountpoint" : "'$( stringEscape $mountpoint )'"'
if [[ $used_size ]]; then
list+='
, "mounted" : true
, "mounted" : '$( grep -q " ${mountpoint// /\\\\040} " /proc/mounts && echo true || echo false )'
, "source" : "'$source'"
, "size" : "'${used_size[0]}'B/'${used_size[1]}'B"
}'
Expand Down
4 changes: 2 additions & 2 deletions srv/http/bash/spotifyd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ if ! playerActive spotify; then
echo spotify > $dirshm/player
$dirbash/cmd.sh playerstart
exit
# --------------------------------------------------------------------
fi

[[ $PLAYER_EVENT == volumeset ]] && volumeGet push

dirspotify=$dirshm/spotify
Expand All @@ -39,8 +39,8 @@ else
if [[ ! $token ]]; then
notify spotify Spotify 'Access token renewal failed.'
exit
# --------------------------------------------------------------------
fi

echo $token > $filetoken
echo $(( $( date +%s ) + 3550 )) > $fileexpire # 10s before 3600s
fi
Expand Down
Loading

0 comments on commit 1218719

Please sign in to comment.