15
15
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
# The developers of the Exaile media player hereby grant permission
19
# for non-GPL compatible GStreamer and Exaile plugins to be used and
20
# distributed together with GStreamer and Exaile. This permission is
21
# above and beyond the permissions granted by the GPL license by which
22
# Exaile is covered. If you modify this code, you may extend this
23
# exception to your version of the code, but you are not obligated to
24
# do so. If you do not wish to do so, delete this exception statement
18
# The developers of the Exaile media player hereby grant permission
19
# for non-GPL compatible GStreamer and Exaile plugins to be used and
20
# distributed together with GStreamer and Exaile. This permission is
21
# above and beyond the permissions granted by the GPL license by which
22
# Exaile is covered. If you modify this code, you may extend this
23
# exception to your version of the code, but you are not obligated to
24
# do so. If you do not wish to do so, delete this exception statement
25
25
# from your version.
27
27
import os, threading, copy
28
from xl import transcoder, track, settings, common
28
from xl import transcoder, trax, settings, common
31
31
class CDImporter(object):
32
32
def __init__(self, tracks):
33
self.tracks = [ t for t in tracks if
33
self.tracks = [ t for t in tracks if
34
34
t.get_loc_for_io().startswith("cdda") ]
35
self.duration = float(sum( [ t['__length'] for t in self.tracks ] ))
35
self.duration = float(sum( [ t.get_tag_raw('__length') for t in self.tracks ] ))
36
36
self.transcoder = transcoder.Transcoder()
37
37
self.current = None
38
38
self.current_len = None
63
63
for tr in self.tracks:
66
self.current_len = tr['__length']
67
tags = copy.copy(tr.tags)
69
if t.startswith("__"):
66
self.current_len = tr.get_tag_raw('__length')
71
67
loc = tr.get_loc_for_io()
72
trackno, device = loc[7:].split("#")
68
trackno, device = loc[7:].split("/#")
73
69
src = "cdparanoiasrc track=%s device=\"%s\""%(trackno, device)
74
70
self.transcoder.set_raw_input(src)
75
71
outloc = self.get_output_location(tr)
79
75
if not self.running:
81
tr2 = track.Track("file://"+outloc)
77
tr2 = trax.Track("file://"+outloc)
78
for t in tr.list_tags():
79
if not t.startswith("__"):
80
tr2.set_tag_raw(t, tr.get_tag_raw(t))
85
incr = tr['__length'] / self.duration
83
incr = tr.get_tag_raw('__length') / self.duration
86
84
self.progress += incr
100
98
replacedict["$%s"%tag] = tag
101
99
for part in parts:
102
100
for k, v in replacedict.iteritems():
104
if type(val) in (list, tuple):
105
val = u" & ".join(val)
101
val = tr.get_tag_display(v, artist_compilations=False)
102
val = val.replace('"', '\\"')
106
103
part = part.replace(k, str(val))
107
104
part = part.replace(os.sep, "") # strip os.sep
108
105
parts2.append(part)
109
dirpath = "/" + os.path.join(*parts2[:-1])
106
dirpath = "/" + os.path.join(*parts2[:-1])
110
107
if not os.path.exists(dirpath):
111
108
os.makedirs(dirpath)
112
109
ext = transcoder.FORMATS[self.transcoder.dest_format]['extension']