Skip to content

Commit

Permalink
Merge pull request #1029 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Sep 17, 2022
2 parents b04ad04 + a3ae974 commit b298640
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion srv/http/bash/cmd-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ latest=$( cat "$dirmpd/latest" 2> /dev/null | wc -l )
for mode in NAS SD USB; do
printf -v $mode '%s' $( mpc ls $mode 2> /dev/null | wc -l )
done
dabradio=$( find -L $dirdabradio -type f ! -path '*/img/*' | wc -l )
dabradio=$( find -L $dirdata/dabradio -type f ! -path '*/img/*' 2> /dev/null | wc -l ) # no $dirdabradio if dab not installed
playlists=$( ls -1 $dirplaylists | wc -l )
song=$( mpc stats | awk '/^Songs/ {print $NF}' )
webradio=$( find -L $dirwebradio -type f ! -path '*/img/*' | wc -l )
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ webradioCount() {
[[ $1 == dabradio ]] && type=dabradio || type=webradio
count=$( find -L $dirdata/$type -type f ! -path '*/img/*' | wc -l )
pushstream radiolist '{"type":"'$type'", "count":'$count'}'
[[ $1 == dabradio ]] && count+=,
grep -q "$type.*,"$ $dirmpd/counts && count+=,
sed -i -E 's/("'$type'": ).*/\1'$count'/' $dirmpd/counts
}
webradioPlaylistVerify() {
Expand Down
19 changes: 8 additions & 11 deletions srv/http/mpdlibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
break;
case 'radio':
$dir = '/srv/http/data/'.$gmode.'/';
$dir.= $string;
$subdirs = [];
$files = [];
$indexes = [];
Expand All @@ -157,6 +156,7 @@
, $files );
} else {
$searchmode = 0;
$dir.= $string;
exec( 'ls -1 "'.$dir.'" \
| grep -E -v "^img|\.jpg$|\.gif$"'
, $lists );
Expand Down Expand Up @@ -381,7 +381,6 @@ function htmlRadio( $subdirs, $files, $dir ) {
global $mode;
global $gmode;
global $html;
$dirimg = '/data/'.$gmode.'/img/';
if ( count( $subdirs ) ) {
foreach( $subdirs as $subdir ) {
$each = ( object )[];
Expand All @@ -392,21 +391,20 @@ function htmlRadio( $subdirs, $files, $dir ) {
usort( $array, function( $a, $b ) {
return strnatcasecmp( $a->sort, $b->sort );
} );
$path = substr( $dir, 9 ); // /srv/http/data/webradio/... > /data/webradio/..
$lipath = substr( $path, 15 ); // /data/webradio/path.. > path
$lipath.= $lipath ? '/'.$subdir : $subdir;
$path = str_replace( '/srv/http/data/'.$gmode.'/', '', $dir ); // /srv/http/data/webradio/path/to > path/to
if ( $path ) $path.= '/';
foreach( $array as $each ) {
$subdir = $each->subdir;
if ( count( $files ) ) {
$html.= '<li class="dir">';
} else {
$index = strtoupper( mb_substr( $each->sort, 0, 1, 'UTF-8' ) );
$indexes[] = $index;
$html.= '<li class="dir" data-index="'.$index.'">';
}
$subdir = $each->subdir;
$thumbsrc = rawurlencode( $path.$subdir.'/thumb.'.time().'.jpg' );
$thumbsrc = rawurlencode( "/data/$gmode/$subdir/thumb.time().jpg" );
$html.= '<img class="lazyload iconthumb lib-icon" data-src="'.$thumbsrc.'" data-target="#menu-wrdir">
<a class="lipath">'.$lipath.'</a>
<a class="lipath">'.$path.$subdir.'</a>
<span class="single">'.$subdir.'</span>
</li>';
}
Expand All @@ -426,14 +424,13 @@ function htmlRadio( $subdirs, $files, $dir ) {
usort( $array, function( $a, $b ) {
return strnatcasecmp( $a->sort, $b->sort );
} );
$time = time();
foreach( $array as $each ) {
$index = strtoupper( mb_substr( $each->sort, 0, 1, 'UTF-8' ) );
$indexes[] = $index;
$datacharset = $each->charset ? ' data-charset="'.$each->charset.'"' : '';
$url = $each->url;
$urlname = str_replace( '/', '|', $url );
$datacharset = $each->charset ? ' data-charset="'.$each->charset.'"' : '';
$thumbsrc = rawurlencode( $dirimg.$urlname.'-thumb.'.$time.'.jpg' );
$thumbsrc = rawurlencode( '/data/'.$gmode.'/img/'.$urlname.'-thumb.'.time().'.jpg' );
$liname = $each->name;
$name = $searchmode ? preg_replace( "/($string)/i", '<bl>$1</bl>', $liname ) : $liname;
$html.= '<li class="file"'.$datacharset.' data-index="'.$index.'">
Expand Down

0 comments on commit b298640

Please sign in to comment.