def what(): for i, d in enumerate(dupes): a = artists[i] if d: self.dupes.append(d) item = QTreeWidgetItem([a]) for z in sorted(d, key=dupe_sort): child = QTreeWidgetItem([tagtofilename(dispformat[0], z[0])]) item.addChild(child) [child.addChild(QTreeWidgetItem([ tagtofilename(dispformat[1],x)])) for x in sorted(z[1:], key=title_sort)] self.emit(SIGNAL('toplevel'), item) yield None
def update_status(enable = True): files = status['selectedfiles'] pattern = status['patterntext'] tf = lambda *args, **kwargs: encode_fn(findfunc.tagtofilename(*args, **kwargs)) if not files: return tag = files[0] state = {'__counter': u'1', '__total_files': unicode(len(files))} x = findfunc.filenametotag(pattern, tag[PATH], True) emit('ftstatus', display_tag(x)) bold_error = translate("Status Bar", "<b>%s</b>") try: newfilename = functions.move(tag, pattern, tag, state=state.copy()) if newfilename: newfilename = newfilename['__path'] emit('tfstatus', translate("Status Bar", "New Filename: <b>%1</b>").arg( decode_fn(newfilename))) else: emit('tfstatus', u'<b>No change</b>') except findfunc.ParseError, e: emit('tfstatus', bold_error % e.message)
def update_status(enable=True): files = status['selectedfiles'] pattern = status['patterntext'] tf = lambda *args, **kwargs: encode_fn( findfunc.tagtofilename(*args, **kwargs)) if not files: return tag = files[0] state = {'__counter': u'1', '__total_files': unicode(len(files))} x = findfunc.filenametotag(pattern, tag[PATH], True) emit('ftstatus', display_tag(x)) bold_error = translate("Status Bar", "<b>%s</b>") try: newfilename = functions.move(tag, pattern, tag, state=state.copy()) if newfilename: newfilename = newfilename['__path'] emit( 'tfstatus', translate("Status Bar", "New Filename: <b>%1</b>").arg( decode_fn(newfilename))) else: emit('tfstatus', u'<b>No change</b>') except findfunc.ParseError, e: emit('tfstatus', bold_error % e.message)
def exportm3u(tags, tofile, format = None, reldir = False, winsep=False): header = ['#EXTM3U'] if reldir: reldir = os.path.dirname(os.path.abspath(tofile)) filenames = [relpath(f.filepath, reldir) for f in tags] else: filenames = [f.filepath for f in tags] if winsep: filenames = [f.replace('/', '\\') for f in filenames] if format is None: text = '\n'.join(header + filenames) else: text = header extinfo = ('#EXTINF: %s, %s' % (str(lnglength(f.length)), encode_fn(tagtofilename(format, f, False))) for f in tags) [text.extend([z,y]) for z,y in zip(extinfo, filenames)] text = '\n'.join(text) playlist = open(tofile, 'w') playlist.write(text) playlist.close()
def save_cover(info, data, filetype): filename = tagtofilename(COVER_PATTERN, info, True, filetype) save_file(filename, data)