From c035ce941ec4338e75f9d646cfdc9129abb9b413 Mon Sep 17 00:00:00 2001 From: Tilman Date: Fri, 21 Jun 2019 00:27:34 +0200 Subject: [PATCH] bugfix streams --- .../de/tilman/cardcreator/CardCreator.java | 99 +++++++++++++++++-- 1 file changed, 91 insertions(+), 8 deletions(-) diff --git a/cardcreator/src/de/tilman/cardcreator/CardCreator.java b/cardcreator/src/de/tilman/cardcreator/CardCreator.java index fd4ff03..6b94c6e 100644 --- a/cardcreator/src/de/tilman/cardcreator/CardCreator.java +++ b/cardcreator/src/de/tilman/cardcreator/CardCreator.java @@ -13,7 +13,6 @@ import com.itextpdf.barcodes.qrcode.EncodeHintType; import com.itextpdf.io.image.ImageDataFactory; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.geom.PageSize; -import com.itextpdf.kernel.log.SystemOutCounter; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfWriter; @@ -29,6 +28,7 @@ import com.wrapper.spotify.SpotifyApi; import com.wrapper.spotify.exceptions.SpotifyWebApiException; import com.wrapper.spotify.model_objects.credentials.ClientCredentials; import com.wrapper.spotify.model_objects.specification.Album; +import com.wrapper.spotify.model_objects.specification.Playlist; import com.wrapper.spotify.model_objects.specification.Track; import com.wrapper.spotify.requests.authorization.client_credentials.ClientCredentialsRequest; @@ -85,8 +85,6 @@ public class CardCreator { System.out.println(link); Card card = new Card(link); - card.qrcode = new BarcodeQRCode(link); - card.qrcode.setHints(hints); cards.add(card); if (link.startsWith("spotify:album:")) { @@ -106,6 +104,14 @@ public class CardCreator { URL url = new URL(track.getAlbum().getImages()[0].getUrl()); card.cover = new Image(ImageDataFactory.create(url)); } + else if (link.startsWith("spotify:playlist:") ) { + String spotifyId = link.substring(17); + Playlist playlist = spotifyApi.getPlaylist(spotifyId).build().execute(); + card.title = playlist.getName(); + card.artist = playlist.getDescription(); + URL url = new URL(playlist.getImages()[0].getUrl()); + card.cover = new Image(ImageDataFactory.create(url)); + } else { String coverPath = null; @@ -136,11 +142,9 @@ public class CardCreator { // FIXME dirty cover retrieval hack if (card.cover == null) { // "/run/user/1000/gvfs/sftp:host=qudio.local,user=volumio/data/INTERNAL" - // "/run/user/1000/gvfs/smb-share:server=cubon,share=hidrive/Media/Audio" // "/run/user/1000/gvfs/sftp:host=qudio.local,user=volumio/data" - // "/media/hidrive/Media/Audio/Kinder" - // "/run/user/1000/gvfs/smb-share:server=cubon,share=hidrive/Media/Audio" - String path = "/run/user/1000/gvfs/smb-share:server=cubon,share=hidrive/Media/Audio/Kinder" + link.substring(link.indexOf("/", 4)) + "/cover.jpg"; + // "/run/user/1000/gvfs/smb-share:server=cubon,share=hidrive/Media/Audio/Kinder" + String path = "/run/user/1000/gvfs/smb-share:server=qudio,share=internal%20storage" + link.substring(link.indexOf("/", 4)) + "/cover.jpg"; System.out.println(path); @@ -156,6 +160,9 @@ public class CardCreator { } + + card.qrcode = new BarcodeQRCode(link); + card.qrcode.setHints(hints); } return cards; @@ -431,6 +438,82 @@ public class CardCreator { public static void main(String[] args) throws Exception { List links = Arrays.asList( + // Josefine +// "/INTERNAL/Astrid Lindgren - Die Kinder aus der Krachmacherstraße", +// "/INTERNAL/Astrid Lindgren - Lotta zieht um", +// "/INTERNAL/Astrid Lindgren - Michel bringt die Welt in Ordnung", +// "/INTERNAL/Astrid Lindgren - Wir Kinder aus Büllerbü", +// "/INTERNAL/Der Grüffelo und Das Grüffelokind", +// "/INTERNAL/Der Räuber Hotzenplotz/CD 1", +// "/INTERNAL/Der Räuber Hotzenplotz/CD 2", +// "/INTERNAL/Janosch - Das Beste von Tiger & Bär", +// "/INTERNAL/Sing mit mir Kinderlieder/Sing mit mir Kinderlieder", +// "/INTERNAL/Sing mit mir Kinderlieder/Sing mit mir Kinderlieder 2", +// "/INTERNAL/Sonst noch was", + + "spotify:album:6QpCsN1do9sWdzxMzP6vAm", + "spotify:album:0zDRwoqvJYhvfhcvQYzfcZ", + "spotify:album:5qvokPibHLO3e47oV4wyhz", + "spotify:album:4ErYqkUdfkAmsgltEPJKH7", + "spotify:album:2ZQKn9GVeJalLEuh3BvuOB", + "spotify:album:66YZOif5ogyl1O0rFT28HM", + "spotify:album:2UNXd8SieHWtTM5g0VMeGv", + "spotify:album:3ixBUKtl7HtxSZECC3YnNb", + "spotify:album:6NkPN8kGJftA5ZURbZTKve", + "spotify:album:7o6y1qwFIJolo0ZKUpPTR9", + "spotify:album:1bK1QqLOaESZgs2pXYY4J6", + "spotify:album:5Dlq8pYslsD1dstLQR7NFw", + "spotify:album:5nCCuIqR5MsRi3tI90Vu4T", + "spotify:album:2xo9X40JoJuDO64Iy5mpNY", + "spotify:album:7A5GQZrirxYgjWCTGpbnbs", + "spotify:album:4ghoOGAttLAGG5LHZ2TyJI", + "spotify:album:1ateqhraMBgvZdaYeMuIok", + "spotify:album:5bt9jrIAYM5pCxX41xBuq2", + "spotify:album:4IzmCaIX0eEgRb7xsQFkfv", + "spotify:album:7iQo6EXjMtLPorNrw2vlXW", + "spotify:album:6K5a3qRU976BpPIEG9mZnb", + "spotify:album:4ix6YihDNef0CrY6yqAZAp", + "spotify:album:6Jv639ZVhVhh3BNVPkBbTx", + "spotify:album:76ZUfDiykUU2cf6CHoQ1f0", + "spotify:album:53dBXzbp9pMtV3CDIQHg42", + "spotify:album:17r2Acz7jO4CK7HH8vPB2k", + "spotify:album:4NHm49J138o8iOADgQfLwk", + "spotify:album:4fAxKCklCcMxl7LAxBeGDD", + "spotify:album:2qffSlb9FcXLjuAmVmxusg", + "spotify:playlist:0Edvyr1N6rCXdlaXJXFTRm", + "spotify:playlist:1MHhoAAkJtenHSc2auRjik", + "spotify:playlist:6F2ndy14LlaUhCoMNUCmS0", + "spotify:album:6xEB4R8xiXssXH8dSYoQAS", + "spotify:album:1pmyleYQz8MWZszsFvr7xj", + "spotify:album:3dhTDo27zieo3NKG9yWDOm", + "spotify:album:7fj4TDf4T2thg5BuFUluNY", + "spotify:album:0gBwfz0Li2PAs6RtcC34Sf", + "spotify:album:3TNwLmVlMD5FH9lfreRTop", + "spotify:album:6VuNMt3hjDKuO0JPu1U8KC", + "spotify:album:1MawyFXVs44JGcgDm7sNRF", + "spotify:album:6dUE7mRlGLJriQtHxM7LZN", + "spotify:album:1Wstoinsm4CGJ4ybpWg8iH", + "spotify:album:721jCM2jOWLTF90qAXsm4j", + "spotify:album:7Auu9enkXXr2Cb7LM3ZZBg", + "spotify:album:57nolXNzaxSbmcQ25xUado", + "spotify:album:7MmGDWg8mBqZmxgQfAFaGx", + "spotify:album:2U3tr7tB5kvIobxriuwY4K", + "spotify:album:21Vw0oLYsqJVGlibJ08mRE", + "spotify:album:3o1p0dVvbb4BIKAfP8xVVL", + "spotify:album:1Xx4o41IUa37w2nB0tOReT", + "spotify:album:3HIGYfO3lJLnRXFz4RnIrw", + "spotify:album:0AfOsu9wcvDu8Cn57xynoh", + "spotify:album:2BmQu8dBAJHd8i1P8suRm4", + "spotify:album:24edFfeEP7oy8BWGatc5CQ", + "spotify:album:66Rt4KLkF7jhSPMLi223Zv", + "spotify:album:2upvzA60OLbOW9M0QKQ0hO", + "spotify:album:00XbTSVi9wVH1jYiYr2Vc9", + "spotify:album:6ZsR4Vx24b1E1PkiGSUQSE", +// "spotify:album:6RKqqB83qVn5SAWXJ5uCpM", + "spotify:album:7wGBvXA1TKtlqyJq6Mtsl5", + "spotify:album:6AdTIgvKhY5knelEsDWJx8", + + /* "spotify:album:1X2HXE2lAqdmD8VjiBX8Tn", "spotify:album:5nCA2mAr3rFzk1A6LZXDYm", "spotify:album:1Vc2BZntRGIdv3Ul8AM6cz", @@ -576,7 +659,7 @@ public class CardCreator { "NAS/share/Wir Kinder vom Kleistpark - #backstage", "NAS/share/Wir Kinder vom Kleistpark - feiern Weihnachten", "NAS/share/Wir Kinder vom Kleistpark - machen Musik", - "NAS/share/Wunderbar, der Herbst ist da", + "NAS/share/Wunderbar, der Herbst ist da", */ // "https://www.medienkompetenzportal-nrw.de/fileadmin/medienkompetenzportal-nrw/inhalte/MPA/EdM/2018-05/KiRaKa_Logo.jpg|KiRaKa|http://www.wdr.de/wdrlive/media/kiraka.m3u", "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Radio_Teddy_Logo.svg/1200px-Radio_Teddy_Logo.svg.png|Radio Teddy|http://streamtdy.ir-media-tec.com/live/mp3-128/web/play.mp3" );