Crate digging in 2020: mpv + lua

01 Jun 2020

What's crate digging?

"A term used by DJ's and collectors to refer to the act of checking record stores, flea markets or thrift shops for second hand music on vinyl"

For me, crate digging is sifting through a lot of music for tracks of interest and doing that really fast.

What's MPV?

mpv is a free, open source, and cross-platform media player. If you are a Linux user and not using mpv then you are seriously missing out!!

You can use mpv to play everything.. LIKE EVERYTHING: a livestream, a radio station, youtube videos, local files, gifs, jpegs, mp3s, flacs, you name it, mpv will play it.

mpv + lua = superpowers

The best part about mpv is that you can script it easily using few langauges and make it do pretty much anything you can imagine. Check out this wiki for a list of user scripts.

Crate digging with mpv

The other reason I like mpv is that it's blazingly fast. There is almost zero latency in switching and browsing between tracks.

This, together with the scripting functionality makes it the perfect candidate for sifting through music super fast. Over time, you can customise this workflow with scripts and I can imagine this being THE way for the modern DJ to organize and prepare their sets.

I've prototyped this idea as follows:

You'll need to install two scripts:

  1. navigator.lua: This will let you browse files and hit play without ever leaving mpv.
  2. crate.lua: This will let you hard-link files into a pre-defined directory which we'll call the "crate", aka your short-list.

The advantage of hard linking is that you can "duplicate" directory structures without taking up additional hard drive space.

Then, the flow goes as such:

  1. First, configure crate.lua's settings table in the script. This is important.
  2. Run mpv /directory/with/lots/of/mp3s from your terminal. Note that the UI/OSD is right in your terminal :)
  3. If you hit F the navigator.lua hotkey should trigger. You can navigate with vim keybindings. Hit enter to load a directory into playlist
  4. At any time, you can hit the ` button to trigger the crate plugin. Instruction will be printed out. Here's an example:
[x]. Trash L0: techxvnode/-dnb variado/atlantic connection - northside.mp3
[c]. Crate L0: techxvnode/-dnb variado/atlantic connection - northside.mp3
[s]. Trash L1: techxvnode/-dnb variado
[d]. Crate L1: techxvnode/-dnb variado
[w]. Trash L2: techxvnode
[e]. Crate L2: techxvnode

Enabled crater
A: 00:00:37 / 00:05:45 (10%)
  • If you're never going to want this particular track, just hit x and be done with it.
  • If you want to shortlist it, you can hit c. A hard link to the song will be created in your crate_dir
  • If you want to delete the whole directory that this file is in, you can use the "L1" keys.. and so on


musicdjingproductionmusic productionhousetechnoTweet