Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>my <code>aggregate_digup</code> program reads an extended sha1sum.txt format file produced by the <a href="https://idlebox.net/2009/digup/" rel="nofollow">digup</a> program. this lets me locate a file based on its sha1sum. the digup program stores the mtime size hash and pathname in its output. by default it skips hashing a file if the mtime and size match. the index produced by my aggregate_digup is used by my modifed version of the open uri context menu gedit plugin allowing one to option click on <code>sha1:b7d67986e54f852de25e2d803472f31fb53184d5</code> and it'll list the copies of the file it knows about so you can pick one and open it.</p> <p>how this relates to the problem is that there are two parts: one the playlists and two the files.</p> <p>if we can assume that nothing the player does changes the files, then the hash and sizes of the files are constant. so we should be able to use the size and hash of a file as a unique identifier.</p> <p>for example the key for the file mentioned: <code>222415:b7d67986e54f852de25e2d803472f31fb53184d5</code></p> <p>i've found that in practice this has no collisions in any natural collection.</p> <p>(this does mean that the ID3 metadata which is appended or prepended to the mp3 data can't change unless you choose to skip that metadata while hashing)</p> <p>so the playlist database would be something this:</p> <pre><code>files(file_key, hash, size, mtime, path, flag) tracks(file_key, title, artist) playlists(playlistid, index, file_key) </code></pre> <p>to update the files table:</p> <pre><code>import os import stat # add new files: update files set flag=0 for path in filesystem: s=os.stat(path) if stat.S_ISREG(s.st_mode): fetch first row of select mtime, hash, size from files where path=path if row is not None: if s.st_mtime == mtime and s.st_size == size: update files set flag=1 where path=path continue hash=hash_file(path) file_key="%s:%s" % (int(s.st_mtime), hash) insert or update files set file_key=file_key, size=s.st_size, mtime=s.st_mtime, hash=hash, flag=1 where path=path # remove non-existent files: delete from files where flag=0 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload