Sign In:     


Forum: Addons

Topic: LocalJSON
 

Posted Thu 26 Dec 24 @ 1:44 pm
Er...."Use you own JSON file" for what? How?
 

Some users knows how to generate a JSON file (webmasters, Python, ...) but doesn't know c++ and how to compile a dll file. So I thought it would help to make a OnlineSource plugin that reads a JSON file on the drive. It uses the same structure as in the VDJ SDK but in JSON format.
{PluginName}.json is in the same folder as the dll

https://www.virtualdj.com/wiki/Plugins_SDKv8_OnlineSource.html

https://www.virtualdj.com/wiki/Plugins_SDKv8_Example7.html

You need to edit "streamUrl" with the url of your mp3 file for example
 

For the ones who are not expert in JSON and you have many lines, an easy way is Python.
Please find some ideas:

import json
import pandas as pd

def test1_sort_json():
strFilepath_In = "C:\\Users\\xxxx\\AppData\\Local\\VirtualDJ\\Plugins64\\OnlineSources\\yyyy.json"
strFilepath_Out = "C:\\Users\\xxxx\\AppData\\Local\\VirtualDJ\\Plugins64\\OnlineSources\\yyyy_fixed.json"

df = pd.read_json(strFilepath_In)

df_sorted = df.sort_values(by='uniqueId', ascending=False)

#df_sorted.drop_duplicates(subset=['uniqueId'],keep='first',inplace=True)

df_sorted['uniqueId'] = df_sorted['uniqueId'].astype(str)

json_str = df_sorted.to_json(strFilepath_Out, orient='records')


def test2_read_json():
strFilepath = "C:\\Users\\xxxx\\AppData\\Local\\VirtualDJ\\Plugins64\\OnlineSources\\yyyy.json"

fp = open(strFilepath, "r", encoding="utf8")

data = json.load(fp)

for i in data[0]:
print(i)

fp.close()
 

What is the description of this JSON plugin?
What's it supposed to do?
I plugged it in now how do, I access it?

So, this below is a JSON file code of my 50s videos that I use in my online database for 60's videos. How would the plugin work with this below or do I need to change the format of this below a little?

[
{"Artist":"Everly Brothers","Title":"All I Have To Do Is Dream [Intro Clean] 97","Bpm":"97.0","Year":"1958"},
{"Artist":"The Platters","Title":"Smoke Gets In Your Eyes [Clean] [Single] 58","Bpm":"57.3","Year":"1958"},
{"Artist":"Chuck Berry","Title":"Johnny B. Goode [Neon Rad Redrum] [Intro Clean] 86","Bpm":"86.0","Year":"1958"},
{"Artist":"Little Richard","Title":"Long Tall Sally [Redrum] [Clean] [Extended] 98","Bpm":"98.0","Year":"1956"},
{"Artist":"Bobby Helms","Title":"Jingle Bell Rock [Neon Rad Redrum] [Intro Clean] 119","Bpm":"119.0","Year":"1957"},
{"Artist":"Frank Sinatra","Title":"Jingle Bells [Single] [HD] [Clean] [Christmas] 88","Bpm":"87.3","Year":"1957"},
{"Artist":"Jackie Wilson","Title":"Reet Petite (The Sweetest Girl In Town) (Mixmash 70's)","Bpm":"85.4","Year":"1957"},
{"Artist":"Mitch Miller","Title":"The River Kwai Colonel Bogey March [Single] - Clean 115","Bpm":"115.0","Year":"1958"},
{"Artist":"Little Richard","Title":"Good Golly Miss Molly [Redrum] [Clean] [Extended] 166","Bpm":"166.0","Year":"1958"},
{"Artist":"Little Richard","Title":"Good Golly Miss Molly [Redrum] [Clean] [Extended] 166","Bpm":"166.0","Year":"1958"},
{"Artist":"Cliff Richard And The Young Ones Feat. Hank Marvin","Title":"Living Doll (Mixmash)","Bpm":"125.0","Year":"1959"},
{"Artist":"Brenda Lee","Title":"Rockin Around The Christmas Tree [Single] [HD] [Clean] [Christmas] 71","Bpm":"70.6","Year":"1958"},
{"Artist":"Pink","Title":"I Don't Believe You","Bpm":"93.0","Year":"1959"},
{"Artist":"Harry Belafonte","Title":"Matilda","Bpm":"99.6","Year":"1957"},
{"Artist":"Frank Sinatra","Title":"Talk To Me","Bpm":"92.1","Year":"1959"},
{"Artist":"Frank Sinatra","Title":"Angel Eyes","Bpm":"82.3","Year":"1958"},
{"Artist":"Frank Sinatra","Title":"High Hopes","Bpm":"138.8","Year":"1959"},
{"Artist":"Frank Sinatra","Title":"Day In, Day Out","Bpm":"96.3","Year":"1954"},
{"Artist":"Frank Sinatra","Title":"It Had To Be You","Bpm":"142.2","Year":"1957"},
{"Artist":"Bill Haley & His Comets","Title":"Rock Around The Clock [50s Redrum Video Edit] [DJ Dolls Video Edit]","Bpm":"88.5","Year":"1955"},
{"Artist":"Frank Sinatra","Title":"At Long Last Love","Bpm":"132.7","Year":"1957"},
{"Artist":"Harry Belafonte","Title":"Jamaica Farewell","Bpm":"124.9","Year":"1956"},
{"Artist":"Harry Belafonte","Title":"Island In The Sun","Bpm":"110.5","Year":"1957"},
{"Artist":"Frank Sinatra","Title":"Pennies From Heaven","Bpm":"111.2","Year":"1956"},
{"Artist":"Frank Sinatra","Title":"Hello, Young Lovers","Bpm":"83.2","Year":"1955"},
{"Artist":"Buddy Holly","Title":"Peggy Sue (Screenplay)","Bpm":"150.3","Year":"1957"},
{"Artist":"Frank Sinatra","Title":"I Get A Kick Out Of You","Bpm":"89.8","Year":"1954"},
{"Artist":"Harry Belafonte","Title":"Turn The World Around","Bpm":"128.5","Year":"1959"},
{"Artist":"Eddie Cochran","Title":"C'mon Everybody (Mixmash)","Bpm":"86.8","Year":"1959"},
{"Artist":"Elvis Presley","Title":"Hound Dog [Intro] - Clean","Bpm":"84.0","Year":"1953"},
{"Artist":"Elvis Presley","Title":"Don't Be Cruel (Screenplay)","Bpm":"84.3","Year":"1956"},
{"Artist":"The Coasters","Title":"Yakety Yak [Intro Clean] 125","Bpm":"125.0","Year":"1958"},
{"Artist":"Dean Martin","Title":"Bye Bye Blackbird (Screenplay)","Bpm":"148.1","Year":"1950"},
{"Artist":"Harry Belafonte","Title":"Day O (The Banana Boat Song)","Bpm":"151.2","Year":"1957"},
{"Artist":"Fats Domino","Title":"I'm Walkin' (Bacca ReDrum) (Clean)","Bpm":"112.0","Year":"1950"},
{"Artist":"Frank Sinatra","Title":"Last Night When We Were Young","Bpm":"160.2","Year":"1955"},
{"Artist":"Elvis Presley","Title":"Love Me Tender (Live) (Promo Only)","Bpm":"123.2","Year":"1956"},
{"Artist":"Elvis Presley","Title":"Heartbreak Hotel [Intro Clean] 96","Bpm":"96.0","Year":"1956"},
{"Artist":"The Platters","Title":"The Great Pretender [Intro] - Clean","Bpm":"78.0","Year":"1955"},
{"Artist":"Muddy Waters","Title":"Hoochie Coochie Man [Intro Clean] 72","Bpm":"72.0","Year":"1954"},
{"Artist":"Danny And The Juniors","Title":"At The Hop (Atom E Edit) (Clean)","Bpm":"91.7","Year":"1950"},
{"Artist":"Jerry Lee Lewis","Title":"Great Balls Of Fire (XMiX Edit Video)","Bpm":"79.5","Year":"1957"},
{"Artist":"Buddy Holly","Title":"That'll Be The Day [Clean] [Extended] 126","Bpm":"126.0","Year":"1958"},
{"Artist":"The Everly Brothers","Title":"Bye Bye Love [Clean] [Extended] 86","Bpm":"86.0","Year":"1957"}
]





 

It is part of the Online Source plugins. It means that it enables you to "read" songs available on Internet (via a URL).
In most cases, Online Source plugins are developped to be used with a songs provider like Deezer, TIDAL, SoundCloud, ...
https://www.virtualdj.com/wiki/Plugins_SDKv8_OnlineSource.html

But here, this plugin enables you to customize your own URLs via a JSON file at the same level as the DLL. It's name is "LocalJSON.json" and it gives you the structure of the expected file (by default it is just a template).
You can rename the dll but your JSON file has to have the same name

In your case, you need to edit your json file first by adding "uniqueId" and "streamUrl" fields first.
"UniqueId" has to be an unique identifier. It can be an incremental number but it has to be converted into a string
Then you also need to modify the bpm and year fields. It has to be a numeric value and not a string.


LocalJSON.json (template)
[
{
"artist" : "artist1",
"bpm" : 0.0,
"comment" : "",
"coverUrl" : "https://url1a.jpg",
"genre" : "",
"isKaraoke" : false,
"isVideo" : false,
"key" : 0,
"label" : "",
"length" : 0.0,
"remix " : "",
"streamUrl" : "https://url1b.mp3",
"title" : "title1",
"uniqueId" : "1"
},
{
"artist" : "artist2",
"bpm" : 0.0,
"comment" : "",
"coverUrl" : "https://url2a.jpg",
"genre" : "",
"isKaraoke" : false,
"isVideo" : false,
"key" : 0,
"label" : "",
"length" : 0.0,
"remix " : "",
"streamUrl" : "https://url2b.mp3",
"title" : "title2",
"uniqueId" : "2"
}
]


 

Thank you DJCEL for showing me where to find that and explaining how it works. I appreciate you doing that! I sort of understand it, but not completely. There's no need to explain it anymore. I will come back and read your messages again until I figure it out. It's just new to me now. I know once I read your description and follow your instructions, that I will catch on.
 

You are welcome.
I forgot to tell that the search in the plugin will work on the JSON file (based on artist and title fields).
To reload/refresh the json file, you need to click on the "local database" subfolder again after clicking on another folder in the browser.

If you have some new ideas or comments, do not hesitate to share.
 

I just got back to dabbling with it. I just added one track online from the internet archive. I tried to edit the json file at first in my LirbreOffice Calc, but I wasn't able to figure out what format to save it in to get it correct.

I went and located the JSON file in the:
AppData\Local\VirtualDJ\Plugins64\OnlineSources

I then used my Notepad++ to add the one test link to the file and then I saved it. Now it streams online thru my Virtual DJ player.

[
{
"artist" : "artist1",
"bpm" : 0.0,
"comment" : "",
"coverUrl" : "https://archive.org/services/img/The_Orb_Remixes-11770/full/pct:500/0/default.jpg",
"genre" : "",
"isKaraoke" : false,
"isVideo" : false,
"key" : 0,
"label" : "",
"length" : 0.0,
"remix " : "",
"streamUrl" : "https://archive.org/download/The_Orb_Remixes-11770/The_Superfools_-_01_-_Little_Fluffy_Clouds_Plush_Mix.mp3",
"title" : "title1",
"uniqueId" : "1"
},
{
"artist" : "artist2",
"bpm" : 0.0,
"comment" : "",
"coverUrl" : "https://url2a.jpg",
"genre" : "",
"isKaraoke" : false,
"isVideo" : false,
"key" : 0,
"label" : "",
"length" : 0.0,
"remix " : "",
"streamUrl" : "https://url2b.mp3",
"title" : "title2",
"uniqueId" : "2"
}
]


I am glad I got it to work and I am glad you created this because it opened my eyes up for ideas on where and how to create plugins. Thank you!
 

One thing to also know is when you load the file on the deck, it saves the uniqueid in the virtualdj local database (xml) as the filename. So if you edit the json file, you may have a refresh issue if you use the same uniqueid. Just clean the virtualdj local database (xml) if so.
 

@djblitz1985 I spotted in your file a track by Pink called I Don't Believe You which is listed as being released in 1959, a full twenty years before she was born. The correct date is 2008.
 

djcel wrote :
Next step is there if you want to go deeper with the VirtualDJ sdk

https://www.virtualdj.com/forums/257735/VirtualDJ_Plugins/Online_Source_plugin.html


Thanks. I want to learn how to get into working on plugins and fix Virtual DJs drag and drop txt feature that was working in the past and now after a 2nd update, it no longer works. It's not related to this topic and it's in another thread. I appreciate you showing me that. Thanks.
 

groovindj wrote :
@djblitz1985 I spotted in your file a track by Pink called I Don't Believe You which is listed as being released in 1959, a full twenty years before she was born. The correct date is 2008.


April fools....LOL