Beispiel #1
0
 def loadDupes(self, lib, algos, dispformat, maintag = 'artist'):
     self.clear()
     dupes = dupesinlib(lib, algos, maintag = maintag)
     self.dupes = []
     artists = dupes.next()
     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
     s = progress(what, 'Checking ', len(artists))
     self.connect(self, SIGNAL('toplevel'), self._addItem)
     if self.parentWidget():
         s(self.parentWidget())
     else:
         s(self)
Beispiel #2
0
 def loadDupes(self, lib, algos, dispformat, maintag = 'artist'):
     self.clear()
     dupes = dupesinlib(lib, algos, maintag = maintag)
     self.dupes = []
     artists = dupes.next()
     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
     s = progress(what, 'Checking ', len(artists))
     self.connect(self, SIGNAL('toplevel'), self._addItem)
     if self.parentWidget():
         s(self.parentWidget())
     else:
         s(self)
Beispiel #3
0
 def writeTags(self, tagiter, rows=None, previews=None):
     ret = self._write(tagiter, rows, previews)
     if ret is None:
         return
     
     func, fin, rows = ret
     s = progress(func, translate("Defaults", 'Writing '), len(rows), fin)
     s(self)
Beispiel #4
0
    def writeTags(self, tagiter, rows=None, previews=None):
        ret = self._write(tagiter, rows, previews)
        if ret is None:
            return

        func, fin, rows = ret
        s = progress(func, translate("Defaults", 'Writing '), len(rows), fin)
        s(self)
Beispiel #5
0
    def writeOneToMany(self, d):
        rows = status["selectedrows"]
        ret = self._write((d.copy() for r in rows), rows)
        if ret is None:
            return
        func, fin, rows = ret

        s = progress(func, translate("Defaults", "Writing "), len(rows), fin)
        s(self)
Beispiel #6
0
    def writeOneToMany(self, d):
        rows = status['selectedrows']
        ret = self._write((d.copy() for r in rows), rows)
        if ret is None:
            return
        func, fin, rows = ret

        s = progress(func, translate("Defaults", 'Writing '), len(rows), fin)
        s(self)
Beispiel #7
0
 def writeAction(self, tagiter, rows=None, state=None):
     if state is None:
         state = {}
     ret = self._write(tagiter, rows)
     if ret is None:
         return
     func, fin, rows = ret
     def finished():
         fin()
         if 'rename_dirs' in state:
             self.renameDirs(state['rename_dirs'].items())
     s = progress(func, translate("Defaults", 'Writing '), len(rows),
         finished)
     s(self)
Beispiel #8
0
    def writeAction(self, tagiter, rows=None, state=None):
        if state is None:
            state = {}
        ret = self._write(tagiter, rows)
        if ret is None:
            return
        func, fin, rows = ret

        def finished():
            fin()
            if 'rename_dirs' in state:
                self.renameDirs(state['rename_dirs'].items())

        s = progress(func, translate("Defaults", 'Writing '), len(rows),
                     finished)
        s(self)
Beispiel #9
0
        return k
    add_shortcuts('&Plugins', [sep(), action, sep()])

def add_seconds(parent=None):
    if status['previewmode']:
        QMessageBox.information(parent, 'puddletag',
            QApplication.translate("Previews",
                'You need to disable preview mode first.'))
        return

    files = status['selectedfiles']
    rows = status['selectedrows']
    def func():
        for row, f in zip(rows, files):
            modified_time = lngtime(f['__modified'])
            modified_time = datetime.fromtimestamp(modified_time) + timedelta(seconds=2)
            accessed_time = lngtime(f['__accessed'])
            try:
                os.utime(f.filepath, (accessed_time, time.mktime(modified_time.timetuple())))
            except (IOError, OSError), e:
                filename = f[audioinfo.PATH]
                m = unicode(QApplication.translate("Defaults",
                    'An error occured while setting the modification time of <b>%1</b>. (%2)').arg(filename).arg(e.strerror))
                if row == rows[-1]:
                    yield m, 1
                else:
                    yield m, len(rows)

    s = progress(func, QApplication.translate("Adding 2 seconds to mod times...",
        'Setting modification time '), len(files))
    s(parent)
Beispiel #10
0
                tag = PATH
                if tag in audio.mapping:
                    tag = audio.mapping[tag]
                try:
                    setRowData(row, {tag: filename}, True, True)
                    yield None
                except EnvironmentError, e:
                    m = translate("Dir Renaming",
                        'An error occured while renaming <b>%1</b> to ' \
                        '<b>%2</b>. (%3)').arg(audio[PATH]).arg(filename).arg(e.strerror)
                    if row == rows[-1]:
                        yield m, 1
                    else:
                        yield m, len(rows)

        s = progress(func, translate("Dir Renaming", 'Renaming '), len(rows), fin)
        s(self)

    def renameDirs(self, dirs):
        self._table.saveSelection()
        showmessage = True
        dirs = sorted(dirs, dircmp, itemgetter(0))
        for index, (olddir, newdir) in enumerate(dirs):
            try:
                if os.path.exists(newdir) and (olddir != newdir):
                    raise IOError(EEXIST, os.strerror(EEXIST), newdir)
                os.rename(olddir, newdir)
                self._table.changeFolder(olddir, newdir)
                if self._lastdir and olddir in self._lastdir:
                    self._lastdir[self._lastdir.index(olddir)] = newdir
            except (IOError, OSError), detail:
