package de.tilman.cardcreator;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import com.itextpdf.barcodes.BarcodeQRCode;
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.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfNumber;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.borders.SolidBorder;
import com.itextpdf.layout.element.Cell;
import com.itextpdf.layout.element.Image;
import com.itextpdf.layout.element.Paragraph;
import com.itextpdf.layout.element.Table;
import com.itextpdf.layout.property.TextAlignment;
import com.itextpdf.layout.property.UnitValue;
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;

public class CardCreator {
	
	public static final float mmUnit = 72f/25.4f; // see https://itextpdf.com/en/resources/faq/technical-support/itext-7/how-define-width-cell
	public static final int cardsPerLine = 6;

	public static final String DEST = "results/simple_table.pdf";
	public static final PdfNumber INVERTEDPORTRAIT = new PdfNumber(180);
	public static final PdfNumber LANDSCAPE = new PdfNumber(90);
	public static final PdfNumber PORTRAIT = new PdfNumber(0);
	public static final PdfNumber SEASCAPE = new PdfNumber(270);

	private static final String clientId = "d104434912874fbf9ff42e5a91db5179";
	private static final String clientSecret = "6acdb874210942128ba4991c4f7228b5";

	private static final SpotifyApi spotifyApi = new SpotifyApi.Builder().setClientId(clientId)
			.setClientSecret(clientSecret).build();
	private static final ClientCredentialsRequest clientCredentialsRequest = spotifyApi.clientCredentials().build();

	public CardCreator(List<String> links) {
		List<Card> cards;

		try {
			final ClientCredentials clientCredentials = clientCredentialsRequest.execute();

			// Set access token for further "spotifyApi" object usage
			spotifyApi.setAccessToken(clientCredentials.getAccessToken());
			
			cards = fetchCardData(links);
			
			File file = new File(DEST);
			file.getParentFile().mkdirs();
			
			createFoldingPdf(DEST, sortCards(cards));
			
		} catch (IOException | SpotifyWebApiException e) {
			System.out.println("Error: " + e.getMessage());
			e.printStackTrace();
		} catch (Exception e) {
			System.out.println("Error: " + e.getMessage());
			e.printStackTrace();
		}
	}

	protected List<Card> fetchCardData(List<String> links) throws SpotifyWebApiException, IOException {
		List<Card> cards = new LinkedList<Card>();
		HashMap<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
		hints.put(EncodeHintType.CHARACTER_SET, "ISO-8859-15");

		for (String link : links) {
			System.out.println(link);
			
			Card card = new Card(link);
			cards.add(card);

			if (link.startsWith("spotify:album:")) {
				String spotifyId = link.substring(14);
				Album album = spotifyApi.getAlbum(spotifyId).build().execute();
				card.title = album.getName();
				card.artist = album.getArtists()[0].getName();

				URL url = new URL(album.getImages()[0].getUrl());
				card.cover = new Image(ImageDataFactory.create(url));
			}
			else if (link.startsWith("spotify:track:") ) {
				String spotifyId = link.substring(14);
				Track track = spotifyApi.getTrack(spotifyId).build().execute();
				card.title = track.getName();
				card.artist = track.getArtists()[0].getName();
				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;
				
				// extract image
				if (link.indexOf('|') > 0) {
					coverPath = link.substring(0, link.indexOf('|'));
					if (coverPath.startsWith("http://") || coverPath.startsWith("https://")) {
						card.cover = new Image(ImageDataFactory.create(coverPath));
					}
					else {
						File f = new File(coverPath);
						if (f.exists()) {
							card.cover = new Image(ImageDataFactory.create(coverPath));
						}
						else {
							System.out.println("Could not find file " + coverPath);
						}
					}
					
					link = link.substring(link.lastIndexOf('|')+1);
				}
				
				if (link.startsWith("http://") || link.startsWith("https://")) {
					card.title = link;
					card.artist = "";
				}
				else {
					// 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/sftp:host=qudio.local,user=volumio/data"
						// "/run/user/1000/gvfs/smb-share:server=cubon,share=hidrive/Media/Audio/Kinder"
						String path = "/run/user/1000/gvfs/smb-share:server=cubon.local,share=hidrive/Media/Audio/Kinder" + link.substring(link.indexOf("/", 4)) + "/cover.jpg";
						System.out.println(path);
						
						
						File f = new File(path);
						if (f.exists()) {
							card.cover = new Image(ImageDataFactory.create(path));
						}
					}
					
					card.title = link.substring(link.lastIndexOf('/') + 1);
					card.artist = "";
				}
				
				
			}
			
			card.qrcode = new BarcodeQRCode(link);
			card.qrcode.setHints(hints);
		}
		
		return cards;
	}

	private List<List<Card>> sortCards(List<Card> cards) {
		List<List<Card>> lines = new LinkedList<List<Card>>();
		
		List<Card> line = new LinkedList<Card>();
		
		for (Card card : cards) {
			if (line.size() < cardsPerLine) {
				line.add(card);
			}
			else {
				lines.add(line);
				line = new LinkedList<Card>();
				line.add(card);
			}
		}
		
		if (line.size() > 0)
			lines.add(line);
		
		return lines;
	}

	protected void createFoldingPdf(String dest, List<List<Card>> lines) throws Exception {
		PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
		pdfDoc.setDefaultPageSize(PageSize.A4.rotate());

		Document doc = new Document(pdfDoc);
		doc.setMargins(0, 28.5f * mmUnit, 0,  28.5f * mmUnit);
		
		UnitValue[] colWidths = new UnitValue[cardsPerLine];
		for (int i = 0; i < colWidths.length; i++)
			colWidths[i] = new UnitValue(UnitValue.PERCENT, 100/cardsPerLine);
		
		for (List<Card> line : lines) {
			
			Cell oldCell = null;
			
			Table table = new Table(colWidths);
			table.useAllAvailableWidth();
			
			for (Card card : line) {
				
				Cell cell = new Cell();
				cell.setBorder(new SolidBorder(ColorConstants.GRAY, 0.5f, 0.5f));
				cell.setPadding(0);
				
				if (card != null) {
					
					Paragraph p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					Image qrcode = new Image(card.qrcode.createFormXObject(pdfDoc));
					qrcode.setWidth(22 * mmUnit); // Cannot set margin to 0 on QR codes and they grow with the length of the content. This is an approximation.
					p.setPaddingTop(22 * mmUnit - qrcode.getWidth().getValue() / 2); // mid point of QR code is 22 mm from top border
					p.add(qrcode);
					cell.add(p);
					
					p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					p.setPaddingTop(5 * mmUnit);
					if (card.cover != null) {
						Image cover = card.cover;
						cover.setWidth(28 * mmUnit);
						p.add(cover);
					}
					else {
						p.setPaddingBottom(28 * mmUnit);
					}
					cell.add(p);
					
					p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					p.setPaddingTop(5 * mmUnit);
					p.setFontSize(8f);
					p.add(card.artist);
					cell.add(p);
					
					p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					p.setPaddingTop(3 * mmUnit);
					p.setFontSize(9f);
					p.setBold();
					p.add(card.title);
					cell.add(p);
				}
				
				oldCell = cell;
				table.addCell(cell.setRotationAngle(Math.PI));
			}
			
			table.setMinHeight(105 * mmUnit);
			table.setMaxHeight(105 * mmUnit);
			doc.add(table);
			
			table = new Table(colWidths);
			table.useAllAvailableWidth();
			
			for (Card card : line) {
				
				Cell cell = new Cell();
				cell.setBorder(new SolidBorder(ColorConstants.GRAY, 0.5f, 0.5f));
				cell.setPadding(0);
				
				if (card != null) {
					
					Paragraph p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					Image qrcode = new Image(card.qrcode.createFormXObject(pdfDoc));
					qrcode.setWidth(22 * mmUnit); // Cannot set margin to 0 on QR codes and they grow with the length of the content. This is an approximation.
					p.setPaddingTop(22 * mmUnit - qrcode.getWidth().getValue() / 2); // mid point of QR code is 22 mm from top border
					p.add(qrcode);
					cell.add(p);
					
					p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					p.setPaddingTop(5 / 25.4f * 72);
					if (card.cover != null) {
						Image cover = card.cover;
						cover.setWidth(30 / 25.4f * 72);
						p.add(cover);
					}
					else {
						p.setPaddingBottom(30 / 25.4f * 72);
					}
					cell.add(p);
					
					p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					p.setPaddingTop(5 / 25.4f * 72);
					p.setFontSize(8f);
					p.add(card.artist);
					cell.add(p);
					
					p = new Paragraph();
					p.setTextAlignment(TextAlignment.CENTER);
					p.setPaddingTop(3 / 25.4f * 72);
					p.setFontSize(9f);
					p.setBold();
					p.add(card.title);
					cell.add(p);
				}
				
				table.addCell(cell);
			}
			
			table.setMinHeight(105 * mmUnit);
			table.setMaxHeight(105 * mmUnit);
			doc.add(table);
		}

		doc.close();
	}
	

	public static void main(String[] args) throws Exception {
		
		List<String> 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:7wGBvXA1TKtlqyJq6Mtsl5",
//				"spotify:album:6AdTIgvKhY5knelEsDWJx8",
				// ENDE Josefine
				
				
				"https://ih1.redbubble.net/image.859117621.1102/ra,unisex_tshirt,x2200,101010:01c5ca27c6,front-c,267,146,1000,1000-bg,f8f8f8.u6.jpg|German: ÄäÖöÜüß, Russian: ЯБГДЖЙ, Polish: ŁĄŻĘĆŃŚŹ, Japanese: Kanji: てすと   (te-su-to), Hankaku: ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃ",
				"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",
				"NAS/share/Astrid Lindgren - Die Kinder aus der Krachmacherstraße",
				"NAS/share/Astrid Lindgren - Lotta zieht um",
				"NAS/share/Astrid Lindgren - Michel bringt die Welt in Ordnung",
				"NAS/share/Astrid Lindgren - Nils Karlsson-Daeumling",
				"NAS/share/Astrid Lindgren - Wir Kinder aus Büllerbü",
				"NAS/share/Benjamin Blümchen/Benjamin Blümchen - 122 - Benjamin Blümchen als Polizist",
				"NAS/share/Benjamin Blümchen/Benjamin Blümchen - Der kleine Hund",
				"NAS/share/Benjamin Blümchen/Benjamin Blümchen - und die Zirkusponys",
				"NAS/share/Bibi Blocksberg/Bibi Blocksberg - 050 - im Orient",
				"NAS/share/Bibi & Tina - Soundtrack zum 3. Kinofilm - Mädchen gegen Jungs",
				"NAS/share/Brüder Grimm - Rotkäppchen",
				"NAS/share/Christine Nöstlinger - Die neue Franz-Hörbuchbox",
				"NAS/share/Conni - Das große Conni-Musikbuch",
				"NAS/share/Das Beste überhaupt und weitere Geschichten",
				"NAS/share/Das Grüffelokind - Hörspiel zum Film",
				"NAS/share/Der Grüffelo und Das Grüffelokind",
				"NAS/share/Der kleine Drache Kokosnuss bei den Dinosauriern",
				"NAS/share/Der kleine Drache Kokosnuss - Das große Liederalbum",
				"NAS/share/Der kleine Drache Kokosnuss - Das Song-Album zum Film",
				"NAS/share/Der kleine Drache Kokosnuss - Feuerfeste Freunde",
				"NAS/share/Der kleine Drache Kokosnuss - Hab keine Angst",
				"NAS/share/Der kleine Drache Kokosnuss im Spukschloss",
				"NAS/share/Der kleine Drache Kokosnuss im Weltraum",
				"NAS/share/Der kleine Drache Kokosnuss kommt in die Schule",
				"NAS/share/Der kleine Drache Kokosnuss reist um die Welt",
				"NAS/share/Der kleine Drache Kokosnuss - Schulausflug ins Abenteuer",
				"NAS/share/Der kleine Drache Kokosnuss - Schulfest auf dem Feuerfelsen",
				"NAS/share/Der kleine Drache Kokosnuss und der große Zauberer",
				"NAS/share/Der kleine Drache Kokosnuss und der Schatz im Dschungel",
				"NAS/share/Der kleine Drache Kokosnuss und die Reise zum Nordpol",
				"NAS/share/Der kleine Drache Kokosnuss und die Wetterhexe",
				"NAS/share/Der Räuber Hotzenplotz/CD 1",
				"NAS/share/Der Räuber Hotzenplotz/CD 2",
				"NAS/share/Der Spielmann - Das Beste aus 20 Jahren",
				"NAS/share/Die 30 besten Spiel- und Bewegungslieder",
				"NAS/share/Die Biene Maja - Die Fahrt in der Limonadenflasche (CD 5)",
				"NAS/share/Die Eiskönigin Völlig Unverfroren",
				"NAS/share/Die schönsten Geschichten von Piggeldy und Frederick",
				"NAS/share/Drachenreiter",
				"NAS/share/Drachenreiter - Die Vulkan-Mission",
				"NAS/share/Eddi & Dän - singen Kinderlieder a capella",
				"NAS/share/Elke Heidenreich/Nero Corleone",
				"NAS/share/Elke Heidenreich/Nero Corleone kehrt zurück",
				"NAS/share/Elke Heidenreich/Sonst noch was",
				"NAS/share/Ferdi und die Feuerwehr",
				"NAS/share/Fredrik Vahle - Durch den Wald",
				"NAS/share/Giraffenaffen/Giraffenaffen 2",
				"NAS/share/Giraffenaffen/Giraffenaffen 3",
				"NAS/share/Giraffenaffen/Giraffenaffen 4",
				"NAS/share/Giraffenaffen/Giraffenaffen 5",
				"NAS/share/Große Oper für kleine Hörer/CD 01 - Die Zauberflöte",
				"NAS/share/Große Oper für kleine Hörer/CD 02 - Der Freischütz",
				"NAS/share/Große Oper für kleine Hörer/CD 03 - Tristan Und Isolde",
				"NAS/share/Große Oper für kleine Hörer/CD 04 - Hänsel und Gretel",
				"NAS/share/Große Oper für kleine Hörer/CD 05 - Die Hochzeit des Figaro",
				"NAS/share/Große Oper für kleine Hörer/CD 06 - Carmen",
				"NAS/share/Große Oper für kleine Hörer/CD 07 - Aida",
				"NAS/share/Große Oper für kleine Hörer/CD 08 - La Bohème",
				"NAS/share/Große Oper für kleine Hörer/CD 09 - Fidelio",
				"NAS/share/Große Oper für kleine Hörer/CD 10 - Der Barbier von Sevilla",
				"NAS/share/Große Oper für kleine Hörer/CD 11 - La Traviata",
				"NAS/share/Große Oper für kleine Hörer/CD 12 - Madame Butterfly",
				"NAS/share/Große Oper für kleine Hörer/CD 01 - Die Zauberflöte",
				"NAS/share/Hej, Pippi Langstrumpf - Die große Astrid Lindgren Lieder-CD",
				"NAS/share/Hexe Lilli - Die Reise nach Mandolan",
				"NAS/share/Hui Buh das Schlossgespenst - und der schaurige Punkt",
				"NAS/share/James Krüss - Der Sängerkrieg der Heidehasen",
				"NAS/share/Janosch - Das Beste von Tiger & Bär",
				"NAS/share/Karlchen-Geschichten",
				"NAS/share/Kikaninchen, Anni & Christian - Die Welt ist bunt!",
				"NAS/share/Kikaninchen - Dibedibedab!",
				"NAS/share/Kikaninchen - Wir tanzen, spielen, singen Lieder! - Das 2. Album",
				"NAS/share/Kindergarten Hits",
				"NAS/share/Kinder vom Kleistpark - Das Liederbuch",
				"NAS/share/Kinderyogalieder",
				"NAS/share/Komische Oper Berlin - Der Zauberer von Oz",
				"NAS/share/Komische Oper Berlin - Die Bremer Stadtmusikanten",
				"NAS/share/Komische Oper Berlin - Peter Pan",
				"NAS/share/Komische Oper Berlin - Schneewittchen und die 77 Zwerge",
				"NAS/share/Lamp und Leute - Die 30 besten Oster- und Frühlingslieder",
				"NAS/share/Lotta kann Radfahren",
				"NAS/share/Meine Freundin Conni - Conni beim Frisör",
				"NAS/share/Morgen kommt der Weihnachtsmann",
				"NAS/share/Neue Karlchen-Geschichten",
				"NAS/share/Oh wie schön ist Panama (Väter sprechen Janosch - Folge 1 Till Schweiger)",
				"NAS/share/Otfried Preussler - Der kleine Wassermann CD1",
				"NAS/share/Pettersson kriegt Weihnachtsbesuch",
				"NAS/share/Pettersson und Findus - Eine Geburtstagstorte für die Katze und andere Geschichten",
				"NAS/share/Pettersson und Findus - Neues von Pettersson und Findus (Hörspiel zum Kinofilm)",
				"NAS/share/Pettersson und Findus - Pettersson zeltet",
				"NAS/share/Pippi Langstrumpf - Soundtrack",
				"NAS/share/Post für den Tiger (Väter sprechen Janosch - Folge 2 Günther Jauch)",
				"NAS/share/Rabe Socke - Alles Gefunden",
				"NAS/share/Rabe Socke - Alles Rabenstark!",
				"NAS/share/Ritter Rost - Die Zauberinsel",
				"NAS/share/Rolfs fröhlicher Familientag",
				"NAS/share/Rolfs Vogelhochzeit",
				"NAS/share/Rolf Zuckowski - Peter und der Wolf - Karneval der Tiere",
				"NAS/share/Rolf Zuckowski - Rolfs Hasengeschichte Ich bin stark",
				"NAS/share/Rolf Zuckowski - Singles",
				"NAS/share/Rolf Zuckowski und seine Freunde - Ich schaff' das schon",
				"NAS/share/Rolf Zuckowski und seine Freunde - Sommerkinder",
				"NAS/share/Rolf Zuckowski und seine Freunde - Unsere schönsten Weihnachtslieder und Weihnachtsgedichte",
				"NAS/share/Schön ist die Welt",
				"NAS/share/Sergej Prokofiev - Peter Und Der Wolf",
				"NAS/share/Sing mit mir Kinderlieder/Sing mit mir Kinderlieder",
				"NAS/share/Sing mit mir Kinderlieder/Sing mit mir Kinderlieder 2",
				"NAS/share/So schön ist die Weihnachtszeit",
				"NAS/share/Weißt du, wie viel Sternlein stehen",
				"NAS/share/Wiener Sängerknaben - Hänschen Klein - Lieder für Eltern und Kinder",
				"NAS/share/Wir Kinder vom Kleistpark - #backstage",
				"NAS/share/Wir Kinder vom Kleistpark - 10 Jahre",
				"NAS/share/Wir Kinder vom Kleistpark - feiern Weihnachten",
				"NAS/share/Wir Kinder vom Kleistpark - machen Musik",
				"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",
				"spotify:album:1X2HXE2lAqdmD8VjiBX8Tn",
				"spotify:album:5nCA2mAr3rFzk1A6LZXDYm",
				"spotify:album:1Vc2BZntRGIdv3Ul8AM6cz",
				"spotify:album:0H3rE11E9DrD3j2gEvQJ5R",
				"spotify:album:0YSWLbCg5SpxAb2VOON3mX",
				"spotify:track:7oolFzHipTMg2nL7shhdz2",
				"spotify:album:2bK91wL7wsGgJJ7uD6XFYo",
				"spotify:album:4umBnPXwRr7kKJ2WUVueTq",
				"spotify:album:6FGyqglqi0oS3tl4SxyZxf",
				"spotify:album:3iBX3uryCaJl9xWUeOBOFv",
				"spotify:album:0FuEZWTzqOJ4hOlUoAJ6wY",
				"spotify:album:6sTefktQuhIHCWjVYMS6h5",
				"spotify:album:1OifUGnI9ziBW4cOW3DSlL",
				"spotify:album:1Z2uoOl1cQPS8R3O9sFbbX",
				"spotify:album:1FAupt6dQ7w849zXeJd5JB",
				"spotify:album:4M74k3dfsbzLQgAKfO8GOU",
				"spotify:album:1qDJ6x3PrQXq9zjZ9846eL",
				"spotify:album:6FNI6BsAUrSZdpPIBxvIPK",
				"spotify:album:2upvzA60OLbOW9M0QKQ0hO",
				"spotify:album:66Rt4KLkF7jhSPMLi223Zv",
				"spotify:album:24edFfeEP7oy8BWGatc5CQ",
				"spotify:album:00XbTSVi9wVH1jYiYr2Vc9",
				"spotify:album:2ZQKn9GVeJalLEuh3BvuOB",
				"spotify:album:3KD5QNC2k1328SsuYFIjiq",
				"spotify:album:6g5MSdVTrKY3f1ZzsqUhXw",
				"spotify:album:3ixBUKtl7HtxSZECC3YnNb",
				"spotify:album:6GUPPV35zx22eO4g9tctKN",
				"spotify:album:49GuQzqAa08WMB8fjtEBj4",
				"spotify:album:0Pg0kbjNl7PC22ghcSqKih",
				"spotify:album:6JvQHhP638FrhhNrfvc5m0",
				"spotify:album:721jCM2jOWLTF90qAXsm4j",
				"spotify:album:6psaeRRArzDxstvowFPIsD",
				"spotify:album:36sbLOkQp8WdgyOnMsySo1",
				"spotify:album:6AdTIgvKhY5knelEsDWJx8",
				"spotify:album:6ef5sf2fJI8KYZdTbOBLSp",
				"spotify:album:6ZsR4Vx24b1E1PkiGSUQSE", // Die kleine Hexe
				"spotify:album:4py7EzeOO7Q95mPS52b7hE", // Hotzenplotz 3
				"spotify:album:17k9w5N035qsJF1UTAhnfi", // Hotzenplotz 4
				"spotify:album:3xhZFbbwqEdbeNJcTKSmff", // Hotzenplotz 5
				"spotify:album:6uGl6pHa5GUWvZEdmEViTY", // Hotzenplotz 6
				"spotify:album:2cMN4ieFIjUGYMf7EeaEiM",
				"spotify:album:54oJ5PM02p1DrfQwJIc1Dc",
				"spotify:album:4gAslzgCtvj2KMet1JMQs5",
				"spotify:album:6ef5sf2fJI8KYZdTbOBLSp",
				"spotify:album:5BOHV35xYWh2sio211kMlS",
				"spotify:album:1Gs0Ff68QRQtQJG7fSne8j",
				"NAS/share/Jim Knopf und Lukas der Lokomotivführer - Kinderoper",
				"NAS/share/Wir Kinder vom Kleistpark - Wir Kinder vom Kleistpark tanzen",
				"NAS/share/In der Weihnachtsbäckerei - Das Musical-Hörspiel",
				"NAS/share/Die Abenteuer des Odysseus",
				"NAS/share/Drachenreiter - Das Hörspiel",
				"NAS/share/Das große Abenteuer Musik",
				"spotify:album:7tfjSYq5aWFwKlYWRzmPMc", // Das kleine Gespenst
				"spotify:album:4kGTkO7CP063Bk0j14829K", // Der Räuber Hotzenplotz und die Mondrakete
				"spotify:album:4tzPsEeFw4kR42NE4NqJvX", // Immer lustig in Bullerbü
				"spotify:album:1zuWVjkOPIK5OHFnlgDQcf" // Die Häschenschule */
				);
		
		new CardCreator(links);
	}
}

class Card {
	String title;
	String artist;
	BarcodeQRCode qrcode;
	Image cover;
	String link;

	public Card(String link) {
		this.link = link;
	}
}