{"id":415364,"date":"2024-06-30T00:19:39","date_gmt":"2024-06-30T00:19:39","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=415364"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=415364","title":{"rendered":"<span>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0440\u0435\u043a\u043e\u0432 \u0441\u043e Spotify \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0438\u0442\u043e\u043d\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0445\u0430\u0431\u0440\u0430! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f python \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u043a\u0438 \u0441\u043e \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044f. \u041e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u044d\u0442\u043e \u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0438\u0434\u0435\u043e \u0441 \u044e\u0442\u0443\u0431\u0430. \u0414\u0430-\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0435\u0441\u043d\u0438 \u043d\u0430 \u044e\u0442\u0443\u0431\u0435 \u0438 \u043a\u0430\u0447\u0430\u0442\u044c \u0438\u0445 \u043e\u0442\u0442\u0443\u0434\u0430. \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 GitHub \u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0431\u043e\u043d\u0443\u0441\u043e\u043c \u0432 \u043a\u043e\u043d\u0446\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fb7\/a9c\/cca\/fb7a9cccaae483826a85a7dbb10ae91e.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b\" width=\"715\" height=\"141\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb7\/a9c\/cca\/fb7a9cccaae483826a85a7dbb10ae91e.png\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b<\/figcaption><\/figure>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f python \u0435\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"https:\/\/www.python.org\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435<\/a>. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0438\u0442\u043e\u043d\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <code>pip install spotipy youtubesearchpython youtube_dl<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c ffmpeg. \u041a\u0430\u043a \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435.<br \/>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u043c \u043d\u0430 <a href=\"https:\/\/developer.spotify.com\/dashboard\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443<\/a>. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/147\/547\/54f\/14754754fd79b49736d07b23d7a89e93.png\" alt=\"\u041f\u0430\u043d\u0435\u043b\u044c spotify\" title=\"\u041f\u0430\u043d\u0435\u043b\u044c spotify\" width=\"1279\" height=\"866\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/147\/547\/54f\/14754754fd79b49736d07b23d7a89e93.png\"\/><figcaption>\u041f\u0430\u043d\u0435\u043b\u044c spotify<\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0443 <strong>LOG IN<\/strong> \u0438 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439 spotify \u0430\u043a\u043a\u0430\u0443\u043d\u0442. \u0417\u0430\u0448\u043b\u0438? \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0436\u0430\u0432 \u043d\u0430 \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0443 <strong>CREATE AN APP<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f38\/e36\/5fb\/f38e365fb9fb908021672acc069f5bf6.png\" alt=\"\u041f\u0430\u043d\u0435\u043b\u044c Spotify\" title=\"\u041f\u0430\u043d\u0435\u043b\u044c Spotify\" width=\"1279\" height=\"866\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f38\/e36\/5fb\/f38e365fb9fb908021672acc069f5bf6.png\"\/><figcaption>\u041f\u0430\u043d\u0435\u043b\u044c Spotify<\/figcaption><\/figure>\n<p>\u0412\u0432\u043e\u0434\u0438\u043c \u043b\u044e\u0431\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0436\u0430\u0432 <strong>CREATE<\/strong>. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041e\u0442\u0441\u044e\u0434\u0430 \u043c\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c <strong>Client ID<\/strong> \u0438 <strong>Client Secret<\/strong>. \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2eb\/c02\/4d4\/2ebc024d412899fdc3082192137cac83.png\" width=\"1168\" height=\"301\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2eb\/c02\/4d4\/2ebc024d412899fdc3082192137cac83.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<br \/><code>from\u00a0__future__\u00a0import\u00a0unicode_literals<br \/>import\u00a0spotipy<br \/>from\u00a0spotipy.oauth2\u00a0import\u00a0SpotifyOAuth,\u00a0SpotifyClientCredentials<br \/>from\u00a0youtubesearchpython\u00a0import\u00a0VideosSearch<br \/>import\u00a0youtube_dl<\/p>\n<p><\/code>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<br \/><code>url\u00a0=\u00a0input(\"\u0412\u0432\u0435\u0434\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u0440\u0435\u043a: \")<br \/>client_id\u00a0=\u00a0\"\" # \u0421\u044e\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0430\u043d\u0435\u043b\u0438 \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044f<br \/>secret\u00a0=\u00a0\"\" # \u0421\u044e\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0430\u043d\u0435\u043b\u0438 \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044f<br \/><\/code><br \/>\u041d\u0430\u0447\u043d\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434:<br \/>1. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044e<br \/><code>auth_manager\u00a0=\u00a0SpotifyClientCredentials(client_id=client_id,\u00a0client_secret=secret)<br \/>spotify\u00a0=\u00a0spotipy.Spotify(auth_manager=auth_manager)<\/p>\n<p><\/code>2. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<code><br \/>def music(result):<br \/>  performers = \"\"<br \/>  music = result['name']<br \/>  for names in result[\"artists\"]:<br \/>    performers = performers + names[\"name\"] + \", \"<br \/>  performers = performers.rstrip(\", \")<br \/>  video = search(music, performers)<br \/>  name = f\"{performers} - {music}\"<br \/>  print(name)<br \/>  ydl_opts = {'format': 'bestaudio\/best', 'postprocessors': [{'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192',}], 'outtmpl': f'.\/{name}.webm'}<br \/>  download(video, ydl_opts)<br \/>  print(\"\u0413\u043e\u0442\u043e\u0432\u043e!\")<br \/><\/code><br \/>3. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0442\u0440\u0435\u043a\u0430<br \/><code>def search(music, performers):<br \/>\u00a0\u00a0videosSearch = VideosSearch(f'{performers} - {music}', limit = 1)<br \/>\u00a0\u00a0videoresult = videosSearch.result()[\"result\"][0][\"link\"]<br \/>\u00a0\u00a0return videoresult<br \/><\/code><br \/>4. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0442\u0440\u0435\u043a\u0430<br \/><code>def download(videoresult, ydl_opts):<br \/>  with youtube_dl.YoutubeDL(ydl_opts) as ydl:<br \/>    ydl.download([videoresult])<\/code><\/p>\n<p>5. \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u0438\u0441\u043a.<br \/><code>result = spotify.track(url)<br \/>music(result)<\/code><\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fb7\/a9c\/cca\/fb7a9cccaae483826a85a7dbb10ae91e.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b\" width=\"715\" height=\"141\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb7\/a9c\/cca\/fb7a9cccaae483826a85a7dbb10ae91e.png\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b<\/figcaption><\/figure>\n<p>\u0422\u0440\u0435\u043a \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438 \u043a\u043e\u0434.<\/p>\n<h2>\u041a\u043e\u043d\u0435\u0446<\/h2>\n<p>\u0412\u043e\u0442 \u0438 \u043f\u043e\u0434\u043e\u0448\u043b\u0430 \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u0435\u0439\u043a\u0430 \u043a \u043a\u043e\u043d\u0446\u0443. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u043a\u043e\u0434 \u0438 \u0431\u043e\u043d\u0443\u0441 \u0435\u0441\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/DevilFireFox\/SpotyDownload\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>. \u0423\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/582170\/\"> https:\/\/habr.com\/ru\/articles\/582170\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0445\u0430\u0431\u0440\u0430! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f python \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u043a\u0438 \u0441\u043e \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044f. \u041e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u044d\u0442\u043e \u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0438\u0434\u0435\u043e \u0441 \u044e\u0442\u0443\u0431\u0430. \u0414\u0430-\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0435\u0441\u043d\u0438 \u043d\u0430 \u044e\u0442\u0443\u0431\u0435 \u0438 \u043a\u0430\u0447\u0430\u0442\u044c \u0438\u0445 \u043e\u0442\u0442\u0443\u0434\u0430. \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 GitHub \u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0431\u043e\u043d\u0443\u0441\u043e\u043c \u0432 \u043a\u043e\u043d\u0446\u0435.<\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b<\/figcaption><\/figure>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f python \u0435\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"https:\/\/www.python.org\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435<\/a>. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0438\u0442\u043e\u043d\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <code>pip install spotipy youtubesearchpython youtube_dl<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c ffmpeg. \u041a\u0430\u043a \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435.<br \/>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u043c \u043d\u0430 <a href=\"https:\/\/developer.spotify.com\/dashboard\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443<\/a>. <\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u0430\u043d\u0435\u043b\u044c spotify<\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0443 <strong>LOG IN<\/strong> \u0438 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439 spotify \u0430\u043a\u043a\u0430\u0443\u043d\u0442. \u0417\u0430\u0448\u043b\u0438? \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0436\u0430\u0432 \u043d\u0430 \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0443 <strong>CREATE AN APP<\/strong><\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u0430\u043d\u0435\u043b\u044c Spotify<\/figcaption><\/figure>\n<p>\u0412\u0432\u043e\u0434\u0438\u043c \u043b\u044e\u0431\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0436\u0430\u0432 <strong>CREATE<\/strong>. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041e\u0442\u0441\u044e\u0434\u0430 \u043c\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c <strong>Client ID<\/strong> \u0438 <strong>Client Secret<\/strong>. \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<br \/><code>from\u00a0__future__\u00a0import\u00a0unicode_literals<br \/>import\u00a0spotipy<br \/>from\u00a0spotipy.oauth2\u00a0import\u00a0SpotifyOAuth,\u00a0SpotifyClientCredentials<br \/>from\u00a0youtubesearchpython\u00a0import\u00a0VideosSearch<br \/>import\u00a0youtube_dl<\/p>\n<p><\/code>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<br \/><code>url\u00a0=\u00a0input(\"\u0412\u0432\u0435\u0434\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u0440\u0435\u043a: \")<br \/>client_id\u00a0=\u00a0\"\" # \u0421\u044e\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0430\u043d\u0435\u043b\u0438 \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044f<br \/>secret\u00a0=\u00a0\"\" # \u0421\u044e\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0430\u043d\u0435\u043b\u0438 \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044f<br \/><\/code><br \/>\u041d\u0430\u0447\u043d\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434:<br \/>1. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u043f\u043e\u0442\u0438\u0444\u0430\u044e<br \/><code>auth_manager\u00a0=\u00a0SpotifyClientCredentials(client_id=client_id,\u00a0client_secret=secret)<br \/>spotify\u00a0=\u00a0spotipy.Spotify(auth_manager=auth_manager)<\/p>\n<p><\/code>2. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<code><br \/>def music(result):<br \/>  performers = \"\"<br \/>  music = result['name']<br \/>  for names in result[\"artists\"]:<br \/>    performers = performers + names[\"name\"] + \", \"<br \/>  performers = performers.rstrip(\", \")<br \/>  video = search(music, performers)<br \/>  name = f\"{performers} - {music}\"<br \/>  print(name)<br \/>  ydl_opts = {'format': 'bestaudio\/best', 'postprocessors': [{'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192',}], 'outtmpl': f'.\/{name}.webm'}<br \/>  download(video, ydl_opts)<br \/>  print(\"\u0413\u043e\u0442\u043e\u0432\u043e!\")<br \/><\/code><br \/>3. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0442\u0440\u0435\u043a\u0430<br \/><code>def search(music, performers):<br \/>\u00a0\u00a0videosSearch = VideosSearch(f'{performers} - {music}', limit = 1)<br \/>\u00a0\u00a0videoresult = videosSearch.result()[\"result\"][0][\"link\"]<br \/>\u00a0\u00a0return videoresult<br \/><\/code><br \/>4. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0442\u0440\u0435\u043a\u0430<br \/><code>def download(videoresult, ydl_opts):<br \/>  with youtube_dl.YoutubeDL(ydl_opts) as ydl:<br \/>    ydl.download([videoresult])<\/code><\/p>\n<p>5. \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u0438\u0441\u043a.<br \/><code>result = spotify.track(url)<br \/>music(result)<\/code><\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430:<\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b<\/figcaption><\/figure>\n<p>\u0422\u0440\u0435\u043a \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438 \u043a\u043e\u0434.<\/p>\n<h2>\u041a\u043e\u043d\u0435\u0446<\/h2>\n<p>\u0412\u043e\u0442 \u0438 \u043f\u043e\u0434\u043e\u0448\u043b\u0430 \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u0435\u0439\u043a\u0430 \u043a \u043a\u043e\u043d\u0446\u0443. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u043a\u043e\u0434 \u0438 \u0431\u043e\u043d\u0443\u0441 \u0435\u0441\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/DevilFireFox\/SpotyDownload\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>. \u0423\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/582170\/\"> https:\/\/habr.com\/ru\/articles\/582170\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-415364","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=415364"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415364\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=415364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=415364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=415364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}