Ejemplo n.º 1
0
    def convertTrack(self, track, artist=None, album=None, convert=True):
        if artist is None:
            artist = track[-2]
        if album is None:
            album = track[-1]

        if convert:
            if track[4]:
                self.cursor.execute(u"SELECT DISTINCT BINARY name FROM composer WHERE id = BINARY %s", (track[4],))
                composer = self.cursor.fetchall()[0][0]
            else:
                composer = u""

            if track[5]:
                self.cursor.execute(u"SELECT DISTINCT BINARY name FROM genre WHERE id = BINARY %s", (track[5],))
                genre = self.cursor.fetchall()[0][0]
            else:
                genre = u""

            if track[7]:
                self.cursor.execute(u"SELECT DISTINCT BINARY name FROM year WHERE id = BINARY %s", (track[7],))
                year = self.cursor.fetchall()[0][0]
            else:
                year = u""
        else:
            composer = track[4]
            genre = track[5]
            year = track[7]

        filename = track[0][1:]
        temp = {
            "__filename": filename,
            "__folder": dirname(filename),
            "__created": audioinfo.strtime(track[2]),
            "__modified": audioinfo.strtime(track[3]),
            "album": album,
            "artist": artist,
            "composer": composer,
            "genre": genre,
            "title": track[6],
            "year": year,
            "comment": track[8],
            "track": unicode(track[9]),
            "discnumber": unicode(track[10]),
            "__bitrate": audioinfo.strbitrate(track[11] * 1000),
            "__length": audioinfo.strlength(track[12]),
            "__frequency": audioinfo.strfrequency(track[13]),
            "__size": unicode(track[14]),
            "___filetype": unicode(track[15]),
            "___sampler": unicode(track[16]),
            "bpm": unicode(track[17]),
            "___deviceid": unicode(track[18]),
            "__path": os.path.basename(filename),
            "__ext": os.path.splitext(filename)[1][1:],
            "__library": "amarok",
        }

        return self.applyToDict(self.applyToDict(temp, self.valuetostring), self.latinutf)
Ejemplo n.º 2
0
    def convertTrack(self, track, artist = None, album = None):
        join = os.path.join
        if artist is None:
            #print len(track), track
            try:
                artist = track[21]
            except:
                print track.tags
                raise

        if album is None:
            album = track[22]
        try:
            genre = GENRES[track[8]]
        except (IndexError, TypeError):
            genre = u''

        temp = {'__filename': join(track[0], track[1]),
            '__path': track[1],
            '__ext': os.path.splitext(track[1])[1][1:], #Don't need(or want) the extra dot
            '__bitrate': audioinfo.strbitrate(track[2] * 1000),
            '__frequency': audioinfo.strfrequency(track[3]),
            '__length': audioinfo.strlength(track[4]),
            '__folder': track[0],
            'title': track[5],
            'track': track[6],
            'year': track[7],
            'genre': genre,
            'comment': track[9],
            '__size' : track[10],
            '__modified': track[11],
            'artist': artist,
            'album': album,
            '__library': 'prokyon',
            "___layer": track[12],
            '___mimetype': track[13],
            '___version': track[14],
            '___mode': track[15],
            '___lyricsid': track[16],
            '___synclyricsid': track[17],
            '___notes': track[18],
            '___rating': track[19],
            '___medium': track[20]}

        return self.applyToDict(self.applyToDict(temp, self.valuetostring), self.latinutf)