rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
fields["filename"] = sound_file.get_uri()
fields["path"] = sound_file.get_base_path() fields["filename"] = sound_file.get_filename()
def append_file(self, tagreader): sound_file = tagreader.get_sound_file()
generator.set_folder(self.get_string("selected-folder"))
path, filename = os.path.split(sound_file.get_filename()) path = "" generator.set_folder(os.path.join(self.get_string("selected-folder"), path))
def generate_filename(self, sound_file): self.gconf.clear_cache() output_type = self.get_string("output-mime-type") output_suffix = { "audio/x-vorbis": ".ogg", "audio/x-flac": ".flac", "audio/x-wav": ".wav", "audio/mpeg": ".mp3", }.get(output_type, None)
base = os.path.commonprefix(folders)
base,notused = os.path.split(os.path.commonprefix(folders))
def on_addfolder_activate(self, *args): #print "add_folder" ret = self.addfolderchooser.run() self.addfolderchooser.hide() if ret == gtk.RESPONSE_OK: folders = self.addfolderchooser.get_uris() base = os.path.commonprefix(folders) filelist = [] for folder in folders: filelist.extend(self.vfs_walk(gnomevfs.URI(folder))...
self.filelist.add_file(SoundFile(f, base))
f = f[len(base)+1:] self.filelist.add_file(SoundFile(base+"/", f))
def on_addfolder_activate(self, *args): #print "add_folder" ret = self.addfolderchooser.run() self.addfolderchooser.hide() if ret == gtk.RESPONSE_OK: folders = self.addfolderchooser.get_uris() base = os.path.commonprefix(folders) filelist = [] for folder in folders: filelist.extend(self.vfs_walk(gnomevfs.URI(folder))...
print "quality: %s=%s" % (properties[self.mp3_mode][1], self.mp3_quality)
def add_mp3_encoder(self): mp3enc = self.make_element("lame", "encoder")
file_list.extend(uri)
file_list.append(uri)
def drag_data_received(self, widget, context, x, y, selection, mime_id, time): if mime_id >= 0 and mime_id < len(self.drop_mime_types): mime_type = self.drop_mime_types[mime_id] #if mime_type == "text/uri-list": file_list = [] for uri in selection.data.split("\n"): uri = uri.strip() if uri: info = gnomevfs.get_file_inf...
result = urllib.unquote(result)
result = unquote_filename(result)
def get_target_name(self, sound_file):
params["filename"] = markup_escape(urllib.unquote(sound_file.get_filename_for_display()))
params["filename"] = markup_escape(unquote_filename(sound_file.get_filename()))
def format_cell(self, sound_file): template_tags = "%(artist)s - <i>%(album)s</i> - <b>%(title)s</b>\n<small>%(filename)s</small>" template_loading = "<i>%s</i>\n<small>%%(filename)s</small>" \ % _("loading tags...") template_notags = '<span foreground="red">%s</span>\n<small>%%(filename)s</small>' \ % _("no tags"...
try: if sound_file.have_tags: template = template_tags
if sound_file.have_tags: template = template_tags else: if sound_file.tags_read: template = template_notags
def format_cell(self, sound_file): template_tags = "%(artist)s - <i>%(album)s</i> - <b>%(title)s</b>\n<small>%(filename)s</small>" template_loading = "<i>%s</i>\n<small>%%(filename)s</small>" \ % _("loading tags...") template_notags = '<span foreground="red">%s</span>\n<small>%%(filename)s</small>' \ % _("no tags"...
if sound_file.tags_read: template = template_notags else: template = template_loading s = template % params except UnicodeDecodeError: str = "" for c in markup_escape(urllib.unquote(sound_file.get_uri())): if ord(c) < 127: str += c else: str += '<span foreground="yellow" background="red"><b>!</b></span>' error.show(_...
template = template_loading s = template % params
def format_cell(self, sound_file): template_tags = "%(artist)s - <i>%(album)s</i> - <b>%(title)s</b>\n<small>%(filename)s</small>" template_loading = "<i>%s</i>\n<small>%%(filename)s</small>" \ % _("loading tags...") template_notags = '<span foreground="red">%s</span>\n<small>%%(filename)s</small>' \ % _("no tags"...
return urllib.unquote(generator.get_target_name(sound_file))
return unquote_filename(generator.get_target_name(sound_file))
def generate_filename(self, sound_file, for_display=False): self.gconf.clear_cache() output_type = self.get_string("output-mime-type") output_suffix = { "audio/x-vorbis": ".ogg", "audio/x-flac": ".flac", "audio/x-wav": ".wav", "audio/mpeg": ".mp3", }.get(output_type, None)
path = urllib.unquote(path)
path = unquote_filename(path)
def add(self, sound_file): output_filename = self.window.prefs.generate_filename(sound_file) path = urlparse.urlparse(output_filename) [2] path = urllib.unquote(path) exists = True try: gnomevfs.get_file_info(gnomevfs.URI((output_filename))) except gnomevfs.NotFoundError: exists = False except gnomevfs.InvalidURIErro...
self.about.show()
about = gtk.glade.XML(GLADE, "about").get_widget("about") about.set_property("name", NAME) about.set_property("version", VERSION) about.show()
def on_about_activate(self, *args): self.about.show()
if not os.path.exists(dirname):
if dirname and not os.path.exists(dirname): print "Creating Folders: '%s'" % dirname
def new_decoded_pad(self, decoder, pad, is_last): if self.added_pad_already: return if "audio" not in pad.get_caps()[0].get_name(): return
print("setting vorbis quality: %f" % self.vorbis_quality)
def add_oggvorbis_encoder(self): vorbisenc = self.make_element("vorbisenc", "encoder") if self.vorbis_quality is not None: vorbisenc.set_property("quality", self.vorbis_quality) print("setting vorbis quality: %f" % self.vorbis_quality) return vorbisenc
"vbr" : (4,"vbr-bitrate"),
"vbr" : (4,"vbr-quality")
def add_mp3_encoder(self): mp3enc = self.make_element("lame", "encoder")
"mp3-mode": 2, "mp3-cbr-quality": 2, "mp3-abr-quality": 2, "mp3-vbr-quality": 2,
"mp3-mode": "vbr", "mp3-cbr-quality": 192, "mp3-abr-quality": 192, "mp3-vbr-quality": 3,
def is_nonempty(self): try: iter = self.model.get_iter((0,)) except ValueError: return False return True
mime_type = self.get_string("output-mime-type")
def set_widget_initial_values(self, glade): self.quality_tabs.set_show_tabs(False) if self.get_int("same-folder-as-input"): w = glade.get_widget("same_folder_as_input") else: w = glade.get_widget("into_selected_folder") w.set_active(True) self.target_folder_chooser.set_filename( self.get_string("selected-folder")) s...
quality = self.get_float("vorbis-quality") quality_setting = {0:0 ,0.2:1 ,0.4:2 ,0.6:3 , 0.8:4} for k, v in quality_setting.iteritems(): if abs(quality-k) < 0.01: w.set_active(v)
def set_widget_initial_values(self, glade): self.quality_tabs.set_show_tabs(False) if self.get_int("same-folder-as-input"): w = glade.get_widget("same_folder_as_input") else: w = glade.get_widget("into_selected_folder") w.set_active(True) self.target_folder_chooser.set_filename( self.get_string("selected-folder")) s...
mode = self.get_string("mp3-mode") self.change_mp3_mode(mode)
def set_widget_initial_values(self, glade): self.quality_tabs.set_show_tabs(False) if self.get_int("same-folder-as-input"): w = glade.get_widget("same_folder_as_input") else: w = glade.get_widget("into_selected_folder") w.set_active(True) self.target_folder_chooser.set_filename( self.get_string("selected-folder")) s...
bitrate = 666
bitrates = (320, 256, 224, 192, 160, 128, 112, 96, 80, 64) bitrate = bitrates[bitrate]
def get_bitrate_from_settings(self): bitrate = 0 aprox = True mode = self.get_string("mp3-mode")
return "~%d" % bitrate
return "~%d kbps" % bitrate
def get_bitrate_from_settings(self): bitrate = 0 aprox = True mode = self.get_string("mp3-mode")
return "%d" % bitrate
return "%d kbps" % bitrate
def get_bitrate_from_settings(self): bitrate = 0 aprox = True mode = self.get_string("mp3-mode")
bitrate = self.get_bitrate_from_settings()
def update_example(self): sound_file = SoundFile(os.path.expanduser("~/foo/bar.flac")) sound_file.add_tags({ "artist": "Foo Bar", "title": "Hi Ho", "album": "IS: TOO", "track-number": 1L, "track-count": 11L, }) self.example.set_text(self.generate_filename(sound_file)) bitrate = self.get_bitrate_from_settings() markup ...
value = getter(self.path(key)) if value is None:
if self.gconf.get(self.path(key)) is None:
def get_with_default(self, getter, key): value = getter(self.path(key)) if value is None: return self.defaults[key] else: return value
return value
return getter(self.path(key))
def get_with_default(self, getter, key): value = getter(self.path(key)) if value is None: return self.defaults[key] else: return value
print _("setting mime:"), mime_type
def change_mime_type(self, mime_type): self.set_string("output-mime-type", mime_type) self.set_sensitive() self.update_example() tabs = { "audio/x-vorbis": 0, "audio/mpeg": 1, "audio/x-flac": 2, "audio/x-wav": 3, } self.quality_tabs.set_current_page(tabs[mime_type]) print _("setting mime:"), mime_type
print _("\nchange mp3 mode") print _("quality: %f") % quality
def change_mp3_mode(self, mode): keys = { "cbr": "mp3-cbr-quality", "abr": "mp3-abr-quality", "vbr": "mp3-vbr-quality", } quality = self.get_int(keys[mode]) print _("\nchange mp3 mode") print _("quality: %f") % quality quality_to_preset = { "cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (1, 3,...
"cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (1, 3, 5, 7, 9),
"cbr": {64:0, 96:1, 128:2, 192:3, 256:4}, "abr": {64:0, 96:1, 128:2, 192:3, 256:4}, "vbr": {9:0, 7:1, 5:2, 3:3, 1:4},
def change_mp3_mode(self, mode): keys = { "cbr": "mp3-cbr-quality", "abr": "mp3-abr-quality", "vbr": "mp3-vbr-quality", } quality = self.get_int(keys[mode]) print _("\nchange mp3 mode") print _("quality: %f") % quality quality_to_preset = { "cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (1, 3,...
active = 0 for i in quality_to_preset[mode]: print " " , quality , " <-> " , i if quality <= i: print _("I choose break active+=1
def change_mp3_mode(self, mode): keys = { "cbr": "mp3-cbr-quality", "abr": "mp3-abr-quality", "vbr": "mp3-vbr-quality", } quality = self.get_int(keys[mode]) print _("\nchange mp3 mode") print _("quality: %f") % quality quality_to_preset = { "cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (1, 3,...
if mode == "vbr": active = 4-active self.mp3_quality.set_active(active)
if quality in quality_to_preset[mode]: self.mp3_quality.set_active(quality_to_preset[mode][quality])
def change_mp3_mode(self, mode): keys = { "cbr": "mp3-cbr-quality", "abr": "mp3-abr-quality", "vbr": "mp3-vbr-quality", } quality = self.get_int(keys[mode]) print _("\nchange mp3 mode") print _("quality: %f") % quality quality_to_preset = { "cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (1, 3,...
print "%s[%d] = %s" % (keys[mode], combobox.get_active(), quality[mode][combobox.get_active()])
def on_mp3_quality_changed(self, combobox): keys = { "cbr": "mp3-cbr-quality", "abr": "mp3-abr-quality", "vbr": "mp3-vbr-quality" } quality = { "cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (9, 7, 5, 3, 1), } mode = self.get_string("mp3-mode") self.set_int(keys[mode], quality[mode][combobox.get...
self.addfolderchooser = gtk.FileChooserDialog(_("Add Folder..."), self.widget, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
def __init__(self, glade): self.widget = glade.get_widget("window") self.filelist = FileList(self, glade) self.filelist_selection = self.filelist.widget.get_selection() self.filelist_selection.connect("changed", self.selection_changed) self.existsdialog = glade.get_widget("existsdialog") self.existsdialog.message = gl...
SoundConverterException.__init__(self, "File exists.", "The file %s exists already")
SoundConverterException.__init__(self, _("File exists."), _("The file %s exists already"))
def __init__(self, name): SoundConverterException.__init__(self, "File exists.", "The file %s exists already")
sys.stderr.write("\n\nError: %s\n%s\n" % (primary, secondary))
sys.stderr.write(_("\n\nError: %s\n%s\n") % (primary, secondary))
def show(self, primary, secondary): sys.stderr.write("\n\nError: %s\n%s\n" % (primary, secondary)) sys.exit(1)
self.id = gtk.idle_add(self.do_work)
self.id = gobject.idle_add(self.do_work)
def run(self): """Start running the task. Call setup().""" try: self.setup() except SoundConverterException, e: error.show_exception(e) return self.id = gtk.idle_add(self.do_work) self.run_start_times = os.times()
gtk.idle_remove(self.id)
gobject.source_remove(self.id)
def stop(self): """Stop task processing. Finish() is not called.""" if 'id' in dir(self) and self.id is not None: gtk.idle_remove(self.id) self.id = None
SoundConverterException.__init__(self, "Internal error", "Couldn't link GStreamer elements. " + "Please report this as a bug.")
SoundConverterException.__init__(self, _("Internal error"), _("Couldn't link GStreamer elements.\n Please report this as a bug."))
def __init__(self): SoundConverterException.__init__(self, "Internal error", "Couldn't link GStreamer elements. " + "Please report this as a bug.")
SoundConverterException.__init__(self, "Unknown type %s" % mime_type, ("The file %s is of an unknown type. " + "Please ask the developers to add support " + "for files of this type if it is important " + "to you.") % uri)
SoundConverterException.__init__(self, _("Unknown type %s") % mime_type, (_("The file %s is of an unknown type.\n Please ask the developers to add support\n for files of this type if it is important\n to you.")) % uri)
def __init__(self, uri, mime_type): SoundConverterException.__init__(self, "Unknown type %s" % mime_type, ("The file %s is of an unknown type. " + "Please ask the developers to add support " + "for files of this type if it is important " + "to you.") % uri)
self.found_tags = True
if not taglist.has_key('serial'): self.found_tags = True
def found_tag(self, decoder, something, taglist): self.sound_file.add_tags(taglist) self.found_tags = True
SoundConverterException.__init__(self, "Target exists.", ("The output file %s already " + "exists.") % uri)
SoundConverterException.__init__(self, _("Target exists."), (_("The output file %s already exists.")) % uri)
def __init__(self, uri): SoundConverterException.__init__(self, "Target exists.", ("The output file %s already " + "exists.") % uri)
context.finish(gtk.TRUE, gtk.FALSE, time)
context.finish(True, False, time)
def drag_data_received(self, widget, context, x, y, selection, mime_id, time): if mime_id >= 0 and mime_id < len(self.drop_mime_types): mime_type = self.drop_mime_types[mime_id] if mime_type == "text/uri-list": for uri in selection.data.split("\n"): uri = uri.strip() if uri: self.add_file(SoundFile(uri)) context.finish...
fields[key] = "unknown"
fields[key] = _("unknown")
def append_file(self, tagreader): sound_file = tagreader.get_sound_file()
for field, tagname in [("Title", "title"), ("Artist", "artist"), ("Album", "album")]:
for field, tagname in [(_("Title"), "title"), (_("Artist"), "artist"), (_("Album"), "album")]:
def append_file(self, tagreader): sound_file = tagreader.get_sound_file()
("%(.inputname)s", "Same as input, but with new suffix"), ("%(track-number)02d-%(title)s", "Track number - title"), ("%(title)s", "Track title"), ("%(artist)s-%(title)s", "Artist - title"),
("%(.inputname)s", _("Same as input, but with new suffix")), ("%(track-number)02d-%(title)s", _("Track number - title")), ("%(title)s", _("Track title")), ("%(artist)s-%(title)s", _("Artist - title")),
def is_nonempty(self): try: iter = self.model.get_iter((0,)) except ValueError: return False return True
("%(artist)s/%(album)s", "artist/album"), ("%(artist)s-%(album)s", "artist-album"),
("%(artist)s/%(album)s", _("artist/album")), ("%(artist)s-%(album)s", _("artist-album")),
def is_nonempty(self): try: iter = self.model.get_iter((0,)) except ValueError: return False return True
self.into_selected_folder.set_label("Into folder %s" %
self.into_selected_folder.set_label(_("Into folder %s") %
def update_selected_folder(self): self.into_selected_folder.set_label("Into folder %s" % self.get_string("selected-folder"))
markup = "<small>Target bitrate: %s</small>" % self.get_bitrate_from_settings()
markup = _("<small>Target bitrate: %s</small>") % self.get_bitrate_from_settings()
def update_example(self): sound_file = SoundFile(os.path.expanduser("~/foo/bar.flac")) sound_file.add_tags({ "artist": "Foo Bar", "title": "Hi Ho", "album": "IS: TOO", "track-number": 1L, "track-count": 11L, }) self.example.set_text(self.generate_filename(sound_file)) bitrate = self.get_bitrate_from_settings() markup ...
print "setting mime:", mime_type
print _("setting mime:"), mime_type
def change_mime_type(self, mime_type): self.set_string("output-mime-type", mime_type) self.set_sensitive() self.update_example() tabs = { "audio/x-vorbis": 0, "audio/mpeg": 1, "audio/x-flac": 2, "audio/x-wav": 3, } self.quality_tabs.set_current_page(tabs[mime_type]) print "setting mime:", mime_type
print "\nchange mp3 mode" print "quality:", quality
print _("\nchange mp3 mode") print _("quality: %f") % quality
def change_mp3_mode(self, mode): keys = { "cbr": "mp3-cbr-quality", "abr": "mp3-abr-quality", "vbr": "mp3-vbr-quality", } quality = self.get_int(keys[mode]) print "\nchange mp3 mode" print "quality:", quality quality_to_preset = { "cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (1, 3, 5, 7, 9),...
print "I choose
print _("I choose
def change_mp3_mode(self, mode): keys = { "cbr": "mp3-cbr-quality", "abr": "mp3-abr-quality", "vbr": "mp3-vbr-quality", } quality = self.get_int(keys[mode]) print "\nchange mp3 mode" print "quality:", quality quality_to_preset = { "cbr": (64, 96, 128, 192, 256), "abr": (64, 96, 128, 192, 256), "vbr": (1, 3, 5, 7, 9),...
SoundConverterException.__init__(self, "Convertion Canceled", "")
SoundConverterException.__init__(self, _("Convertion Canceled"), "")
def __init__(self): SoundConverterException.__init__(self, "Convertion Canceled", "")
"The output file <i>%s</i> " \ "exists already.\n" \ "Do you want to skip the file, overwrite it or cancel the conversion?\n" % \
_("The output file <i>%s</i>\n exists already.\n Do you want to skip the file, overwrite it or cancel the conversion?\n") % \
def add(self, sound_file): output_filename = self.window.prefs.generate_filename(sound_file) path = urlparse.urlparse(output_filename) [2] if os.path.exists(path):
self.window.set_status("Conversion done. ( in %s )" %
self.window.set_status(_("Conversion done. ( in %s )") %
def finish(self): TaskQueue.finish(self) self.reset_counters() self.window.set_progress(0, 0) self.window.set_sensitive() total_time = self.run_finish_times[4] - self.run_start_times[4] user_time = self.run_finish_times[0] - self.run_start_times[0] system_time = self.run_finish_times[1] - self.run_start_times[1] self.w...
self.addchooser = gtk.FileChooserDialog("Add files...",
self.addchooser = gtk.FileChooserDialog(_("Add files..."),
def __init__(self, glade): self.widget = glade.get_widget("window") self.filelist = FileList(self, glade) self.filelist_selection = self.filelist.widget.get_selection() self.filelist_selection.connect("changed", self.selection_changed) self.existsdialog = glade.get_widget("existsdialog") self.existsdialog.message = gl...
print "canceling conversion."
print _("canceling conversion.")
def on_convert_button_clicked(self, *args): try: for fields in self.filelist.get_files(): self.converter.add(fields["META"]) except ConverterQueueCanceled: print "canceling conversion." else: self.converter.run() self.set_sensitive()
print "Usage: %s [options] [soundfile ...]" % sys.argv[0]
print _("Usage: %s [options] [soundfile ...]") % sys.argv[0]
def print_help(*args): print "Usage: %s [options] [soundfile ...]" % sys.argv[0] for short, long, func, doc in options: print if short[-1] == ":": print " -%s arg, --%sarg" % (short[:1], long) else: print " -%s, --%s" % (short[:1], long) for line in textwrap.wrap(doc): print " %s" % line sys.exit(0)
"Print out a usage summary."),
_("Print out a usage summary.")),
def print_help(*args): print "Usage: %s [options] [soundfile ...]" % sys.argv[0] for short, long, func, doc in options: print if short[-1] == ":": print " -%s arg, --%sarg" % (short[:1], long) else: print " -%s, --%s" % (short[:1], long) for line in textwrap.wrap(doc): print " %s" % line sys.exit(0)
"Convert in batch mode, from command line, without a graphical user " + "interface. You can use this from, say, shell scripts."),
_("Convert in batch mode, from command line, without a graphical user\n interface. You can use this from, say, shell scripts.")),
def print_help(*args): print "Usage: %s [options] [soundfile ...]" % sys.argv[0] for short, long, func, doc in options: print if short[-1] == ":": print " -%s arg, --%sarg" % (short[:1], long) else: print " -%s, --%s" % (short[:1], long) for line in textwrap.wrap(doc): print " %s" % line sys.exit(0)
"Set the output MIME type for batch mode. The default is " + get("cli-output-type") + ". Note that you probably want to set " + "the output suffix as well."),
_("Set the output MIME type for batch mode. The default is\n %s . Note that you probably want to set\n the output suffix as well.") % get("cli-output-type")),
def print_help(*args): print "Usage: %s [options] [soundfile ...]" % sys.argv[0] for short, long, func, doc in options: print if short[-1] == ":": print " -%s arg, --%sarg" % (short[:1], long) else: print " -%s, --%s" % (short[:1], long) for line in textwrap.wrap(doc): print " %s" % line sys.exit(0)
"Be quiet. Don't write normal output, only errors."),
_("Be quiet. Don't write normal output, only errors.")),
def print_help(*args): print "Usage: %s [options] [soundfile ...]" % sys.argv[0] for short, long, func, doc in options: print if short[-1] == ":": print " -%s arg, --%sarg" % (short[:1], long) else: print " -%s, --%s" % (short[:1], long) for line in textwrap.wrap(doc): print " %s" % line sys.exit(0)
"Set the output filename suffix for batch mode. The default is " + get("cli-output-suffix") + ". Note that the suffix does not affect " + "the output MIME type."),
_("Set the output filename suffix for batch mode. The default is \n %s . Note that the suffix does not affect\n the output MIME type.") % get("cli-output-suffix")),
def print_help(*args): print "Usage: %s [options] [soundfile ...]" % sys.argv[0] for short, long, func, doc in options: print if short[-1] == ":": print " -%s arg, --%sarg" % (short[:1], long) else: print " -%s, --%s" % (short[:1], long) for line in textwrap.wrap(doc): print " %s" % line sys.exit(0)
"Show tags for input files instead of converting them. This indicates " + "command line batch mode and disables the graphical user interface."),
_("Show tags for input files instead of converting them. This indicates \n command line batch mode and disables the graphical user interface.")),
def print_help(*args): print "Usage: %s [options] [soundfile ...]" % sys.argv[0] for short, long, func, doc in options: print if short[-1] == ":": print " -%s arg, --%sarg" % (short[:1], long) else: print " -%s, --%s" % (short[:1], long) for line in textwrap.wrap(doc): print " %s" % line sys.exit(0)
result = s
result = urllib.quote(s)
def get_target_name(self, sound_file): u = gnomevfs.URI(sound_file.get_uri()) root, ext = os.path.splitext(u.path) if u.host_port: host = "%s:%s" % (u.host_name, u.host_port) else: host = u.host_name
dirname = os.path.dirname(path)
dirname = urllib.unquote( os.path.dirname(path) )
def new_decoded_pad(self, decoder, pad, is_last): if self.added_pad_already: return if "audio" not in pad.get_caps()[0].get_name(): return
def on_replace_only_impossible_chars_toggled(self, button):
def UNUSED_on_replace_only_impossible_chars_toggled(self, button):
def on_replace_only_impossible_chars_toggled(self, button): if button.get_active(): self.set_int("replace-messy-chars", 0) self.update_example()
self.update_example()
else: self.set_int("replace-messy-chars", 0) self.update_example()
def on_replace_messy_chars_toggled(self, button): if button.get_active(): self.set_int("replace-messy-chars", 1) self.update_example()
def UNUSED_sleep(duration):
def sleep(duration):
def UNUSED_sleep(duration): start = time.time() while time.time() < start + duration: while gtk.events_pending(): gtk.main_iteration(gtk.FALSE) time.sleep(0.001)
gtk.main_iteration(gtk.FALSE) time.sleep(0.001)
gtk.main_iteration(False) time.sleep(0.010)
def UNUSED_sleep(duration): start = time.time() while time.time() < start + duration: while gtk.events_pending(): gtk.main_iteration(gtk.FALSE) time.sleep(0.001)
self.id = gobject.idle_add(self.do_work)
self.paused = False self.id = gobject.idle_add(self.do_work, priority=gobject.PRIORITY_LOW)
def run(self): """Start running the task. Call setup().""" try: self.setup() except SoundConverterException, e: error.show_exception(e) return self.id = gobject.idle_add(self.do_work) self.run_start_times = os.times()
return False
print "error: pipeline.state == null"
def work(self): if self.pipeline.get_state() == gst.STATE_NULL: return False return self.pipeline.iterate()
msg = "mime type: %s" % mime_type
self.found_type = None
def have_type(self, typefind, probability, caps): mime_type = caps.to_string() msg = "mime type: %s" % mime_type for t in mime_whitelist: if t in mime_type: msg += " -> accepted!" self.found_type = mime_type log(msg)
msg += " -> accepted!"
def have_type(self, typefind, probability, caps): mime_type = caps.to_string() msg = "mime type: %s" % mime_type for t in mime_whitelist: if t in mime_type: msg += " -> accepted!" self.found_type = mime_type log(msg)
log(msg)
if not self.found_type: log("Mime type skipped: %s (mail us if this is an error)" % mime_type)
def have_type(self, typefind, probability, caps): mime_type = caps.to_string() msg = "mime type: %s" % mime_type for t in mime_whitelist: if t in mime_type: msg += " -> accepted!" self.found_type = mime_type log(msg)
log(_("Writing to: '%s'") % self.output_filename)
log( _("Writing to: '%s'") % urllib.unquote(self.output_filename) )
def new_decoded_pad(self, decoder, pad, is_last): if self.added_pad_already: return if not pad.get_caps(): return if "audio" not in pad.get_caps()[0].get_name(): return
def try_to_launch_convertion(self):
def wait_tags_and_convert(self):
def try_to_launch_convertion(self): # check that all files have loaded their tags not_ready = [s for s in self.filelist.get_files() if not s["META"].tags_read] if not_ready: # retry later gobject.timeout_add(1000, self.try_to_launch_convertion) else: # start convertion self.do_convert() return False
gobject.timeout_add(1000, self.try_to_launch_convertion)
self.progressbar.pulse() return True
def try_to_launch_convertion(self): # check that all files have loaded their tags not_ready = [s for s in self.filelist.get_files() if not s["META"].tags_read] if not_ready: # retry later gobject.timeout_add(1000, self.try_to_launch_convertion) else: # start convertion self.do_convert() return False
self.convertion_waiting = True self.set_status(_("Waiting for tags...")) self.set_sensitive() self.try_to_launch_convertion()
if not self.converter.is_running(): self.convertion_waiting = True self.set_status(_("Waiting for tags...")) self.set_sensitive() gobject.timeout_add(100, self.wait_tags_and_convert) else: self.converter.paused = not self.converter.paused if self.converter.paused: self.set_status(_("Paused")) else: self.set_status(""...
def on_convert_button_clicked(self, *args): self.convertion_waiting = True self.set_status(_("Waiting for tags...")) self.set_sensitive() self.try_to_launch_convertion()
self.filelist.is_nonempty() and not self.converter.is_running() and not self.convertion_waiting)
self.filelist.is_nonempty())
def set_sensitive(self): self.set_widget_sensitive("remove", self.filelist_selection.count_selected_rows() > 0) self.set_widget_sensitive("convert_button", self.filelist.is_nonempty() and not self.converter.is_running() and not self.convertion_waiting) self.set_widget_sensitive("stop_button", self.converter.is_running(...
basename, ext = os.path.splitext(sound_file.get_filename())
basename, ext = os.path.splitext(urllib.unquote(sound_file.get_filename()))
def get_target_name(self, sound_file):
result = pattern % dict
result = urllib.quote(pattern % dict)
def get_target_name(self, sound_file):
self.id = gobject.timeout_add(10, self.do_work, priority=gobject.PRIORITY_LOW)
self.id = gobject.timeout_add(100, self.do_work, priority=gobject.PRIORITY_LOW)
def run(self): """Start running the task. Call setup().""" try: self.setup() except SoundConverterException, e: error.show_exception(e) return self.paused = False self.run_start_time = time.time() self.current_paused_time = 0 self.paused_time = 0 #self.id = gobject.idle_add(self.do_work, priority=gobject.PRIORITY_LOW) ...
s = r%60 m = r/60 remaining = _("%d:%02d left") % (m,s)
if r < 0 or r>60*60: remaining = "Error" else: s = r%60 m = r/60 remaining = _("%d:%02d left") % (m,s)
def set_progress(self, done_so_far, total, current_file=""): if (total==0) or (done_so_far==0): self.progressbar.set_text(" ") self.progressbar.set_fraction(0.0) self.progressbar.pulse() return self.progresstitle.set_text(_("Converting")) if time.time() < self.progress_time + 0.10: # ten updates per second should be e...
info = gnomevfs.get_file_info(uri, gnomevfs.FILE_INFO_GET_MIME_TYPE)
info = gnomevfs.get_file_info(uri, gnomevfs.FILE_INFO_FIELDS_TYPE)
def vfs_walk(uri): """similar to os.path.walk, but with gnomevfs. uri -- the base folder uri. return a list of uri. """ if str(uri)[-1] != '/': uri = uri.append_string("/") info = gnomevfs.get_file_info(uri, gnomevfs.FILE_INFO_GET_MIME_TYPE) #info = gnomevfs.get_file_info(uri, gnomevfs.FILE_INFO_FIELDS_TYPE) filelis...
self.tags = { "track-number": 0, "title": "Unknown Title", "artist": "Unknown Artist", "album": "Unknown Album", }
self.tags = {}
def __init__(self, base_path, filename=None): if filename: self.base_path = base_path self.filename = filename self.uri = os.path.join(base_path, filename) else: self.uri = base_path self.base_path, self.filename = os.path.split(self.uri) self.base_path += "/" self.tags = { "track-number": 0, "title": "Unknown Title"...
self.exists = os.path.exists
self.exists = gnomevfs.exists
def __init__(self): self.folder = None self.subfolders = "" self.basename= "%(.inputname)s" self.suffix = None self.replace_messy_chars = False self.max_tries = 2 self.exists = os.path.exists
u = gnomevfs.URI(sound_file.get_uri()) root, ext = os.path.splitext(u.path) if u.host_port: host = "%s:%s" % (u.host_name, u.host_port) else: host = u.host_name
def get_target_name(self, sound_file):
"album": "", "artist": "", "title": "",
"album": "Unknow Album", "artist": "Unknow Artist", "title": "Unknow Title",
def get_target_name(self, sound_file):
tuple = (u.scheme, host, result, "", u.fragment_identifier) u2 = urlparse.urlunsplit(tuple) if self.exists(u2): raise TargetNameCreationFailure(u2)
u2 = result
def get_target_name(self, sound_file):
self.sound_file.have_tags = True
def found_tag(self, decoder, something, taglist):
if time.time()-self.run_start_time > 5:
if time.time()-self.run_start_time > 9:
def work(self): if time.time()-self.run_start_time > 5: # stop looking for tags after 5s return False return Decoder.work(self) and not self.found_tags
template_notags = '<span foreground="red">%s</span>\n<small>%%(filename)s</small>' \
template_notags = '<i> %s</i>\n<small>%%(filename)s</small>' \
def format_cell(self, sound_file): template_tags = "%(artist)s - <i>%(album)s</i> - <b>%(title)s</b>\n<small>%(filename)s</small>" template_loading = "<i>%s</i>\n<small>%%(filename)s</small>" \ % _("loading tags...") template_notags = '<span foreground="red">%s</span>\n<small>%%(filename)s</small>' \ % _("no tags"...
str += '<span foreground="yellow" background="red"><b>!</b></span>'
str += '<span foreground="yellow" background="red"><b>?</b></span>'
def format_cell(self, sound_file): template_tags = "%(artist)s - <i>%(album)s</i> - <b>%(title)s</b>\n<small>%(filename)s</small>" template_loading = "<i>%s</i>\n<small>%%(filename)s</small>" \ % _("loading tags...") template_notags = '<span foreground="red">%s</span>\n<small>%%(filename)s</small>' \ % _("no tags"...
tuple = urlparse.urlparse(sound_file.get_uri()) path = tuple[2] generator.set_folder(os.path.dirname(path))
generator.set_folder(sound_file.get_base_path())
def generate_filename(self, sound_file): self.gconf.clear_cache() output_type = self.get_string("output-mime-type") output_suffix = { "audio/x-vorbis": ".ogg", "audio/x-flac": ".flac", "audio/x-wav": ".wav", "audio/mpeg": ".mp3", }.get(output_type, None)
return
def set_sensitive(self): #TODO return for widget in self.sensitive_widgets.values(): widget.set_sensitive(False) x = self.get_int("same-folder-as-input") for name in ["choose_folder", "create_subfolders", "subfolder_pattern"]: self.sensitive_widgets[name].set_sensitive(not x) self.sensitive_widgets["vorbis_quality"...
bytes = task.get_bytes_progress() self.window.set_progress(self.total_for_processed_files + bytes,
if hasattr(task,"converting"): bytes = task.get_bytes_progress() self.window.set_progress(self.total_for_processed_files + bytes,
def work_hook(self, task): bytes = task.get_bytes_progress() self.window.set_progress(self.total_for_processed_files + bytes, self.total_bytes)
self.found_type = ""
def __init__(self, sound_file): Pipeline.__init__(self) self.sound_file = sound_file self.found_type = "" command = '%s location="%s" ! typefind name=typefinder ! fakesink' % \ (gstreamer_source, encode_filename(self.sound_file.get_uri())) self.add_command(command) self.add_signal("typefinder", "have-type", self.have_...
self.found_type = None
self.sound_file.mime_type = None
def have_type(self, typefind, probability, caps): mime_type = caps.to_string() #debug("have_type:", mime_type, self.sound_file.get_filename_for_display()) self.found_type = None for t in mime_whitelist: if t in mime_type: self.found_type = mime_type if not self.found_type: log("Mime type skipped: %s (mail us if this is...
self.found_type = mime_type if not self.found_type:
self.sound_file.mime_type = mime_type if not self.sound_file.mime_type:
def have_type(self, typefind, probability, caps): mime_type = caps.to_string() #debug("have_type:", mime_type, self.sound_file.get_filename_for_display()) self.found_type = None for t in mime_whitelist: if t in mime_type: self.found_type = mime_type if not self.found_type: log("Mime type skipped: %s (mail us if this is...
return Pipeline.work(self) and not self.found_type
return Pipeline.work(self) and not self.sound_file.mime_type
def work(self): return Pipeline.work(self) and not self.found_type