Hallo, This patch allows universal SP upload via USB to NetMD-Recorders. It also includes a small howto comment. Please keep in mind that you need a secret key to get things to work, which is not yet included due to unknown legal status. I also commited a git branch downloadhack-enhancements, but I don't know if that worked. yours Matthias
>From 6b155ebd221832f64591c851d9e4e27389c0ff01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= <matthias@mailaender.name> Date: Sun, 18 Jul 2010 22:53:49 +0200 Subject: [PATCH] =?UTF-8?q?Committer:=20Matthias=20Mail=C3=A4nder=20<https://launchpad.net/~mailaender> =20On=20branch=20downloadhack-enhancement =20Changes=20to=20be=20committed: =20 modified:=20=20=20netmd/downloadhack.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- netmd/downloadhack.py | 43 ++++++++++++++++++++++++++++++------------- 1 files changed, 30 insertions(+), 13 deletions(-) diff --git a/netmd/downloadhack.py b/netmd/downloadhack.py index f48f8ae..25722d0 100644 --- a/netmd/downloadhack.py +++ b/netmd/downloadhack.py @@ -1,9 +1,33 @@ #!/usr/bin/python import os +import sys +import getopt import usb1 import libnetmd from Crypto.Cipher import DES +# USAGE +####### +# first: create an uncompressed 16-bit stereo PCM: +# ffmpeg -i $audiofile -f s16be test.raw +####### +# plug in your NetMD using USB and use this script accordingly (title is optional): +# sudo python downloadhack.py --filename ~/music/test.raw --title songtitle + +from optparse import OptionParser +parser = OptionParser() +parser.add_option('-b', '--bus') +parser.add_option('-d', '--device') +parser.add_option('-f', '--filename') +parser.add_option('-t', '--title') +(options, args) = parser.parse_args() +assert len(args) < 4 +filename=options.filename +if options.title != None: + title=options.title +else: + title="no title" + def main(bus=None, device_address=None): context = usb1.LibUSBContext() for md in libnetmd.iterdevices(context, bus=bus, @@ -22,17 +46,17 @@ class EKB1_10: return (["\x25\x45\x06\x4d\xea\xca\x14\xf9\x96\xbd\xc8\xa4\x06\xc2\x2b\x81"], 9, \ "\x68\x86\x90\x89\xb7\x24\x18\x1e\xe8\x60\x04\x1d\x2e\xb3\xfd\xdb\xe7\x4c\x7c\xcd\xb1\xe3\x06\xc0") -testframes=4644 +framecount=int(os.path.getsize(filename)/2048) class MDTrack: def getTitle(self): - return "HACK" + return title def getFramecount(self): - return testframes + return framecount def getDataFormat(self): - return libnetmd.WIREFORMAT_LP2 + return libnetmd.WIREFORMAT_PCM def getContentID(self): # value probably doesn't matter @@ -52,10 +76,9 @@ class MDTrack: keycrypter = DES.new(self.getKEK(), DES.MODE_ECB) key = keycrypter.encrypt(datakey) datacrypter = DES.new(key, DES.MODE_CBC, firstiv) - # to be obtained from http://users.physik.fu-berlin.de/~mkarcher/ATRAC/LP2.wav - file = open("/tmp/LP2.wav") + file = open(filename) file.read(60) - data = file.read(testframes*192) + data = file.read(framecount*2048) return [(datakey,firstiv,datacrypter.encrypt(data))] def DownloadHack(md_iface): @@ -79,11 +102,5 @@ def DownloadHack(md_iface): md_session.close() if __name__ == '__main__': - from optparse import OptionParser - parser = OptionParser() - parser.add_option('-b', '--bus') - parser.add_option('-d', '--device') - (options, args) = parser.parse_args() - assert len(args) < 2 main(bus=options.bus, device_address=options.device) -- 1.7.0.4