Пример #1
0
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
 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()