Skip to content

Commit

Permalink
Merge pull request #1017 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Sep 9, 2022
2 parents f786b6e + e9c30f6 commit d8d92f0
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 93 deletions.
2 changes: 1 addition & 1 deletion srv/http/assets/js/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ $( '.contextmenu a, .contextmenu .submenu' ).click( function() {
case 'remove':
G.contextmenu = 1;
setTimeout( function() { G.contextmenu = 0 }, 500 );
plRemove( G.list.li );
playlistRemove( G.list.li );
return
case 'savedpladd':
if ( G.playlist ) {
Expand Down
21 changes: 10 additions & 11 deletions srv/http/assets/js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,8 @@ function playlistFilter() {
$( '#pl-search-close' ).empty();
}
}
function plRemove( $li ) {
if ( G.status.pllength === 1 ) {
function playlistRemove( $li ) {
if ( $( '#pl-list li' ).length === 1 ) {
bash( [ 'plremove' ] );
} else {
var total = $( '#pl-time' ).data( 'time' ) - $li.find( '.time' ).data( 'time' );
Expand All @@ -978,22 +978,21 @@ function plRemove( $li ) {
$count.prev().addBack().remove();
}
}
var i = $li.index() + 1;
var poscurent = '';
var pos = $li.index() + 1;
if ( $li.hasClass( 'active' ) ) {
if ( $li.next().is( 'li' ) ) {
var activenext = i;
poscurent = pos;
$li.next().addClass( 'active' );
} else {
var activenext = i - 1;
poscurent = pos - 1;
$li.prev().addClass( 'active' );
}
} else {
var activenext = '';
}
bash( [ 'plremove', i, activenext ] );
$( '#pl-list li .pos' ).slice( i ).each( function() {
$( this ).text( i );
i++
bash( [ 'plremove', pos, poscurent ] );
$( '#pl-list li .pos' ).slice( pos ).each( function() {
$( this ).text( pos );
pos++
} );
$li.remove();
}
Expand Down
7 changes: 2 additions & 5 deletions srv/http/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ $( '#playback' ).click( function() {
switchPage( 'playback' );
}
} );
$( '#playlist' ).click( function() {
$( '#playlist, #button-playlist' ).click( function() {
if ( !G.local ) G.pladd = {}
if ( G.playlist ) {
if ( G.savedlist || G.savedplaylist ) getPlaylist();
Expand Down Expand Up @@ -1770,9 +1770,6 @@ $( '.page' ).on( 'click', '.index a', function() {
$( 'html, body' ).scrollTop( scrollT - ( $( '#bar-top' ).is( ':visible' ) ? 80 : 40 ) );
} );
// PLAYLIST /////////////////////////////////////////////////////////////////////////////////////
$( '#button-playlist' ).click( function() {
$( '#playlist' ).click();
} );
$( '#pl-manage i' ).click( function() {
menuHide();
} );
Expand Down Expand Up @@ -2013,7 +2010,7 @@ $( '#pl-list' ).on( 'click', 'li', function( e ) {
$menu.find( '.wrsave' ).toggleClass( 'hide', !notsaved );
contextmenuScroll( $menu, $thisli.offset().top + 48 );
} ).on( 'click', '.pl-remove', function() { // remove from playlist
plRemove( $( this ).parent() );
playlistRemove( $( this ).parent() );
} );
$( '#pl-savedlist' ).on( 'click', 'li', function( e ) {
menuHide();
Expand Down
10 changes: 3 additions & 7 deletions srv/http/assets/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,9 @@ function playbackIcon() {
function renderPage() {
playbackIcon();
var htmlstatus = G.version +'<br>'
if ( G.counts ) {
htmlstatus += '<i class="fa fa-song gr"></i>&ensp;'+ G.counts.song.toLocaleString() +'&emsp; '
+'<i class="fa fa-album gr"></i>&ensp;'+ G.counts.album.toLocaleString() +'<wide>&emsp; '
+'<i class="fa fa-webradio gr"></i>&ensp;'+ G.counts.webradio.toLocaleString() +'</wide>';
} else {
htmlstatus += '<gr>Updating ...</gr>';
}
+'<i class="fa fa-song gr"></i>&ensp;'+ ( G.counts.song || 0 ).toLocaleString() +'&emsp; '
+'<i class="fa fa-album gr"></i>&ensp;'+ ( G.counts.album || 0 ).toLocaleString() +'<wide>&emsp; '
+'<i class="fa fa-webradio gr"></i>&ensp;'+ ( G.counts.webradio || 0 ).toLocaleString() +'</wide>';
if ( !G.active ) htmlstatus += '<br><i class="fa fa-warning red"></i>&ensp;MPD not running'
$( '#statusvalue' ).html( htmlstatus );
if ( G.asoundcard != -1 ) {
Expand Down
39 changes: 27 additions & 12 deletions srv/http/assets/js/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ function infoMount( values ) {
if ( !values || values.length === 8 ) {
var htmlname = `\
<tr><td><gr>As:</gr> NAS/</td>
<td><input type="text"></td>
<td><input id="mountpoint" type="text"></td>
</tr>`;
var chktext = 'Update Library on mount'
} else {
Expand All @@ -889,8 +889,8 @@ ${ htmlname }
<tr><td>Server IP</td>
<td><input type="text"></td>
</tr>
<tr id="sharename"><td>Share name</td>
<td><input type="text"></td>
<tr><td id="sharelabel">Share name</td>
<td><input id="share" type="text"></td>
</tr>
<tr class="guest"><td>User</td>
<td><input type="text"></td>
Expand All @@ -913,24 +913,39 @@ ${ htmlname }
, beforeshow : function() {
$( '#infoContent td' ).eq( 0 ).css( 'width', 90 );
$( '#infoContent td' ).eq( 1 ).css( 'width', 230 );
var $sharelabel = $( '#sharename td' ).eq( 0 );
var $share = $( '#sharename input' );
var $guest = $( '.guest' );
var $share = $( '#share' );
function hideOptions( type ) {
$share.val( '' );
if ( type === 'nfs' ) {
$sharelabel.text( 'Share path' );
$guest.addClass( 'hide' );
$share.val( $share.val() || '/' );
$( '#sharelabel' ).text( 'Share path' );
$( '.guest' ).addClass( 'hide' );
$share.attr( 'placeholder', '/path/to/share' );
} else {
$sharelabel.text( 'Share name' );
$guest.removeClass( 'hide' );
$share.val( $share.val().replace( /\//g, '' ) );
$( '#sharelabel' ).text( 'Share name' );
$( '.guest' ).removeClass( 'hide' );
$share.attr( 'placeholder', 'sharename' );
}
}
hideOptions( values ? values[ 0 ] : 'cifs' );
$( '#infoContent input:radio' ).change( function() {
hideOptions( $( this ).val() );
} );
var $mountpoint = $( '#mountpoint' );
$mountpoint.on( 'keyup paste', function() {
setTimeout( function() {
$mountpoint.val( $mountpoint.val().replace( /\//g, '' ) );
}, 0 );
} );
$share.on( 'keyup paste', function() {
setTimeout( function() {
var sharename = $share.val();
if ( $( '#infoContent input[type=radio]:checked' ).val() === 'cifs' ) {
$share.val( sharename.replace( /[\/\\]/g, '' ) );
} else {
if ( sharename[ 0 ] !== '/' ) $share.val( '/'+ sharename );
}
}, 0 );
} );
}
, cancel : function() {
if ( shareddata ) $( '#shareddata' ).prop( 'checked', false );
Expand Down
6 changes: 3 additions & 3 deletions srv/http/bash/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,10 @@ plorder )
;;
plremove )
pos=${args[1]}
activenext=${args[2]}
posprev=${args[2]}
if [[ $pos ]]; then
mpc -q del $pos
[[ $activenext ]] && mpc -q play $activenext && mpc -q stop
[[ $posprev ]] && mpc -q play $posprev && mpc -q stop
else
mpc -q clear
fi
Expand Down Expand Up @@ -1373,7 +1373,7 @@ webradiodelete )
path=$dirdata/$type
[[ $dir ]] && path+="/$dir"
rm -f "$path/$urlname"
[[ -z $( find $dir -name $urlname ) ]] && rm -f "$path/img/$urlname"{,-thumb}.*
[[ ! $( find $dir -name $urlname ) ]] && rm -f "$path/img/$urlname"{,-thumb}.*
webradioCount $type
;;
wrdirdelete )
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 @@ -32,7 +32,7 @@ for service in "${services[@]}"; do
echo "\
$name
48 kHz 160 kbit/s
" > "$dirdabradio/$ensemble/rtsp:||$host|$channel_id"
" > "$dirdabradio/$ensemble/rtsp:||$host:8554|$channel_id"
list+="\
$channel_id:
runOnDemand: /srv/http/bash/dab-start.sh $id $channel \$RTSP_PORT \$RTSP_PATH
Expand Down
12 changes: 6 additions & 6 deletions srv/http/bash/dab-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ dab-rtlsdr-3 \
DABPID=$!

ffmpeg \
-re \
-stream_loop -1 \
-ac 2 \
-ar 48000 \
-b:a 160k \
-c:a aac \
-f s16le \
-f rtsp rtsp://localhost:$3/$4 \
-i $MYPIPE \
-metadata title="DAB Radio" \
-readrate 1 \
-stream_loop -1 \
-vn \
-b:a 160k \
-c:a aac \
-metadata title="DAB Radio" \
-f rtsp rtsp://localhost:$3/$4 \
&> /dev/null &
FFMPID=$!

Expand Down
6 changes: 4 additions & 2 deletions srv/http/bash/settings/system-datareset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ sed -i -e -E '/^auto_update|^audio_buffer_size| #custom$/ d
}
' /etc/mpd.conf
if [[ ! -e $dirmpd/counts ]]; then
webradio=$( find -L $dirwebradio -type f ! -path '*/img/*' | wc -l )
echo '{ "webradio": '$webradio' }' > $dirmpd/counts
echo '{
"playlists" : '$( ls -1 $dirplaylists | wc -l )'
, "webradio" : '$( find -L $dirwebradio -type f ! -path '*/img/*' | wc -l )'
}' > $dirmpd/counts
fi

usermod -a -G root http # add user http to group root to allow /dev/gpiomem access
Expand Down
43 changes: 8 additions & 35 deletions srv/http/bash/settings/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ databackup )
fi
mkdir -p $dirconfig/var/lib
cp -r /var/lib/bluetooth $dirconfig/var/lib &> /dev/null
xinitrcfiles=$( ls /etc/X11/xinit/xinitrc.d | grep -v 50-systemd-user.sh )
if [[ $xinitrcfiles ]]; then
mkdir -p $dirconfig/etc/X11/xinit
cp -r /etc/X11/xinit/xinitrc.d $dirconfig/etc/X11/xinit
fi

services='bluetooth hostapd localbrowser mpdscribble@mpd powerbutton shairport-sync smb snapclient snapserver spotifyd upmpdcli'
for service in $services; do
Expand Down Expand Up @@ -190,18 +195,17 @@ datarestore )
rm -f $dirsystem/{color,relays,soundprofile} # system

bsdtar -xpf $backupfile -C /srv/http
# temp
# temp 20220808 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if [[ -e $dirdata/webradios ]]; then
mv $dirdata/webradio{s,}
mv $dirdata/{webradiosimg,webradio/img}
fi

# temp 20220808 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
uuid1=$( head -1 /etc/fstab | cut -d' ' -f1 )
uuid2=${uuid1:0:-1}2
sed -i "s/root=.* rw/root=$uuid2 rw/; s/elevator=noop //" $dirconfig/boot/cmdline.txt
sed -i "s/^PARTUUID=.*-01 /$uuid1 /; s/^PARTUUID=.*-02 /$uuid2 /" $dirconfig/etc/fstab

rm -f $dirconfig/etc/{shairport-sync,spotifyd}.conf # temp: for ealier version
cp -rf $dirconfig/* /
[[ -e $dirsystem/enable ]] && systemctl -q enable $( cat $dirsystem/enable )
[[ -e $dirsystem/disable ]] && systemctl -q disable $( cat $dirsystem/disable )
Expand All @@ -219,8 +223,6 @@ datarestore )
rm -rf $backupfile $dirconfig $dirsystem/{enable,disable,hostname,netctlprofile,timezone}
[[ -e $dirsystem/crossfade ]] && mpc crossfade $( cat $dirsystem/crossfade.conf )
rmdir /mnt/MPD/NAS/* &> /dev/null
chown -R http:http /srv/http
chown mpd:audio $dirmpd/mpd* &> /dev/null
readarray -t mountpoints <<< $( grep /mnt/MPD/NAS /etc/fstab | awk '{print $2}' | sed 's/\\040/ /g' )
if [[ $mountpoints ]]; then
for mountpoint in $mountpoints; do
Expand All @@ -240,36 +242,7 @@ datarestore )
done
fi
fi

# temp 20220312 ###
readarray -t plfiles <<< $( ls -I '*.*' $dirplaylists )
if [[ $plfiles ]]; then
echo -e "\n\e[38;5;6m\e[48;5;6m . \e[0m Convert saved playlists ..."
for name in "${plfiles[@]}"; do
echo $name
plfile="$dirplaylists/$name"
list=$( grep '"file":' "$plfile" | sed 's/^\s*"file": "//; s/",$//; s/\\//g' )
if grep -q '^\s*"Range": ' "$plfile"; then
readarray -t file_track <<< $( grep -B1 -A5 '"Range":' "$plfile" \
| egrep '"file":|"Track":' \
| sed -E 's/^\s*"file": "|^\s*"Track": //; s/",$|,$//; s/\\//g' )
iL=${#file_track[@]}
for (( i=0; i < iL; i++ )); do
track=000${file_track[$(( i + 1 ))]}
file=${file_track[i]}
filecue="${file%.*}.cue/track${track: -4}"
list=$( sed "s|$file|$filecue|" <<< "$list" )
(( i++ ))
done
fi
echo "$list" > "$plfile.m3u"
rm "$plfile"
done
fi
# temp 20220312 ###

chown -R http:http /srv/http/{assets,bash,settings}
chmod 755 /srv/http/* $dirbash/* /srv/http/settings/*
$dirbash/cmd.sh dirpermissions
[[ -e $dirsystem/color ]] && $dirbash/cmd.sh color
$dirbash/cmd.sh power$'\n'reboot
;;
Expand Down
4 changes: 1 addition & 3 deletions srv/http/bash/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ if [[ -e $dirsystem/hddspindown ]]; then
fi

if [[ ! $shareddata && ! -e $dirmpd/mpd.db ]]; then
if [[ ! -z $( ls /mnt/MPD/NAS ) || ! -z $( ls /mnt/MPD/SD ) || ! -z $( ls /mnt/MPD/USB ) ]]; then
$dirbash/cmd.sh$'\n'rescan
fi
$dirbash/cmd.sh$'\n'rescan
elif [[ -e $dirmpd/updating ]]; then
$dirbash/cmd.sh$'\n'"$( cat $dirmpd/updating )"
elif [[ -e $dirmpd/listing || ! -e $dirmpd/counts ]]; then
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ $radiosampling" > $dirshm/radio
stationcover=$filenoext.$date.jpg
fi
fi
status=$( egrep -v '^, *"state"|^, *"webradio"' <<< "$status" )
status=$( egrep -v '^, *"state"|^, *"webradio".*true|^, *"webradio".*false' <<< "$status" )
########
status+='
, "Album" : "'$Album'"
Expand Down
9 changes: 3 additions & 6 deletions srv/http/bash/xinitrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

export XDG_CACHE_HOME="/tmp/.cache"

if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
for file in /etc/X11/xinit/xinitrc.d/*; do
. "$file"
done

. /srv/http/data/system/localbrowser.conf

Expand Down

0 comments on commit d8d92f0

Please sign in to comment.