forked from flindroth/netmd.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathputWave.py
More file actions
executable file
·61 lines (45 loc) · 1.31 KB
/
putWave.py
File metadata and controls
executable file
·61 lines (45 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python2
import sys
import os
from libnetmd.download import download
from optparse import OptionParser
from songutils.id3reader import Reader
from songutils.transcoder import transcode
parser = OptionParser()
parser.add_option('-b', '--bus')
parser.add_option('-d', '--device')
parser.add_option('-f', '--filename')
parser.add_option('-F', '--format')
parser.add_option('-t', '--title')
(options, args) = parser.parse_args()
assert len(args) < 4
filename=options.filename
informat=options.format
WF_PCM = 0
WF_105KBPS = 0x90
WF_LP2 = 0x94
WF_LP4 = 0xA8
wireformat = WF_PCM
if informat == '' or informat == 'PCM' or informat == 'SP':
wireformat = WF_PCM
if informat == 'LP2':
wireformat = WF_LP2
if options.title != None:
title=options.title
else:
title=None
if title == None:
id3r = Reader(filename)
id3performer = id3r.getValue('performer')
id3title = id3r.getValue('title')
if id3title != None and id3performer != None:
title = "%s - %s" % (id3performer, id3title)
elif id3title != None and id3performer == None:
title = id3title
else:
title = os.path.basename(filename)
tr_filename = transcode(filename)
if tr_filename == None:
print "ERROR: Could not transcode source file. ffmpeg is required."
sys.exit(1)
download(tr_filename,title,wireformat)