Multi-Source Sets and Shared/Merged History | No "Start Time" on History Exports

Hey, normally I export tracks to the internal SSD on my Prime 4+ and play from that single Source. Last night, I played tracks from that internal SSD, and would switch over to a USB I plugged in, with it’s own library, etc.

After the set, I normally open Engine DJ Desktop and export the set playlist via History functionality, but I noticed that from last night, there are two entries in my history for that date, one of them containing only tracks played from the internal SSD, and another containing only tracks played from the USB.

Once I learned how Engine DJ Desktop shows all your libraries of all the drives on your machine, merging them together into a single view, I kinda expected to see something similar with History, even if it meant needing to have the other sources plugged in when exporting it, but instead I see two completely separate History entries.

I believe that in the past if I’ve mixed two sets on the same day, both of those sets’ tracks were found in the same History entry, under the date performed, so I thought the same would be true for a single set performed using multiple Sources.

This isn’t a huge deal, as I can just export both History entries, and merge them, except the exports are missing a critical field: “Start Time”. If these exports contained “Start Time”, I could merge both .csv files, sort by this column, and have a single, unified setlist that reflected the order of the tracks played, regardless of source.

If there is a way that I can add “Start Time” to my History exports, please let me know, otherwise, I hope to see this column added to these exports. I also hope to see the row values to be YYYY-MM-DD for proper string sorting without having to interpret the values as datetime objects.

Thanks

The good news is that the playlist entries in h.db do contain proper start time for each track. Perhaps this is a great opportunity for a feature request?

Yeah, that’s a great idea. I just want to make sure I’m not missing something first before making such a request.

I just tried to export the entire month history, figuring I could just trim it down to my most recent set, however when exporting a month, the resulting CSV is sorted based on the artist name, making it unsuitable to create a setlist. Even having the view in History sorted by date, the export doesn’t honor the sorting and comes out sorted by artist name.

The sorting in the CSV can be done a few ways:

  • Write a command line utility to ingest and sort
  • Import CSV into a spreadsheet app like Google Sheets / Excel, sort then export as CSV or whatever you want.

Except the column “Start Time” is not included in the .csv exports, thus I cannot sort.

I intend to sort and merge via CLI, something along the lines of

sort -t ',' -k COL_NUM,COL_NUM *.csv > sorted.csv

Where COL_NUM is the column with the “Start Time” information.

I’ll then tie it in with my existing workflow/pipeline:

#!/usr/bin/env python3
# @earthmeLon

import csv
import argparse

parser = argparse.ArgumentParser(add_help=False)
parser.add_argument(
    "filename", nargs='?', type=str, metavar="FILENAME",
    help="CSV File to Open"
)

args = parser.parse_args()


results = []
firstline = True
with open(args.filename) as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        if firstline:
            firstline = False
            continue
        trackname = f"{row[2]} - {row[1]}"
        if trackname not in results:
            #results += f"{row[2]} - {row[1]}\n"
            results.append(trackname)

print('\n'.join(results))
engine_setlist "$(dialog --inputbox test 0 0 --output-fd 1)" | xsel --clipboard; clear

Ok, given you are familiar with Python, then this stuff should be easy for you to implement:

On your host OS, there is a database file called hm.db. I imagine that hm means history main. From what I can tell, every time you open Engine with performance volumes attached, the history will be imported here.

To query all of the histories:

select id, strftime('%Y-%m-%d %H:%M', Historylist.startTime, 'unixepoch') timeStart, originDriveName 
from historyList order by HistoryList.startTime

If you know a specific history you’d like to import, then you can query the DB like this and get the data you want:

SELECT 
	HistorylistEntity.listId,
	strftime('%Y-%m-%d %H:%M', HistoryListEntity.startTime, 'unixepoch') timeStart,
	HistorylistEntity.trackId,
	Track.title,
	Track.artist
FROM 
	HistorylistEntity
INNER JOIN
	Track 
ON 
	Track.id = HistorylistEntity.trackId
WHERE 
	HistorylistEntity.listId = 2 -- Playlist ID here 
ORDER BY 
	HistorylistEntity.startTime

3 Likes

This is incredible information. Thank you.

1 Like

my pleasure. I’m glad to see my hours of digging into this stuff go into some use :wink:

4 Likes