Creating A Simple PHP Script That Gets Songs URL From Audiomack

Audiomack is a popular online music streaming and audio distribution platform. It allows artists, DJs, and podcasters to upload, share, and promote their music and audio content.
Users can discover and listen to a wide variety of music genres, including hip-hop, rap, R&B, electronic, and more, from both established and emerging artists.
Audiomack offers features such as personalized playlists, trending charts, and the ability to create and share playlists with others. It provides a platform for artists to showcase their work, connect with fans, and gain exposure in the music industry.
In addition to streaming music, Audiomack also allows users to download tracks for offline listening. It has both a website interface and mobile apps for iOS and Android devices, making it accessible across various platforms.
Overall, Audiomack serves as a platform that facilitates the discovery, promotion, and consumption of music and audio content for both artists and listeners.
Before we dive into the PHP scripts that get songs url from Audiomack, please note that Audiomack’s terms of service or the specific audio file’s usage rights may impose restrictions on getting audio files.
Make sure to comply with any applicable usage restrictions or obtain the necessary permissions before using this code.
Certainly! Here’s a simple PHP script that can download audio from Audiomack:
<?php
function downloadAudioFromAudiomack($url, $savePath) {
// Create a new cURL resource
$ch = curl_init();
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
// Execute the request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error occurred while downloading: ' . curl_error($ch);
curl_close($ch);
return false;
}
// Close cURL resource
curl_close($ch);
// Save the audio file
file_put_contents($savePath, $response);
echo 'Audio downloaded successfully!';
return true;
}
// Example usage
$url = 'https://www.audiomack.com/song/example-song';
$savePath = 'path/to/save/example-song.mp3';
downloadAudioFromAudiomack($url, $savePath);
?>
In this script, you need to provide the Audiomack URL of the audio you want to download in the $url variable, and specify the desired path and filename for the downloaded audio in the $savePath variable. The script uses cURL to fetch the audio file and file_put_contents() to save it to the specified location.
Inserting the html form to paste your URL:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Function to download audio from Audiomack
function downloadAudioFromAudiomack($url, $savePath) {
// Create a new cURL resource
$ch = curl_init();
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
// Execute the request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error occurred while downloading: ' . curl_error($ch);
curl_close($ch);
return false;
}
// Close cURL resource
curl_close($ch);
// Save the audio file
file_put_contents($savePath, $response);
echo 'Audio downloaded successfully!';
return true;
}
// Get the Audiomack URL and save path from the form submission
$url = $_POST['url'];
$savePath = $_POST['save_path'];
// Download the audio from Audiomack
downloadAudioFromAudiomack($url, $savePath);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Audiomack Audio Downloader</title>
</head>
<body>
<h1>Audiomack Audio Downloader</h1>
<form method="POST" enctype="multipart/form-data">
<label for="url">Audiomack URL:</label>
<input type="text" name="url" id="url" required><br><br>
<label for="save_path">Save Path:</label>
<input type="text" name="save_path" id="save_path" required><br><br>
<input type="submit" value="Download Audio">
</form>
</body>
</html>
This code includes an HTML form with two input fields: one for the Audiomack URL (url
) and one for the save path (save_path
). The form’s method is set to POST
, and the form data is processed by the same PHP script ($_SERVER['REQUEST_METHOD'] === 'POST'
condition).
When the form is submitted, the PHP script retrieves the Audiomack URL and save path from the form data and calls the downloadAudioFromAudiomack()
function to download the audio file from Audiomack. The downloaded audio will be saved to the specified save path.
You can save this code in a PHP file (e.g., audiomack_downloader.php
) and upload it to your test website. Accessing the PHP file through a web browser will display the HTML form, allowing you to enter the Audiomack URL and save path for audios.