Example #1
0
    saveToXml($output, 'artist');
    $edit_id = -1;
    include 'foundAlbums.php';
} else {
    if ($albumName == 'albumName' || $albumName == '') {
        $artist = str_replace(' ', '+', $artist);
        $url = 'https://api.spotify.com/v1/search?q=' . $artist . '&type=artist';
        $output = fetchAsJson($url);
        $url = 'https://api.spotify.com/v1/artists/' . $output['artists']['items'][0]['id'] . '/albums?album_type=album';
        $output = fetchAsJson($url);
        saveToXml($output, 'album');
        $edit_id = -1;
        include 'foundAlbums.php';
    } else {
        $albumName = str_replace(' ', '+', $albumName);
        $artist = str_replace(' ', '+', $artist);
        $url = 'https://api.spotify.com/v1/search?q=album%3A' . $albumName . '+artist%3A' . $artist . '&type=album';
        $albumName = ucwords(strtolower(str_replace('+', ' ', $albumName)));
        $artist = ucwords(strtolower(str_replace('+', ' ', $artist)));
        $outputAsJson = fetchAsJson($url);
        if ($outputAsJson['albums']['total'] == 0) {
            $imgUrl = '../img/placeholder.png';
            $albumUrl = 'https://open.spotify.com/album/404';
        } else {
            echo $albumID = $outputAsJson['albums']['items'][0]['id'];
            getAlbumInfo($year, $numTracks, $albumID);
            $imgUrl = $outputAsJson['albums']['items'][0]['images'][0]['url'];
            $albumUrl = $outputAsJson['albums']['items'][0]['external_urls']['spotify'];
        }
    }
}
Example #2
0
    }
    $imageLength = getImageListLength($artist->image);
    insertImageUrl($dbHandle, $artist->image, $imageLength, $artistId, 0, $ARTIST_ARTWORK_FLAG, array(0 => $ARTIST_ARTWORK_FLAG, 1 => $ALBUM_ARTWORK_FLAG), $MAX_IMAGE_COUNT);
    saveBio($artistId . "-artist_bio.txt", $artist->bio->content, $fp, $DATABASE_SCRIPT_DIR, $DS_ARTIST_BIO_DIR, $DS_LOGS_DIR);
    $dbHandle->query("UPDATE artist_list SET \n                    `bio_file`='" . addslashes($artistId . "-artist_bio.txt") . "', time_added='" . getRandom() . "' WHERE artist_id='" . $artistId . "'");
}
//////////////////////////////////////////////////////////////
// ALBUM STUFF //
$dataDump = uwe_file_get_contents("http://ws.audioscrobbler.com/2.0/?method=artist.gettopalbums&artist=" . urlencode($artist->name) . "&api_key=" . $LASTFM_API_KEY . "&format=json");
$albumList = json_decode($dataDump)->topalbums;
$albumLength = getAlbumLength($albumList);
for ($i = 0; $i < $albumLength; $i++) {
    if ($albumLength == 1) {
        $albumInfo = getAlbumInfo($albumList->album);
    } else {
        $albumInfo = getAlbumInfo($albumList->album[$i]);
    }
    if (albumExist($dbHandle, $artistId, addslashes($albumInfo['name']))) {
        fprintf($fp, "DUP Album, skipping album\n");
        $warning++;
    } else {
        $sql[0] = "INSERT INTO album_list (artist_id, album_title, time_added) VALUES ('" . $artistId . "', '" . addslashes($albumInfo['name']) . "', '" . getRandom() . "')";
        $sql[1] = "SELECT * FROM album_list WHERE artist_id='" . $artistId . "' AND `album_title`='" . addslashes($albumInfo['name']) . "'";
        if (!insertQuery($dbHandle, $sql)) {
            fprintf($fp, "Unable to add album to database\n");
            fclose($fp);
            echo "Failed adding album";
            exit;
        }
        if (!albumExist($dbHandle, $artistId, addslashes($albumInfo['name']))) {
            fprintf($fp, "Unable to retrieve album from database\n");
function getInfo($stream)
{
    if (!$stream['info']['song']) {
        $stream['info']['song'] == 'Not found';
        return $stream;
    }
    if (GET_TRACK_INFO == TRUE) {
        $stream = getTrackInfo($stream);
    }
    if (GET_ALBUM_INFO && isset($stream['album']['title'])) {
        $stream = getAlbumInfo($stream);
    }
    if (GET_ARTIST_INFO == TRUE) {
        $stream = getArtistInfo($stream);
    }
    if (GET_TRACK_BUY_LINK == TRUE) {
        $stream = getTrackBuyLink($stream);
    }
    if (CACHE_ALBUM_ART == TRUE) {
        $stream['album']['local_image'] = cacheAlbumArt($stream['album']['image_l']);
    }
    if (GET_LYRICS == TRUE) {
        $stream['track']['lyric'] = getLyric($stream['info']['artist'], $stream['info']['song']);
    }
    $stream['fetch_time'] = time();
    return $stream;
}
Example #4
0
function showSubAlbum($root = 1)
{
    global $db, $prefix, $moduleName, $iConfig, $pag, $ofsppg, $ofsbgn;
    $root = intval($root);
    $showDetails = intval($iConfig['show_details']);
    $showColumns = intval($iConfig['show_columns']);
    $thumbsPath = $iConfig['thumbs_path'];
    $thumbsRealPath = iPath($thumbsPath);
    $thumbsFormat = strtolower($iConfig['thumbs_format']);
    $albumCounter = 0;
    //echo '<table class="show-child" cellspacing="5" cellpadding="5"><tr>' . PHP_EOL;
    echo '<ul class="thumbnails">' . PHP_EOL;
    $column = 1;
    $srow = 1;
    $node = getNodes($root);
    $sql = 'SELECT node.*, (COUNT(parent.album_id) - (sub_tree.depth + 1)) AS depth
	FROM ' . $prefix . '_igallery_albums AS node,
	' . $prefix . '_igallery_albums AS parent,
	' . $prefix . '_igallery_albums AS sub_parent,
	(
		SELECT node.*, (COUNT(parent.album_id) - 1) AS depth
		FROM ' . $prefix . '_igallery_albums AS node,
		' . $prefix . '_igallery_albums AS parent
		WHERE node.album_left BETWEEN parent.album_left AND parent.album_right
		AND node.album_id = \'' . $node['id'] . '\'
		GROUP BY node.album_id
		ORDER BY node.album_left
	) AS sub_tree
	WHERE node.album_left BETWEEN parent.album_left AND parent.album_right
		AND node.album_left BETWEEN sub_parent.album_left AND sub_parent.album_right
		AND sub_parent.album_id = sub_tree.album_id
	GROUP BY node.album_id
	HAVING depth = 1
	ORDER BY node.album_left;';
    $result = $db->sql_query($sql);
    while ($album = $db->sql_fetchrow($result)) {
        $albumCounter++;
        $catId = $album['album_id'];
        $folderName = $album['album_folder'];
        $cover = $album['album_cover'];
        $title = $album['album_title'];
        $description = $album['album_desc'];
        $albumParent = $album['album_id'];
        $what = getAlbumInfo($catId);
        $latestDate = $what[0];
        $totalPics = $what[1];
        if (!empty($cover)) {
            $info = pathinfo($cover);
            $rawCover = str_replace($info['extension'], '', $cover);
        }
        if (!empty($rawCover)) {
            $pictureId = $db->sql_fetchrow($db->sql_query('SELECT picture_id FROM ' . $prefix . '_igallery_pictures WHERE picture_file=\'' . $cover . '\' AND album_id=\'' . $albumId . '\' LIMIT 0,1'));
            $coverSrc = 'modules.php?name=' . $moduleName . '&amp;op=getThumb&amp;pictureid=' . $pictureId['picture_id'];
        } else {
            $catListIds = getSubAlbumIds($catId);
            if (!empty($catListIds) && $catListIds !== ',') {
                $catListIds = $catId . ', ' . $catListIds;
                $sql = 'album_id IN (' . $catListIds . ')';
            } else {
                $sql = 'album_id=' . $catId . '';
            }
            $data = $db->sql_fetchrow($db->sql_query('SELECT picture_id FROM ' . $prefix . '_igallery_pictures WHERE ' . $sql . ' LIMIT 0,1'));
            $pictureId = $data['picture_id'];
            $coverSrc = 'modules.php?name=' . $moduleName . '&amp;op=getThumb&amp;pictureid=' . $pictureId;
        }
        //echo '<td class="sub-album">' . PHP_EOL;
        //echo '<div class="thumb-target">' . PHP_EOL;
        echo '<li class="span3">' . PHP_EOL;
        echo '<div class="thumbnail">' . PHP_EOL;
        echo '	<a href="modules.php?name=' . $moduleName . '&amp;op=showAlbum&amp;albumid=' . $catId . '"><img class="sub-album" src="' . $coverSrc . '" alt="' . $title . '" /></a>' . PHP_EOL;
        //echo '	<div class="tooltip_description">' . PHP_EOL;
        //echo '		<p>' . PHP_EOL;
        //echo '			<span class="title">'.$title .'</span>';
        echo '		<div class="caption">' . PHP_EOL;
        echo '			<h4>' . $title . '</h4>';
        //echo showNewEmblem($latestDate);
        //echo '<br />' . PHP_EOL;
        if ($description) {
            echo '			<p>' . $description . '</p>' . PHP_EOL;
        }
        echo '		<span class="label label-info">' . $totalPics . ' ' . _IG_TOTALPICS . '</span>' . PHP_EOL;
        echo '	</div>';
        echo '</div>';
        echo '</li>' . PHP_EOL;
        /*if (($column%$showColumns)==0) {
        			//echo '<div style="clear:left;"></div>' . PHP_EOL;
        			echo '</tr><tr>' . PHP_EOL;
        			$srow++;
        		}*/
        $column++;
    }
    //echo '<div style="clear:left;"></div></div>';
    //echo '<td></td></tr></table>' . PHP_EOL;
    echo '</ul>' . PHP_EOL;
    //$totalItems = $db->sql_numrows($db->sql_query('SELECT album_id FROM '.$prefix .'_igallery_albums WHERE album_parent=0 AND album_active=1 ;'));
    //paginationSystem($ofsbgn, $ofsppg, $totalItems);
    //if ($srow!==1 || $column!==1) echo '<hr />';
}