New topic: Help with RAR STORE parsing - Converting Python Routine
<http://forums.realsoftware.com/viewtopic.php?t=30573> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message eduo Post subject: Help with RAR STORE parsing - Converting Python RoutinePosted: Tue Oct 20, 2009 4:01 pm Joined: Sun Jun 24, 2007 12:24 pm Posts: 202 Location: Madrid Hi. I have a program that parses movie files to obtain a hash to uniquely identify (along with the bytesize) them and then check against a database that provides subtitles matched to said hash. I've been asked to provide hash for files compressed with RAR STORE functionality. I don't need to support the RAR compression algorithm, but I do need to parse the header. I have the specs for the header here: http://libxad.cvs.sourceforge.net/viewv ... iew=markup And I have a Python routine here: http://trac.opensubtitles.org/projects/ ... ourceCodes I need the same hash and size as this function provides, but in reality I just need to be able to obtain the first 64 bytes and the last 64 bytes of the file stored. I have the following function for the hash itself: Code:Function moviehash(extends f as folderItem) As string dim b as BinaryStream dim mb as MemoryBlock dim hash,bytesize as UINT64 dim i, x, chunksize, filelen as integer if f <> nil and f.Exists then b= f.OpenAsBinaryFile if b = nil then MsgBox str(f.LastErrorCode) return "" end hash = b.Length bytesize = b.Length if bytesize >= 65536 then chunksize = 65536 mb = b.Read(65536) mb.LittleEndian = True for i= 0 to chunksize -1 step 8 hash = hash+ mb.UINT64Value(i) next b.Position = max(b.Length-chunksize, 0) mb= b.Read(chunksize) mb.LittleEndian = True for i= 0 to chunksize -1 step 8 hash = hash+ mb.UINT64Value(i) next myhash = Lowercase(str(hex(hash))) return myhash else return "" end if else return "" end End Function So I could have a variant of this receiving just the head 64 bytes and the last 64 bytes. My problem is with the parsing of that header and then two byteblocks. I'm not being able to adopt this function for my needs. I don't do python, so I'm not sure but it looks to me like it's just offsetting some bytes and starts picking from that (at the beginning it's just looking for the last rar segment). Help, anyone? _________________ ---- http://eduo.info/ http://gallery.eduo.info/ http://twitter.com/eduo/ Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
