|
|
|
@ -56,6 +56,7 @@ OC_MEDIA_COLLECTION::$uid=OC_User::getUser(); |
|
|
|
|
if($arguments['action']){ |
|
|
|
|
switch($arguments['action']){ |
|
|
|
|
case 'delete': |
|
|
|
|
unset($_SESSION['collection']); |
|
|
|
|
$path=$arguments['path']; |
|
|
|
|
OC_MEDIA_COLLECTION::deleteSongByPath($path); |
|
|
|
|
$paths=explode(PATH_SEPARATOR,OC_Preferences::getValue(OC_User::getUser(),'media','paths','')); |
|
|
|
@ -64,17 +65,21 @@ if($arguments['action']){ |
|
|
|
|
OC_Preferences::setValue(OC_User::getUser(),'media','paths',implode(PATH_SEPARATOR,$paths)); |
|
|
|
|
} |
|
|
|
|
case 'get_collection': |
|
|
|
|
$artists=OC_MEDIA_COLLECTION::getArtists(); |
|
|
|
|
foreach($artists as &$artist){ |
|
|
|
|
$artist['albums']=OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']); |
|
|
|
|
foreach($artist['albums'] as &$album){ |
|
|
|
|
$album['songs']=OC_MEDIA_COLLECTION::getSongs($artist['artist_id'],$album['album_id']); |
|
|
|
|
if(!isset($_SESSION['collection'])){ |
|
|
|
|
$artists=OC_MEDIA_COLLECTION::getArtists(); |
|
|
|
|
foreach($artists as &$artist){ |
|
|
|
|
$artist['albums']=OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']); |
|
|
|
|
foreach($artist['albums'] as &$album){ |
|
|
|
|
$album['songs']=OC_MEDIA_COLLECTION::getSongs($artist['artist_id'],$album['album_id']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$_SESSION['collection']=json_encode($artists); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo json_encode($artists); |
|
|
|
|
echo $_SESSION['collection']; |
|
|
|
|
break; |
|
|
|
|
case 'scan': |
|
|
|
|
unset($_SESSION['collection']); |
|
|
|
|
OC_DB::beginTransaction(); |
|
|
|
|
set_time_limit(0); //recursive scan can take a while |
|
|
|
|
$path=$arguments['path']; |
|
|
|
@ -90,6 +95,7 @@ if($arguments['action']){ |
|
|
|
|
flush(); |
|
|
|
|
break; |
|
|
|
|
case 'scanFile': |
|
|
|
|
unset($_SESSION['collection']); |
|
|
|
|
echo (OC_MEDIA_SCANNER::scanFile($arguments['path']))?'true':'false'; |
|
|
|
|
break; |
|
|
|
|
case 'get_artists': |
|
|
|
|