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 metadata (metadata) for the radio stream sent from your encoder of Radio streaming .
Use URL available
Just do a GET on a type URL:
https://[flux]:[password]@api.infomaniak.com/1/radios/stats/metadata?data=artist - title
The full URL is available on the administration interface:
- Click here in order to access the management of your product on the Manager Infomaniak (Need help?).
- Click directly on the nameallocated to the product concerned.
- Click on the name of the audio stream concerned.
- Click on Parameters in the left side menu.
- Click on the button for copy the link of metadata:
Read more
For developers who would encode a Player, there are libraries that can search for the transmitted info and display it because in the data of the stream, the data is transmitted. The other option is to retrieve the feed information 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 complete product.
Clear Radio
To access the Streaming service and delete one of the streams:
- Click here in order to access the management of your product on the Manager Infomaniak (Need help?).
- Click directly on the nameallocated to the product concerned:
- Click on the name of the radio concerned:
- Click on the action menu ⋮ located to the right of the element concerned.
- Click on Remove:
- Enter the name of the radio to validate the deletion.
This guide explains how to properly configure a stream on the Radio streaming Infomaniak.
Configuring the broadcast of a radio stream
In order to access the Radio Streaming service:
- Click here in order to access the management of your product on the Manager Infomaniak (Need help?).
- Click directly on the nameallocated to the product concerned.
- Click on the name of the radio.
- Click on the button Add Stream:
- then a second time on the button Add Stream:
- Add a standard stream:
- Choose the desired options:
- Click on the button Save.
This guide explains how to specify a backup audio stream on the Radio streaming Infomaniak.
So if your main stream becomes unavailable, the backup stream will automatically take over the broadcast.
Create a backup stream
In order to access the Radio Streaming service:
- Click here in order to access the management of your product on the Manager Infomaniak (Need help?).
- Click directly on the nameallocated to the product concerned.
- Click on the name of the radio.
- Click on the button Add Stream to create a new stream and join it with a backup stream or Configure an existing stream in order to activate the option:
- Click the toggle switch button to activate the backup stream on your feed:
- Copy the information at your disposal to set your backup encoder.
- Save the activation of the backup stream at the bottom right of the page.
At the same place you can set the backup stream as a flow relays in order to manually enter the parameters corresponding to the backup audio stream:
Save the new information at the bottom right of the page.
This guide concerns listening information for Streaming Radio which can be exported to ACPM (former Digital OJD).
Preamble
- The Alliance pour les Numériques de la Presse et des Médias is an independent organisation in France, which certifies data relating to the dissemination, the audience, and the use of the media.
- This data, which is recognised as an official reference, supports media and advertising market players in the analysis, comparison and structuring of their strategies.
- Under the governance of its media organisations, the ACPM guarantees transparency, independence and methodological rigour; it ensures reliable certifications in line with developments in the media sector.
- Also take note of this other guide concerning a similar service but intended for Switzerland.
Managing ACPM certification
Prerequisites
- The Organization in which the Streaming Service is located must be established with an address in France.
- To activate the ACPM certification, please contact this service by email:
equipe-ojdnumerique@acpm.fr
. - Once the contract has been drawn up with the latter,contact Infomaniak supportgiving information about your ACPM and Infomaniak contract.
To manage the activation or deactivation of the service:
- Click here in order to access the management of your product on the Manager Infomaniak (Need help?).
- Click directly on the nameallocated to the product concerned.
- Click on the name of the audio stream concerned.
- Click on Parameters in the left side menu.
- Enable or disable the export of logs to ACPM with the toggle switch button:
This guide explains how to maintain control over your Streaming Radio MP3/AAC or HLS by activating single key protection (token) to decide e.g. whether a listener can listen to your radio or not.
Preamble
- The principle is simple: at each connection, you will make a request to the Infomaniak API which will return you in return a unique token with a limited and adjustable lifespan. This token will allow anyone who owns it to consume the flow during this period.
- You can protect an MP3/AAC or HLS stream independently of each other (idem for geolocation elsewhere).
- The activation of the restriction implies a change in the flow configuration which can take a few minutes to be replicated on the servers.
Protecting a single key audio stream
To do this, just go to the restrictions settings and activate the protection by token on the stream you want to secure:
- Click here in order to access the management of your product on the Manager Infomaniak (Need help?).
- Click directly on the nameallocated to the product concerned.
- Click on the name of the audio stream concerned.
- Click on Restrictions in the left side menu.
- Choose HLS if necessary.
- Click on the action menu ⋮located to the right of the element concerned.
- Click on Restriction by token:
Then activate the protection.
Be careful, when you enable 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 token API Radio
To access the Radio API, you must first authenticate with a token application. This step is only to be done once. To create this application token, read this guide.
The scope is radio and unlimited life 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.
Example of use in PHP language
For MP3/AAC or HLS, the code can be substantially the same, only the URL called in POST changes in its form.
Paste the generated token in place of the indicated token below:
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're going to create the token, the token creation URL is broken 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 road 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 road will be: https://api.infomaniak.com/1/radios/acl/hls_streams/myradiostream/token
Example in the case of MP3 / AAFC, consider adjusting:
$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 when loading the page, the listener will have "window" seconds to start reading the stream. Beyond this time, the token will expire, and the stream will no longer be launched unless the page is reloaded. Depending on your needs and your use case, it will be necessary to adjust this time frame in the best possible way.
You will also need to replace below the URL to read your stream instead of the one indicated while keeping the parameter $token
At the end. And finally, we show the Player (here a simple html5 tag, but of course we can add any overlay after that, the token being passed in the settings) $_GET
of the url).
$streamUrl = "https://newradiotest.ice.infomaniak.ch/newradiotest-128.aac?$token";
echo "<audio controls=""><source src="$streamUrl"></audio>";