Answer the question
In order to leave comments, you need to log in
Export a Yandex.Music playlist?
Hello!
I recently decided to switch to Spotify and I want to transfer my music from Yandex Music there. I figured out the import services: soundiiz.com, playlist-converter.net. I want to know how to export the "I like" playlist as a playlist file with the extension .pls, .m3u or at least as a text file, where the songs will be written line by line in the form "Artist" - "Composition name"
Answer the question
In order to leave comments, you need to log in
Here is a small PHP script
<?php
// https://music.yandex.ru/users/{owner}/playlists/{kinds}
$uriRaw = 'https://music.yandex.ru/users/vadim.loxx/playlists/1073';
$uriRaw = explode('/', $uriRaw);
$owner = $uriRaw[4];
$kinds = $uriRaw[6];
$uri = 'https://music.yandex.ru/handlers/playlist.jsx?owner=' . $owner . '&kinds=' . $kinds;
$responseRaw = file_get_contents($uri);
$response = json_decode($responseRaw);
$playlistTitle = $response->playlist->title;
$tracks = $response->playlist->tracks;
file_exists($playlistTitle . '.txt') ? unlink($playlistTitle . '.txt') : null;
// Генерация с нумерацией или без нее
$flagNums = true;
$numSong = 1;
foreach ($tracks as $track) {
$artistsNames = [];
foreach ($track->artists as $artist) {
$artistsNames[] = $artist->name;
}
$artistsNames = implode(', ', $artistsNames);
$flagNums ? $fullTrack = $numSong++ . ') ' . $artistsNames . ' - ' . $track->title . PHP_EOL :
$fullTrack = $artistsNames . ' - ' . $track->title . PHP_EOL;
file_put_contents($playlistTitle . '.txt', $fullTrack, FILE_APPEND);
}
echo 'Done!';
echo '<br>';
echo '<a href="' . $playlistTitle . '.txt">Список песен</a>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question