def set_info(self, loc="", title="", artist="", album="", disc_id=0, genre="", track=0, length=0, bitrate=0, year="", modified=0, user_rating=0, rating=0, blacklisted=0, time_added='', encoding=xlmisc.get_default_encoding(), playcount=0): """ Sets track information """ # Doesn't matter what charset we use here, as long as we use # the same one when we decode (or encode as it were) if type(loc) is unicode: self._loc = loc else: try: self._loc = unicode(loc, xlmisc.get_default_encoding()) except (UnicodeDecodeError, TypeError): self._loc = loc self._encoding = encoding self._bitrate = bitrate self._len = length self.connections = [] self.date = year self.playing = 0 self.submitted = False self.last_position = 0 self.bitrate = bitrate self.modified = modified self.blacklisted = blacklisted self._rating = user_rating self.system_rating = rating self.time_added = time_added self.playcount = playcount for tag, val in {'title': title, 'artist': artist, 'album':album,\ 'genre': genre, 'discnumber':disc_id,\ 'tracknumber':track}.iteritems(): self.set_tag(tag, val)
def set_loc(self, value): """ Sets the location. It is always in unicode. If the value is not unicode, convert it into unicode using some default mapping. This way, when we want to access the file, we decode it back into the ascii and don't worry about botched up characters (ie the value should be exactly identical to the one given) """ self._loc = to_unicode(value, xlmisc.get_default_encoding())
def set_info(self,loc="", title="", artist="", album="", disc_id=0, genre="", track=0, length=0, bitrate=0, year="", modified=0, user_rating=0, rating=0, blacklisted=0, time_added='', encoding=xlmisc.get_default_encoding(), playcount=0): """ Sets track information """ # Doesn't matter what charset we use here, as long as we use # the same one when we decode (or encode as it were) if type(loc) is unicode: self._loc = loc else: try: self._loc = unicode(loc, xlmisc.get_default_encoding()) except (UnicodeDecodeError, TypeError): self._loc = loc self._encoding = encoding self._bitrate = bitrate self._len = length self.connections = [] self.date = year self.playing = 0 self.submitted = False self.last_position = 0 self.bitrate = bitrate self.modified = modified self.blacklisted = blacklisted self._rating = user_rating self.system_rating = rating self.time_added = time_added self.playcount = playcount for tag, val in {'title': title, 'artist': artist, 'album':album,\ 'genre': genre, 'discnumber':disc_id,\ 'tracknumber':track}.iteritems(): self.set_tag(tag, val)
def get_loc_for_io(self): """ Gets the location as ascii. Should always be correct, see set_loc. """ return self._loc.encode(xlmisc.get_default_encoding())