{"id":90,"date":"2017-03-19T17:31:49","date_gmt":"2017-03-19T15:31:49","guid":{"rendered":"http:\/\/wiesing.net\/?p=90"},"modified":"2018-08-19T21:52:54","modified_gmt":"2018-08-19T19:52:54","slug":"spotifyplaylistrobot","status":"publish","type":"post","link":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/","title":{"rendered":"Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify"},"content":{"rendered":"<p>Inspiriert durch den Artikel \u201eFerngestreamt \u2013 Google Play Music und Spotify per Skript steuern\u201c in der c&#8217;t 19\/2016 S. 170 (<a href=\"https:\/\/www.heise.de\/ct\/ausgabe\/2016-19-Google-Play-Music-und-Spotify-per-Skript-steuern-3305800.html\">https:\/\/www.heise.de\/ct\/ausgabe\/2016-19-Google-Play-Music-und-Spotify-per-Skript-steuern-3305800.html<\/a>) habe ich ein kleines Projekt gestartet. Mein erkl\u00e4rtes Ziel war es, die Playlist von 1Live Plan B automatisch in eine Playlist auf Spotify zu verwandeln. Die Zusammenstellung der Titel, welche derzeit im Webchannel 1Live Plan B zu h\u00f6ren sind, findet sich gut aufbereitet unter der folgenden URL: <a href=\"http:\/\/www1.wdr.de\/radio\/1live\/on-air\/1live-channels\/plan-b-channel-playlist-100.html\">http:\/\/www1.wdr.de\/radio\/1live\/on-air\/1live-channels\/plan-b-channel-playlist-100.html<\/a>.<!--more--><\/p>\n<p>Da ich jedoch nach M\u00f6glichkeit nicht, wie im Artikel beschrieben, mittels Python\u00a0 sondern Java auf die Web API von Spotify zugreifen wollte, musste ich zun\u00e4chst nach einer Alternative suchen. Mit <a href=\"https:\/\/github.com\/thelinmichael\/spotify-web-api-java\">https:\/\/github.com\/thelinmichael\/spotify-web-api-java<\/a> bin ich dann auch f\u00fcndig geworden.<\/p>\n<p>Als Erstes musste die Anwendung bei Spotify im eigenen Benutzerkonto registriert werden, wozu die folgende Adresse aufzurufen ist: <a href=\"https:\/\/developer.spotify.com\/my-applications\/\">https:\/\/developer.spotify.com\/my-applications\/<\/a>. Client Id, Client Secret und Redirect URI sind dann in der SpotifyPlaylistRobot.cfg ebenso zu hinterlegen wie der Benutzername.<br \/>\nDar\u00fcber hinaus ben\u00f6tigen wir eine neue Playlist. Nach dem Erstellen kann die ben\u00f6tigte Id z.B. im Webplayer gut eingesehen werden, da diese beim Aufruf der Playlist in der URL erscheint.<\/p>\n<p>Ein kleiner Fallstrick war, dass f\u00fcr die \u00c4nderung von Playlisten eines Benutzers der \u201eClient Credentials flow\u201c nicht ausreicht. Stattdessen musste der komliziertere Weg \u201eAuthorization Code Grant\u201c verwendet werden. Eine Besonderheit dabei ist, dass die Autorisierung vom Spotify Webservice vorgenommen und der ben\u00f6tigte Code dann an die hinterlegte Redirect URL \u00fcbermittelt wird. Da ich jedoch ein reines Java-Programm ohne Webserver haben wollte,\u00a0 ist an dieser Stelle ein kleiner Workaround notwendig. Es wird nun einfach in der Kommandozeile die aufzurufende URL ausgegeben und die Redirect-URL abgefragt. D.h. der Benutzer muss die gennante URL mit seinem Browsser aufrufen, sich daraufhin bei Spotify anmelden und die Berechtigungen f\u00fcr die Anwendungen gew\u00e4hren. Anschlie\u00dfend ist die Redirect-URL wiederum in die Kommandozeile zu kopieren. Das Programm schneidet anschlie\u00dfend automatisch die ben\u00f6tigten Werte aus der URL heraus und setzt sich das Refresh Token. In diesem Schritt werden dann auch die Werte f\u00fcr accessToken und refreshToken in der Konfiguration gesetzt. Gl\u00fccklicherweise kann das Programm ab dem Zeitpunkt sein Token ohne weitere Benutzereingriffe aktuell halten. Dazu ist lediglich erforderlich, dass jede Stunde das Programm l\u00e4uft um den Refresh durchzuf\u00fchren. Dies l\u00e4ssst sich z.B. \u00fcber einen CronJob realisieren. Falls es dazu kommen sollte, dass ein Login nicht mehr m\u00f6glich ist, da das Refresh Token bereits abgelaufen ist, m\u00fcssen lediglich die Werte von accessToken und refreshToken in der Konfiguration gel\u00f6scht und der Vorgang mit der manuellen Anmeldung wiederholt werden.<\/p>\n<p>Die kompletten Sourcen des Projektes sind unter <a href=\"https:\/\/github.com\/michaelwiesing\/SpotifyPlaylistRobot\">https:\/\/github.com\/michaelwiesing\/SpotifyPlaylistRobot<\/a> ver\u00f6ffentlicht. Es handelt sich\u00a0 um ein Maven Projekt.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inspiriert durch den Artikel \u201eFerngestreamt \u2013 Google Play Music und Spotify per Skript steuern\u201c in der c&#8217;t 19\/2016 S. 170 (https:\/\/www.heise.de\/ct\/ausgabe\/2016-19-Google-Play-Music-und-Spotify-per-Skript-steuern-3305800.html) habe ich ein kleines Projekt gestartet. Mein erkl\u00e4rtes Ziel war es, die Playlist von 1Live Plan B automatisch in eine Playlist auf Spotify zu verwandeln. Die Zusammenstellung der Titel, welche derzeit im Webchannel 1Live &hellip; <a href=\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\" class=\"more-link\"><span class=\"screen-reader-text\">Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spotify Playlist Robot - Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify - wiesing.net<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spotify Playlist Robot - Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify - wiesing.net\" \/>\n<meta property=\"og:description\" content=\"Inspiriert durch den Artikel \u201eFerngestreamt \u2013 Google Play Music und Spotify per Skript steuern\u201c in der c&#8217;t 19\/2016 S. 170 (https:\/\/www.heise.de\/ct\/ausgabe\/2016-19-Google-Play-Music-und-Spotify-per-Skript-steuern-3305800.html) habe ich ein kleines Projekt gestartet. Mein erkl\u00e4rtes Ziel war es, die Playlist von 1Live Plan B automatisch in eine Playlist auf Spotify zu verwandeln. Die Zusammenstellung der Titel, welche derzeit im Webchannel 1Live &hellip; Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify weiterlesen &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\" \/>\n<meta property=\"og:site_name\" content=\"wiesing.net\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-19T15:31:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-08-19T19:52:54+00:00\" \/>\n<meta name=\"author\" content=\"michael\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"michael\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\"},\"author\":{\"name\":\"michael\",\"@id\":\"https:\/\/wiesing.net\/#\/schema\/person\/2181896027b3fa9ecf036fa7af159b2c\"},\"headline\":\"Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify\",\"datePublished\":\"2017-03-19T15:31:49+00:00\",\"dateModified\":\"2018-08-19T19:52:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\"},\"wordCount\":484,\"commentCount\":0,\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\",\"url\":\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\",\"name\":\"Spotify Playlist Robot - Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify - wiesing.net\",\"isPartOf\":{\"@id\":\"https:\/\/wiesing.net\/#website\"},\"datePublished\":\"2017-03-19T15:31:49+00:00\",\"dateModified\":\"2018-08-19T19:52:54+00:00\",\"author\":{\"@id\":\"https:\/\/wiesing.net\/#\/schema\/person\/2181896027b3fa9ecf036fa7af159b2c\"},\"breadcrumb\":{\"@id\":\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wiesing.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wiesing.net\/#website\",\"url\":\"https:\/\/wiesing.net\/\",\"name\":\"wiesing.net\",\"description\":\"IT-Themen, die mich in meiner Freizeit besch\u00e4ftigen\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wiesing.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wiesing.net\/#\/schema\/person\/2181896027b3fa9ecf036fa7af159b2c\",\"name\":\"michael\",\"sameAs\":[\"https:\/\/wiesing.net\"],\"url\":\"https:\/\/wiesing.net\/index.php\/author\/michael\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spotify Playlist Robot - Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify - wiesing.net","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/","og_locale":"de_DE","og_type":"article","og_title":"Spotify Playlist Robot - Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify - wiesing.net","og_description":"Inspiriert durch den Artikel \u201eFerngestreamt \u2013 Google Play Music und Spotify per Skript steuern\u201c in der c&#8217;t 19\/2016 S. 170 (https:\/\/www.heise.de\/ct\/ausgabe\/2016-19-Google-Play-Music-und-Spotify-per-Skript-steuern-3305800.html) habe ich ein kleines Projekt gestartet. Mein erkl\u00e4rtes Ziel war es, die Playlist von 1Live Plan B automatisch in eine Playlist auf Spotify zu verwandeln. Die Zusammenstellung der Titel, welche derzeit im Webchannel 1Live &hellip; Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify weiterlesen &rarr;","og_url":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/","og_site_name":"wiesing.net","article_published_time":"2017-03-19T15:31:49+00:00","article_modified_time":"2018-08-19T19:52:54+00:00","author":"michael","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"michael","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#article","isPartOf":{"@id":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/"},"author":{"name":"michael","@id":"https:\/\/wiesing.net\/#\/schema\/person\/2181896027b3fa9ecf036fa7af159b2c"},"headline":"Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify","datePublished":"2017-03-19T15:31:49+00:00","dateModified":"2018-08-19T19:52:54+00:00","mainEntityOfPage":{"@id":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/"},"wordCount":484,"commentCount":0,"inLanguage":"de","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/","url":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/","name":"Spotify Playlist Robot - Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify - wiesing.net","isPartOf":{"@id":"https:\/\/wiesing.net\/#website"},"datePublished":"2017-03-19T15:31:49+00:00","dateModified":"2018-08-19T19:52:54+00:00","author":{"@id":"https:\/\/wiesing.net\/#\/schema\/person\/2181896027b3fa9ecf036fa7af159b2c"},"breadcrumb":{"@id":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wiesing.net\/index.php\/2017\/03\/19\/spotifyplaylistrobot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wiesing.net\/"},{"@type":"ListItem","position":2,"name":"Spotify Playlist Robot &#8211; Automatische Synchronisation der 1LIVE Plan B Playlist mit Spotify"}]},{"@type":"WebSite","@id":"https:\/\/wiesing.net\/#website","url":"https:\/\/wiesing.net\/","name":"wiesing.net","description":"IT-Themen, die mich in meiner Freizeit besch\u00e4ftigen","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wiesing.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/wiesing.net\/#\/schema\/person\/2181896027b3fa9ecf036fa7af159b2c","name":"michael","sameAs":["https:\/\/wiesing.net"],"url":"https:\/\/wiesing.net\/index.php\/author\/michael\/"}]}},"_links":{"self":[{"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":19,"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions\/120"}],"wp:attachment":[{"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiesing.net\/index.php\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}