Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
This guide concerns the listening information of Streaming Radio which can be exported using the FTP protocol; these logs (from which the listening statistics are also derived after "cleaning" or "purification") are then automatically transferred by FTP to be subsequently processed.
Preamble
- Your radio logs will be provided as a compressed file xyz.mp3-20140805.log.gz (the log date is in the format YYYYMMDD).
- Each log starts at 04:00 Swiss time and ends at 03:59:59 the next day.
- The log is in the form
ip user-identifier authuser [date-time] "request" status octets "referer" "useragent" listening-tim
e:81.56.215.98 - - [09/Apr/2019:08:23:18 +0200] "GET /toto.mp3 HTTP/1.1" 200 1211297 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko/2019032711 Ubuntu/8.10 (intrepid) Firefox/3.0.8" 69
- It may happen that the log line is malformed, due to a referer that is too long for example; this behavior of Icecast cannot be modified.
- The IP range 84.16.67.128/25 should be ignored as these are the streaming servers.
- From the settings page on the Manager, you can request the logs from past days.
- You can also directly export them to ACPM or Mediapulse.
Enable FTP log sending
For this:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the relevant product.
- Click on the name of the audio stream in question.
- Click on Settings in the left sidebar.
- Enable FTP log export with the toggle switch.
- Enter a hostname: FTP server address.
- Enter a username: FTP account name.
- Enter a password: that of the FTP account.
- Enter the directory on the server where to store the logs.
- Click on the Save button at the bottom of the page:
Process the logs
The best option is to use a regular expression like the one below:
"/^(\S+)\s(.+)\s(\S+)?\s\[((\d\d)\/([a-zA-Z]{3,3})\/(\d\d\d\d)\:(\d\d)\:(\d\d)\:(\d\d)\s\+\d\d\d\d)\]\s"GET\s\/([\-a-z0-9]{1,40}(\.)?(mp3|aac|ogg){0,1})(.*)?"\s(\d{3,3})\s(\d+)\s"(.+)"\s"(.+)"\s(\d+)$/i";
This syntax is for the PHP function preg_match
and will need to be adapted if other functions/languages are used.
The function preg_match
returns an array with the following significant positions:
1 | ip |
4 | complete date - time |
5 | day |
6 | month |
7 | year |
8 | hour |
9 | min |
10 | seconds |
11 | mount point |
15 | result (HTTP code) |
16 | length in bytes |
18 | user agent |
19 | listening duration (seconds) |
This guide explains how to transmit the metadata for the radio stream sent from your encoder of Streaming radio.
Use the available URL
You just need to do a GET on a URL of this type:
https://[flux]:[password]@api.infomaniak.com/1/radios/stats/metadata?data=artist - title
The full URL is available on the administration interface:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the relevant product.
- Click on the name of the audio stream in question.
- Click on Settings in the left sidebar.
- Click the button to copy the metadata link:
Learn more
For developers who would code a Player, there are libraries that can search for the transmitted info and display it because the data is transmitted in the stream data. The other possibility is to retrieve the stream info from the server itself.
This guide covers the audience and listening statistics for Streaming Radio, allowing you to view all information about listeners and different audiences for your radio streams.
Foreword
- Refer to this other guide if you wish to process the raw logs yourself.
Accessing listening statistics
To access this information:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the relevant product.
- Click on Statistics in the left sidebar:
- Click on the different menus in the left sidebar:
Overview
Real-time audience
Refer to this other guide for more information on this topic.
Listeners
Listening time
Consumption
Geolocation
Exporting to .csv
format is possible:
Players
This guide explains how to remove an audio stream from your Streaming Radio, without deleting the entire product.
Delete a radio station
To access the Streaming service and delete one of the streams:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the product in question:
- Click on the name of the radio in question:
- Click on the action menu ⋮ located to the right of the relevant item.
- Click on Delete:
- Enter the name of the radio to confirm deletion.
This guide explains how to properly set up a stream on the Streaming radio Infomaniak.
Set up radio stream broadcasting
To access the radio streaming service:
- Click here to access your product management on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the relevant product.
- Click on the radio name.
- Click on the Add a stream button:
- then click again on the Add a stream button:
- Add a standard stream:
- Choose the desired options:
- Click on the Save button.
This guide explains how to specify a backup audio stream on the Streaming radio Infomaniak.
Thus, if your main stream becomes unavailable, the backup stream will automatically take over the broadcast.
Create a backup stream
To access the radio streaming service:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the relevant product.
- Click on the radio name.
- Click the Add a stream button to create a new stream and add a backup stream to it or Configure an existing stream to activate the option:
- Click the toggle switch to enable the backup stream on your stream:
- Copy the information provided to configure your backup encoder.
- Save the activation of the backup stream at the bottom right of the page.
In the same place, you can set the backup stream as a stream relay to manually enter the corresponding parameters for the backup audio stream:
Save the new information at the bottom right of the page.
This guide concerns the listening information of Streaming Radio that can be exported to ACPM (formerly OJD Numérique).
Preamble
- The ACPM, Alliance for Press and Media Figures, is an independent organization in France that certifies data related to the distribution, audience, and traffic of media outlets.
- These data, recognized as the official reference, support market players in the media and advertising sectors in their analysis, comparison, and structuring of their strategies.
- Governed by its bodies composed of media professionals, ACPM ensures transparency, independence, and methodological rigor; it provides reliable certifications in line with the evolution of the media sector.
- Also, refer to this other guide about a similar service but intended for Switzerland.
Manage ACPM certification
Prerequisites
- The Organization where the Streaming service is located must be established with an address in France.
- To activate ACPM certification, please contact this service by email:
equipe-ojdnumerique@acpm.fr
. - Once the contract has been established with them, contact Infomaniak support by providing the information related to your ACPM and Infomaniak contract.
To manage the activation or deactivation of the service:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the product in question.
- Click on the name of the audio stream in question.
- Click on Settings in the left sidebar.
- Enable or disable the export of logs to ACPM with the toggle switch:
SpacialAudio SAM Cast is compatible with the audio streaming offer.
This guide explains how to maintain control over your MP3/AAC or HLS Streaming Radio streams by activating unique key (token) protection to decide, for example, whether a listener can listen to your radio or not.
Introduction
- The principle is simple: with each connection, you will make a request to the Infomaniak API, which will return a unique token with a limited and customizable lifespan. This token will authorize anyone who possesses it to consume the stream during this period.
- You can protect an MP3/AAC or HLS stream independently of each other (the same applies to geolocation).
- Enabling the restriction involves changing the stream configuration, which may take a few minutes to be replicated across the servers.
Protect an audio stream with a unique key
To do this, simply go to the restriction settings and activate token protection on the stream you wish to secure:
- Click here to access the management of your product on the Manager Infomaniak (need help?).
- Click directly on the name assigned to the product in question.
- Click on the name of the audio stream in question.
- Click on Restrictions in the left sidebar.
- Select HLS if necessary.
- Click on the action menu ⋮ located to the right of the relevant item.
- Click on Token Restriction:
Enable the protection next.
Warning, when you activate this option, access to the stream will be instantly blocked for new connections. Adapt your Players to take into account the restriction, as illustrated in the example below:
Create a Radio API Token
To access the Radio API, you must first authenticate using an application token. This step only needs to be done once. To create this application token, refer to this other guide.
The scope is radio and with unlimited lifetime to avoid having to regenerate a code on a regular basis. Once the token is generated, copy it to paste it into the example below.
PHP usage example
For MP3/AAC or HLS, the code can be quite similar, only the URL called in POST changes in its form.
Paste the generated token below instead of the one indicated:
if (!defined('API_TOKEN')) {
define('API_TOKEN', 'AYF5lSh3c7Xy5974Fs12RTkTThujT-L9R4Xk2ZfGyP6sV7QqJ1oC3jD8nFtKzIxUeMw5oNzR6');
}
/**
* Fonction générique pour executer des requêtes cURL
*
* @param string $method Méthode HTTP (GET, POST, PUT, etc...)
* @param string $url Url de l'api a requêter
* @param array $headers Liste des en-têtes HTTP (l'autorisation doit être passée ici avec un ['Authorization: Bearer ']
* @param array $payload Un tableau contenant les données pour créer un token
* @return mixed
*/
function request(string $method, string $url, array $headers = [], array $payload = []): mixed{
// prepare options array
$opts = [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => strtoupper($method),
];
// add payload if relevant
if ($payload && $method !== 'GET') {
$opts[CURLOPT_POSTFIELDS] = json_encode($payload);
}
$ch = curl_init();
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
if(curl_errno($ch)){
throw new Exception(curl_error($ch));
}
$data = json_decode($result, true);
if ($data['result'] === 'error') {
throw new Exception($data['error']['description'] ?? 'an error occured');
}
return $data['data'];
}
We are going to create the token. The URL for creating the token breaks down as follows:
- For an MP3 / AAC stream
POST https://api.infomaniak.com/1/radios/acl/streams/mountpoint.mp3/token
Example to protect https://newradiotest.ice.infomaniak.ch/newradiotest-128.aac
the route will be: https://api.infomaniak.com/1/radios/acl/streams/newradiotest-128.aac/token
- For an HLS stream
POST https://api.infomaniak.com/1/radios/acl/hls_streams/<stream>/token
Example to protect https://myradiostream.radiohls.infomaniak.com/myradiostream/manifest.m3u8
the route will be: https://api.infomaniak.com/1/radios/acl/hls_streams/myradiostream/token
Example for MP3/AAC, make sure to adjust:
$token = request(
'POST',
'https://api.infomaniak.com/1/radios/acl/streams/newradiotest-128.aac/token',
// en-tête d'authorization
[
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json',
],
/**
* payload pour créer le token, vous pouvez passer les valeurs suivantes
* window | 300 | optionnel | durée de validité du token (default: 5 minutes)
*/
[
'window' => 3600, // 1h validity
]
);
It is important to note that if this code is generated at the time of page loading, the listener will have "window" seconds to start playing the stream. Beyond this delay, the token will expire, and the stream will no longer be able to be launched unless the page is reloaded. Depending on your needs and use case, it will be necessary to adjust this delay in the best possible way.
You will also need to replace the playback URL of your stream below with the one indicated, while keeping the $token
parameter at the end. Finally, display the Player (here a simple html5 tag, but you can of course add any overlay afterwards, the token being passed in the $_GET
parameters of the url).
$streamUrl = "https://newradiotest.ice.infomaniak.ch/newradiotest-128.aac?$token";
echo "<audio controls=""><source src="$streamUrl"></audio>";