Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #155 by enabling to start an update by running php update.php #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions update.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,18 @@
exit();


// +------------------------------------------------------------------------+
// | CLI Update wrapper |
// +------------------------------------------------------------------------+
function cliUpdate() {
global $cfg, $db, $lastGenre_id, $getID3, $dirsCounter, $filesCounter, $curFilesCounter, $curDirsCounter, $last_update, $file;

$cfg['cli_update'] = true;

cliLog( "CLI update of " . $cfg['media_dir'] );

update_impl( $cfg['media_dir'] );
}


// +------------------------------------------------------------------------+
Expand All @@ -98,12 +109,18 @@ function update($dir_to_update = '') {

global $cfg, $db, $lastGenre_id, $getID3, $dirsCounter, $filesCounter, $curFilesCounter, $curDirsCounter, $last_update, $file;
authenticate('access_admin', false, true);

$cfg['cli_update'] = false;

update_impl( $dir_to_update );
}


function update_impl($dir_to_update = '') {
global $cfg, $db, $lastGenre_id, $getID3, $dirsCounter, $filesCounter, $curFilesCounter, $curDirsCounter, $last_update, $file;

require_once('getid3/getid3/getid3.php');
require_once('include/play.inc.php'); // Needed for mpdUpdate()

$cfg['cli_update'] = false;
$startTime = new DateTime();

cliLog("Update start time: " . date("Ymd H:i:s"));
Expand Down Expand Up @@ -251,6 +268,8 @@ function show_update_progress() {
$update_status=$row["update_status"];
}

cliLog( "Update status ".$update_status );

if ($update_status == 0) {
mysqli_query($db,"update update_progress set
update_status = 1,
Expand Down Expand Up @@ -846,6 +865,25 @@ function countDirectories($base_dir) {
$album = basename($dir);
}

// misc_tracks_misc_artists_folder might also be a CSV - https://github.com/ArturSierzant/OMPD/issues/147
$miscs = explode( ',',$cfg['misc_tracks_misc_artists_folder'] );

if( count($miscs) > 1 ){
$is_misc = false;
foreach($miscs as $misc){
if( basename($dir) == $misc ){
$is_misc = true;

$artist = 'Various Artists';
$artist_alphabetic = $artist;
$aGenre = '';
$year = NULL;
$album = basename($dir);
}
}

}

/* $result = mysqli_query($db,'SELECT genre_id FROM genre WHERE genre="' . $db->real_escape_string($aGenre) . '"');
$row=mysqli_fetch_assoc($result);
$aGenre_id=$row["genre_id"];
Expand Down