From matthias@mailaender.name Tue Jul 27 13:15:36 2010 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.69) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Odi8D-0003PY-O0>; Tue, 27 Jul 2010 13:15:33 +0200 Received: from mail.tiggerswelt.net ([94.186.151.130]) by relay1.zedat.fu-berlin.de (Exim 4.69) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Odi8D-0003BC-Jc>; Tue, 27 Jul 2010 13:15:33 +0200 Received: from [192.168.178.21] (p548CD5A1.dip.t-dialin.net [84.140.213.161]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.tiggerswelt.net (Postfix) with ESMTP id C0C037B10 for ; Tue, 27 Jul 2010 13:21:45 +0200 (CEST) Message-ID: <4C4EBFD3.5030502@mailaender.name> Date: Tue, 27 Jul 2010 13:15:31 +0200 From: =?ISO-8859-15?Q?Matthias_Mail=E4nder?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Lightning/1.0b1 Thunderbird/3.0.5 MIME-Version: 1.0 To: linux-minidisc@lists.fu-berlin.de X-Enigmail-Version: 1.0.1 Content-Type: multipart/mixed; boundary="------------050009070001060902060807" X-Originating-IP: 94.186.151.130 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1280229333-000069FD-A52CACBA/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.2 X-Spam-Flag: NO X-Spam-Checker-Version: SpamAssassin 3.0.4 on Algerien.ZEDAT.FU-Berlin.DE X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=RATWARE_GECKO_BUILD, SPF_HELO_PASS,SPF_PASS X-Mailman-Approved-At: Tue, 27 Jul 2010 13:31:16 +0200 Subject: [linux-minidisc] [PATCH] downloadhack enhancements X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jul 2010 11:15:36 -0000 This is a multi-part message in MIME format. --------------050009070001060902060807 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit 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 --------------050009070001060902060807 Content-Type: text/x-patch; name="0001-downloadhack-enhancement.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-downloadhack-enhancement.patch" >From 6b155ebd221832f64591c851d9e4e27389c0ff01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 18 Jul 2010 22:53:49 +0200 Subject: [PATCH] =?UTF-8?q?Committer:=20Matthias=20Mail=C3=A4nder=20 =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 --------------050009070001060902060807--