# -*- coding: utf-8 -*-

import os
from phrydy import MediaFile


class Bundler(object):

    def __init__(self, folder):
        self.album = []
        for root_path, subdirs, files in os.walk(folder):
            subdirs.sort()
            files.sort()

            album_title = ''

            for file in files:
                path = os.path.join(root_path, file)

                if path.lower().endswith((".mp3", ".m4a", ".flac", ".wma")):
                    media = MediaFile(path)
                    if not album_title or album_title != media.album:
                        album_title = media.album

                        #print(len(album))
                        self.max_album(self.album)

                        print('#### New Album###')

                        self.album = []

                    self.album.append(path)
                    print('    ' + str(media.track) + '_' + path)

    def max_album(self, album):
        if len(album) > 10:
            print(album)

@@ -139,16 +139,46 @@
 um = %5B%5D%0A
+        self.album_title = ''%0A
         
@@ -543,16 +543,21 @@
  if not 
+self.
 album_ti
@@ -563,16 +563,21 @@
 itle or 
+self.
 album_ti
@@ -612,32 +612,37 @@
                 
+self.
 album_title = me
@@ -651,17 +651,16 @@
 a.album%0A
-%0A
         
@@ -679,25 +679,27 @@
     
-#print(len(
+self.explore_
 album
-)
+(
 )%0A  
@@ -729,30 +729,18 @@
 elf.
-max_
 album
-(self.album)%0A
+ = %5B%5D
 %0A   
@@ -760,80 +760,137 @@
     
-    print('#### New Album###')%0A%0A                        self.album = %5B%5D%0A
+self.album.append(path)%0A%0A    def check_quantity(self, quantity=6):%0A        if len(self.album) %3E quantity:%0A            return True
 %0A   
@@ -886,32 +886,38 @@
 rn True%0A        
+else:%0A
             self
@@ -916,96 +916,149 @@
     
-self.album.append(path)%0A                    print('    ' + str(media.track) + '_' + path
+return False%0A%0A    def check_completeness(self):%0A        pass%0A%0A    def execute(self):%0A        for title in self.album:%0A            print(title
 )%0A%0A 
@@ -1068,11 +1068,15 @@
 def 
-max
+explore
 _alb
@@ -1086,15 +1086,8 @@
 self
-, album
 ):%0A 
@@ -1100,23 +1100,29 @@
  if 
-len(album) %3E 10
+self.check_quantity()
 :%0A  
@@ -1135,17 +1135,19 @@
     
-print(album
+self.execute(
 )%0A

Improve bundler