usdb_syncer icon indicating copy to clipboard operation
usdb_syncer copied to clipboard

Allow users to run custom commands after download

Open randompersona1 opened this issue 6 months ago • 1 comments

This PR adds the ability to run a user-set command after the song has downloaded. This enables the syncer to be infinitely customizable at a users whim, for example, being able to split songs with AI or transcode videos to a more efficient codec.

settings screenshot

Usage

A new setting with a plain text field allows entering the command. In the user-set command, occurrences of "$dir$" (writing this, I am not convinced of that name) will be replaced by the song folder that was just downloaded. The command is executed in the global song directory. A user could create a batch file there with the song folder as an argument, and write everything else in the batch file.

Example Usage

I want to split my songs with demucs. Unfortunately, I could not get it to work with cuda in python3.12. The only thing I managed was to pin the torch dependencies to specific releases and use python3.11 for the project. This makes running that from python3.12 a pain. With this feature, I can write a little batch script that just passes the song folder to my program and launches it with poetry correctly (i could also enter the poetry command in the settings), therefore bypassing many requirements I assume are being written in the instrumental-version branch, for example actually installing the cuda drivers, and using the correct torch dependancy, because the cuda version of torch obviously doesn't work for users that don't have an nvidia graphics card. This feature allows users like me to take some of that responsibility, which definitely doesn't work for everyone, but greatly improves the experience those that can take advantage of it.

Implementation details

I decided not to write stdout of the command to the log, because that seemed like a great idea for completely spamming the log. The return code of the command is written to the log as an info, so there is that for communication. Otherwise, I've tried to include as much information about execution into the log, so there shouldn't be any confusion there.

Regarding security, I don't think there is any need to consider it. We are only running a user-supplied command, at the same execution level as the rest of the syncer.

randompersona1 avatar Aug 13 '24 21:08 randompersona1