예제 #1
0
파일: __init__.py 프로젝트: griffy/Pyap
def uri_type(uri):
    if uri.startswith(r'http://'):
        return STREAM
    extension = get_extension(uri)
    if extension and is_audio(extension):
        return FILE
    return UNKNOWN
예제 #2
0
파일: main.py 프로젝트: griffy/Muuse
 def on_add_folder_click(self, widget, data=None):
     dialog = gtk.FileChooserDialog("Select Folder(s)", 
                                    None,
                                    gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                    (gtk.STOCK_CANCEL,
                                     gtk.RESPONSE_CANCEL, 
                                     gtk.STOCK_OPEN,
                                     gtk.RESPONSE_OK))
     dialog.set_default_response(gtk.RESPONSE_OK)
     dialog.set_select_multiple(True)
     
     response = dialog.run()
     if response == gtk.RESPONSE_OK:
         uris = []
         folders = dialog.get_filenames()
         for folder in folders:
             for root, dirs, files in os.walk(folder):
                 for file in files:
                     ext = os.path.splitext(file)[1].replace('.', '')
                     if util.is_audio(ext):
                         uri = os.path.join(root, file)
                         uris.append(uri)
         audio_list = [Audio(uri) for uri in uris]
         self.extend_library(audio_list)
     dialog.destroy()