1
# Copyright (C) 2008-2009 Adam Olsen
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2, or (at your option)
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
from xl.metadata import BaseFormat
19
from mutagen import id3
22
logger = logging.getLogger(__name__)
25
class ID3Format(BaseFormat):
28
"originalalbum": "TOAL",
33
"originalartist": "TOPE",
35
"originaldate": "TDOR",
44
"tracknumber": "TRCK",
51
"organization": "TPUB",
57
def _get_tag(self, raw, t):
58
if not raw.tags: return []
59
if t not in self.tag_mapping.itervalues():
61
field = raw.tags.getall(t)
65
if t == 'TDRC' or t == 'TDOR': # values are ID3TimeStamps
67
ret.extend([unicode(x) for x in value.text])
68
elif t == 'USLT': # Lyrics are stored in plain old strings
70
ret.append(unicode(value.text))
71
elif t == 'WOAR': # URLS are stored in url not text
73
ret.extend([unicode(x.replace('\n','').replace('\r','')) \
78
ret.extend([unicode(x.replace('\n','').replace('\r','')) \
81
logger.warning("Can't parse ID3 field")
82
common.log_exception(logger)
85
def _set_tag(self, raw, tag, data):
86
if tag not in self.tag_mapping.itervalues():
88
if raw.tags is not None:
90
frame = id3.Frames[tag](encoding=3, text=data)
91
if raw.tags is not None: