Quick Sign In:  

Forum: VirtualDJ Plugins

Topic: Plugin - range date played
Hi, with the help of chat gpt I was trying to create this plugin that should open a dialog box (somehow I still don't know), where I insert the dates and the start and end time of the range, giving the 'Ok it should color all the tracks that have been reproduced in that range.

I downloaded and tried to configure everything in C ++ on XCode (given that I need the plugin for macOS), but I don't know how to go on to make it working.

Could any of you give me a hand?
Thank you

#include "vdjPlugin8.h"
#include <iostream>
#include <ctime>
#include <vector>

// Define macros if not defined by the SDK
#ifndef DllExport
#define DllExport __attribute__((visibility("default")))
#endif

#ifndef VDJ_API
#define VDJ_API
#endif

// Data structure to store played tracks information
struct PlayedTrack {
std::string trackName;
std::time_t playedTime;
};

// List to store played tracks
std::vector<PlayedTrack> playedTracks;

// Function to convert string to time_t
std::time_t stringToTimeT(const std::string& dateTime) {
struct tm tm;
strptime(dateTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm);
return mktime(&tm);
}

// Function to check if a track was played within a specific range
bool isTrackPlayedInRange(const PlayedTrack& track, std::time_t start, std::time_t end) {
return (track.playedTime >= start && track.playedTime <= end);
}

// Entry point for the plugin
extern "C" {
DllExport void VDJ_API PluginStart() {
// Initialize plugin
}

DllExport void VDJ_API OnTrackPlayed(const char* trackName) {
// Get the current time
std::time_t now = std::time(nullptr);
// Add track to played tracks list
playedTracks.push_back({trackName, now});
}

DllExport void VDJ_API ShowDialog() {
// Show dialog to get start and end date/time
std::string startDate, endDate;
std::cout << "Enter start date/time (YYYY-MM-DD HH:MM:SS): ";
std::cin >> startDate;
std::cout << "Enter end date/time (YYYY-MM-DD HH:MM:SS): ";
std::cin >> endDate;

// Convert strings to time_t
std::time_t start = stringToTimeT(startDate);
std::time_t end = stringToTimeT(endDate);

// Highlight tracks played in the specified range
for (const auto& track : playedTracks) {
if (isTrackPlayedInRange(track, start, end)) {
std::cout << "Highlighting track: " << track.trackName << std::endl;
// Code to highlight track in VirtualDJ UI
}
}
}
}

 

Posted Sat 01 Jun 24 @ 9:17 pm
locoDogPRO InfinityModeratorMember since 2013
I don't think you can access the colorRules via the API, you could use quick_filter to only show tracks within your range.

you'd need to convert your std::time_t start / end to
double start_days_since_now
double end_days_since_now

then do something like this

std::stringstream cmd;
cmd << "quick_filter 0 ? quick_filter off : get_text 'Days since Last Play >= " << start_days_since_now << " and Days since Last Play <= " << end_days_since_now << "' & param_cast text & quick_filter"
SendCommand(cmd.str().c_str());


Something like that, there might be better ways but that's my first take on it.
 

Posted Sun 02 Jun 24 @ 1:37 am
AdionPRO InfinityCTOMember since 2006
Also note that nothing of the code produced by chatgpt is even remotely right to create a vdj plugin, so I recommend to use the plugin documentation directly instead of chatgpt
 

Posted Sun 02 Jun 24 @ 3:21 am
locoDogPRO InfinityModeratorMember since 2013
I think...[dangerous, I know] the quick filter way could be done with just script.

set_var_dialog for input
countdown script to turn date into days since date.
virtualfx maybe to make it easier to slot things in.

That could be made without breaking out the IDE
 

Posted Sun 02 Jun 24 @ 3:58 am
Thanks for the advice, I know that using Chatgpt is not a nice idea for this type of thing, but I still wanted to try because I really need this function.

Can you recommend another way to highlight with a color all the traces reproduced in a date and time range?
It would be very useful to know which songs I mixed an evening in the disco and orient yourself only with the day is not enough because you may have reproduced it even the next day, so e.g. The "reproduced from <7 days" is not a reliable figure.

If there is no simple way to do it, can someone develop this paid plugin for me?
Thanks
 

Posted Sun 02 Jun 24 @ 12:04 pm
locoDogPRO InfinityModeratorMember since 2013
days is a float, so
Days since Last Play < 0.25

is played less than 6 hours ago

And like I said you can't access colorRules via script or the API, and actually tag colouring tracks would not be a good idea [because tag colouring is permanent, and would be pretty expensive/messy processing wise]

I could make you the quick_filter way for a couple of beers, but it would just hide tracks that don't match the filter, it wouldn't colour anything.
 

Posted Sun 02 Jun 24 @ 1:07 pm
Thanks Loco Dog for the starting point,
I thought about it for a moment and it was actually simpler than it seemed.

Just create a range of dates and now with Last Play and thus color the tracks. I don't care to add a filter.
 

Posted Sun 02 Jun 24 @ 2:29 pm
locoDogPRO InfinityModeratorMember since 2013
locoDog wrote :
you can't access colorRules via script or the API...


colouring isn't possible, I'm experimenting now and even with every trick I know, quick_filter 0 is proving difficult, it might be possible with a standard filter folder.
 

Posted Sun 02 Jun 24 @ 3:03 pm
locoDogPRO InfinityModeratorMember since 2013
I got it made, yesterday... monday, I forget, not easy I needed a clear head to work out the virtualfx
 

Posted Wed 05 Jun 24 @ 9:31 pm