Beispiel #11
0
    files = status['selectedfiles']
    rows = status['selectedrows']

    def func():
        for row, f in zip(rows, files):
            modified_time = lngtime(f['__modified'])
            modified_time = datetime.fromtimestamp(modified_time) + timedelta(
                seconds=2)
            accessed_time = lngtime(f['__accessed'])
            try:
                os.utime(
                    f.filepath,
                    (accessed_time, time.mktime(modified_time.timetuple())))
            except (IOError, OSError), e:
                filename = f[audioinfo.PATH]
                m = unicode(
                    QApplication.translate(
                        "Defaults",
                        'An error occured while setting the modification time of <b>%1</b>. (%2)'
                    ).arg(filename).arg(e.strerror))
                if row == rows[-1]:
                    yield m, 1
                else:
                    yield m, len(rows)

    s = progress(
        func,
        QApplication.translate("Adding 2 seconds to mod times...",
                               'Setting modification time '), len(files))
    s(parent)
Beispiel #12
0
        for row, f in zip(rows, files):
            try:
                _remove_tag(f, tag)
                yield None
            except (IOError, OSError), e:
                filename = f[audioinfo.PATH]
                m = translate(
                    "Defaults",
                    'An error occured while writing to <b>%1</b>. (%2)')
                m = m.arg(filename).arg(e.strerror)
                if row == rows[-1]:
                    yield m, 1
                else:
                    yield m, len(rows)
        status['model'].undolevel += 1

    s = progress(func, translate("Tag Tools", 'Removing %s tag: ' % tag),
                 len(files))
    s(parent)


remove_apev2 = lambda parent=None: remove_tag('APEv2', parent)
remove_id3 = lambda parent=None: remove_tag('ID3', parent)
remove_id3v1 = lambda parent=None: remove_tag('ID3v1', parent)
remove_id3v2 = lambda parent=None: remove_tag('ID3v2', parent)


def set_status(stat):
    global status
    status = stat
Beispiel #13
0
        for row, f in zip(rows, files):
            try:
                if isinstance(f, id3_tag):
                    f.to_encoding(3)
                    f.link(f.filepath)
                yield None
            except (IOError, OSError), e:
                filename = f[audioinfo.PATH]
                m = unicode(QApplication.translate("Defaults",
                    'An error occured while converting <b>%1</b>. (%2)').arg(filename).arg(e.strerror))
                if row == rows[-1]:
                    yield m, 1
                else:
                    yield m, len(rows)

    s = progress(func, QApplication.translate("ID3 Plugin",
        'Converting '), len(files))
    s(parent)

def update_to_24(parent=None):
    if status['previewmode']:
        QMessageBox.information(parent, 'puddletag',
            QApplication.translate("Previews",
                'You need to disable preview mode first.'))
        return
    files = status['selectedfiles']
    rows = status['selectedrows']

    def func():
        for f in files:
            try:
                if isinstance(f, id3_tag):
Beispiel #14
0
                tag = PATH
                if tag in audio.mapping:
                    tag = audio.mapping[tag]
                try:
                    setRowData(row, {tag: filename}, True, True)
                    yield None
                except EnvironmentError, e:
                    m = translate("Dir Renaming",
                        'An error occured while renaming <b>%1</b> to ' \
                        '<b>%2</b>. (%3)').arg(audio[PATH]).arg(filename).arg(e.strerror)
                    if row == rows[-1]:
                        yield m, 1
                    else:
                        yield m, len(rows)

        s = progress(func, translate("Dir Renaming", 'Renaming '), len(rows),
                     fin)
        s(self)

    def renameDirs(self, dirs):
        self._table.saveSelection()
        showmessage = True
        dirs = sorted(dirs, dircmp, itemgetter(0))
        for index, (olddir, newdir) in enumerate(dirs):
            try:
                if os.path.exists(newdir) and (olddir != newdir):
                    raise IOError(EEXIST, os.strerror(EEXIST), newdir)
                os.rename(olddir, newdir)
                self._table.changeFolder(olddir, newdir)
                if self._lastdir and olddir in self._lastdir:
                    self._lastdir[self._lastdir.index(olddir)] = newdir
            except (IOError, OSError), detail:
Beispiel #15
0
    files = status['selectedfiles']
    rows = status['selectedrows']

    def func():
        for row, f in zip(rows, files):
            try:
                _remove_tag(f, tag)
                yield None
            except (IOError, OSError), e:
                filename = f[audioinfo.PATH]
                m = translate("Defaults",
                    'An error occured while writing to <b>%1</b>. (%2)')
                m = m.arg(filename).arg(e.strerror)
                if row == rows[-1]:
                    yield m, 1
                else:
                    yield m, len(rows)
        status['model'].undolevel += 1

    s = progress(func, translate("Tag Tools",
        'Removing %s tag: ' % tag), len(files))
    s(parent)

remove_apev2 = lambda parent=None: remove_tag('APEv2', parent)
remove_id3 = lambda parent=None: remove_tag('ID3', parent)
remove_id3v1 = lambda parent=None: remove_tag('ID3v1', parent)
remove_id3v2 = lambda parent=None: remove_tag('ID3v2', parent)

def set_status(stat):
    global status
    status = stat
Beispiel #16
0
                    f.to_encoding(3)
                    f.link(f.filepath)
                yield None
            except (IOError, OSError), e:
                filename = f[audioinfo.PATH]
                m = unicode(
                    QApplication.translate(
                        "Defaults",
                        'An error occured while converting <b>%1</b>. (%2)').
                    arg(filename).arg(e.strerror))
                if row == rows[-1]:
                    yield m, 1
                else:
                    yield m, len(rows)

    s = progress(func, QApplication.translate("ID3 Plugin", 'Converting '),
                 len(files))
    s(parent)


def update_to_24(parent=None):
    if status['previewmode']:
        QMessageBox.information(
            parent, 'puddletag',
            QApplication.translate("Previews",
                                   'You need to disable preview mode first.'))
        return
    files = status['selectedfiles']
    rows = status['selectedrows']

    def func():
        for f in files: