{"id":1117,"date":"2013-03-13T19:51:47","date_gmt":"2013-03-13T18:51:47","guid":{"rendered":"http:\/\/denbeke.be\/blog\/?page_id=1117"},"modified":"2013-03-13T19:51:47","modified_gmt":"2013-03-13T18:51:47","slug":"itunes-library-parser-albumlistgenerator","status":"publish","type":"page","link":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/","title":{"rendered":"iTunes Library Parser &#8211; AlbumListGenerator"},"content":{"rendered":"<pre><code data-language=\"python\">class AlbumListGenerator:\r\n\r\ndef __init__(self, input_file):\r\n    '''Constructor'''\r\n    self.parsedLibrary = iTunesParser(input_file)\r\n    self.albums = list()\r\n\r\ndef generateList(self):\r\n    '''Generate list of albums'''\r\n\r\n    self.parsedLibrary.parse()\r\n\r\n    #Loop through tracks in parsed libary\r\n    for track in self.parsedLibrary.getTrackList():\r\n\r\n        #Add album to list if it is not yet found in the list\r\n        if not self.isInList(track.getAlbum()):\r\n            self.albums.append(Album(track.getAlbum(), track.getAlbumArtist(), track.getYear()))\r\n\r\ndef getList(self):\r\n    '''Return list of albums'''\r\n    return self.albums\r\n\r\ndef isInList(self, album_name):\r\n    '''Check if the album with the given name is yet in the list'''\r\n    #Loop through albums\r\n    for album in self.albums:\r\n\r\n        #Check if album name is found\r\n        if album.getAlbum() == album_name:\r\n            return True\r\n\r\n    return False\r\n\r\ndef sortList(self):\r\n    '''Sort the list with the album name as search key'''\r\n    self.albums.sort(key = lambda Album: Album.artist)\r\n\r\ndef __str__(self):\r\n    '''Returns string of List with all albums'''\r\n\r\n    string = \"\"\r\n\r\n    for i in range ( len(self.albums) ):\r\n\r\n        string += str(i+1)+\". \"\r\n\r\n        string += str(self.albums[i])\r\n\r\n        if i != len(self.albums) - 1:\r\n            string += \"\\n\"\r\n\r\n    return string<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>class AlbumListGenerator: def __init__(self, input_file): &#8221;&#8217;Constructor&#8221;&#8217; self.parsedLibrary = iTunesParser(input_file) self.albums = list() def generateList(self): &#8221;&#8217;Generate list of albums&#8221;&#8217; self.parsedLibrary.parse() #Loop through tracks in parsed libary for track in self.parsedLibrary.getTrackList(): #Add album to list if it is not yet found in the list if not self.isInList(track.getAlbum()): self.albums.append(Album(track.getAlbum(), track.getAlbumArtist(), track.getYear())) def getList(self): &#8221;&#8217;Return list of albums&#8221;&#8217; return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1102,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1117","page","type-page","status-publish","hentry","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>iTunes Library Parser - AlbumListGenerator &#8211; DenBeke<\/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:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"iTunes Library Parser - AlbumListGenerator &#8211; DenBeke\" \/>\n<meta property=\"og:description\" content=\"class AlbumListGenerator: def __init__(self, input_file): &#039;&#039;&#039;Constructor&#039;&#039;&#039; self.parsedLibrary = iTunesParser(input_file) self.albums = list() def generateList(self): &#039;&#039;&#039;Generate list of albums&#039;&#039;&#039; self.parsedLibrary.parse() #Loop through tracks in parsed libary for track in self.parsedLibrary.getTrackList(): #Add album to list if it is not yet found in the list if not self.isInList(track.getAlbum()): self.albums.append(Album(track.getAlbum(), track.getAlbumArtist(), track.getYear())) def getList(self): &#039;&#039;&#039;Return list of albums&#039;&#039;&#039; return [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/\" \/>\n<meta property=\"og:site_name\" content=\"DenBeke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-albumlistgenerator\\\/\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-albumlistgenerator\\\/\",\"name\":\"iTunes Library Parser - AlbumListGenerator &#8211; DenBeke\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#website\"},\"datePublished\":\"2013-03-13T18:51:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-albumlistgenerator\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-albumlistgenerator\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-albumlistgenerator\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"iTunes Library Parser\",\"item\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"iTunes Library Parser &#8211; AlbumListGenerator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"iTunes Library Parser - AlbumListGenerator &#8211; DenBeke","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:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/","og_locale":"en_US","og_type":"article","og_title":"iTunes Library Parser - AlbumListGenerator &#8211; DenBeke","og_description":"class AlbumListGenerator: def __init__(self, input_file): '''Constructor''' self.parsedLibrary = iTunesParser(input_file) self.albums = list() def generateList(self): '''Generate list of albums''' self.parsedLibrary.parse() #Loop through tracks in parsed libary for track in self.parsedLibrary.getTrackList(): #Add album to list if it is not yet found in the list if not self.isInList(track.getAlbum()): self.albums.append(Album(track.getAlbum(), track.getAlbumArtist(), track.getYear())) def getList(self): '''Return list of albums''' return [&hellip;]","og_url":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/","og_site_name":"DenBeke","twitter_card":"summary_large_image","twitter_site":"@MthsBk","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/","url":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/","name":"iTunes Library Parser - AlbumListGenerator &#8211; DenBeke","isPartOf":{"@id":"https:\/\/denbeke.be\/blog\/#website"},"datePublished":"2013-03-13T18:51:47+00:00","breadcrumb":{"@id":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-albumlistgenerator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/denbeke.be\/blog\/"},{"@type":"ListItem","position":2,"name":"iTunes Library Parser","item":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/"},{"@type":"ListItem","position":3,"name":"iTunes Library Parser &#8211; AlbumListGenerator"}]},{"@type":"WebSite","@id":"https:\/\/denbeke.be\/blog\/#website","url":"https:\/\/denbeke.be\/blog\/","name":"DenBeke","description":"Mathias Beke","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/denbeke.be\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/comments?post=1117"}],"version-history":[{"count":1,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1117\/revisions"}],"predecessor-version":[{"id":1118,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1117\/revisions\/1118"}],"up":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1102"}],"wp:attachment":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/media?parent=1117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}