The script was not written by me - it is a .vbs script for use in Foobar2000
https://gist.github.com/rornor/4d06d0994c1b8ae61ef5
The script queries the soundcloud.api and gets a list of songs based on a user or group. A dialogue pops up and asks for a username, search term, group, or URL, and it will load a group of songs into a temporary .pls file that it deletes after closing the player. I haven't much experience with .vbs so I can't give much information, but I can give the script here:
Screenshot of dialogue:
Click to enlarge
My question is
I would like it to build a related playlist like that the website does, so I choose one song and it loads the list of related songs into my Foobar Playlist. Is there a specific url I can load so it does that, or can I have it load from the API somewhere?
I've found an undocumented /related endpoint that can be used on a track object to get its "related" tracks
I'll be using this track as an example, which has an id of 107686148: https://soundcloud.com/maddecent/grandtheft-mobbin-feat
HTTP GET: https://api-v2.soundcloud.com/tracks/107686148/related?client_id={YOUR_CLIENT_ID}
The response from this api-v2 endpoint is an array of track objects which matche the related tracks shown in your web browser.
try this if you're working with WScript:
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run "soundcloud.com/tracks/00000/related?client_id=(your client id)"
that's a basic running mechanism in WScript but I'd like you to clarify a bit as I'm not sure what you mean by "loading songs into your playlist through vbscript".
Related
I want to be able to have a script which can detects if I have new messages in my messaging apps.. Slack, lync,.
Is it possible to use applescript to read if there is any active notification on the apps in the Dock..
If you do:
`getconf DARWIN_USER_DIR`/com.apple.notificationcenter/db
(which line I found at Ask Different), you'll get returned:
/var/folders/_d/pg2g_[some_funny_numbers]/0//com.apple.notificationcenter/db: is a directory
Inside this/my folder I found:
db db-shm db-wal db2upgraded
When some action happens (I sent a notification) only db-wal gets updated (nearly) at once.
So, in principle it should be possible to write an AS (saved as Stay Open app) that periodically looks if "db-wal" has changed (comparing saved sizes or change dates) and, ONLY if so, searches it for some keywords (Slack, lync,…) again comparing # of occurrences, thus learning if s.th. new has arrived. Admittedly sounds awkward but could work.
It would be much more elegant to use a folder script, but as no file is moved nor a folder opened/closed such a script can not be invoked.
I'm looking for API that would allow do these tasks
Search song in Apple Music
Create playlist
Add songs to playlist
Thanks in advance.
I'm afraid that what you are asking to do, is at the moment not possible since starting from iTunes 12.2 we can only search the local library and not the entire Apple Music from the API.
In the case you have the song that you want to play inside your library(local or cloud), you can search and play a song like this :
tell application "iTunes"
set results to (every track whose name contains "Cumuli" and artist is "883")
repeat with tune in results
play tune
end repeat
end tell
And then you can put the retrieved tune inside the playlist you want, or create a new one. Take a look at this post for an example.
Alright, so, I'm working on a script to execute some commands in an MMC Snapin, and I'm not very experienced with doing this kind of scripting, but i've made a lot of progress...the problem I am having, is if I create a new object every time the script runs, it will massively delay my overall script while the snapin and everything in it loads(which can take as long as five minutes). If it could load the snapin content once and then just take control of it as needed, and only create a new object IF there's not one open already, I'll save a massive amount of time when I run the script sometimes 100 times in a day.
The problem is, I'm not entirely certain how to achieve this. I thought, after some research, that it would be GetObject, but when I do
Dim objMMC
Set objMMC = GetObject("", "MMC20.Application")
It seems to create a new mmc window with no snapins loaded, rather than get the existing one with snapins loaded that I want.
Any advice? Am I just totally off base here, using completely the wrong command, or is there some simple change that I can make to fix this?
Edit:
Is there some weird workaround way I could achieve this, like storing an object to a temporary file so i can at least reuse it through a single session.
I'm in a weird situation where I am trying to add functionality to a powershell script and couldn't find a way to do it directly in powershell, so i'm setting up a vbscript to do one piece of it and calling the vbscript from powershell. I already had to do a lot of research to figure out how to do it in vbscript(and i'm still not sure about all of it) so i guess before i go any further, I'll try to figure out if this is even viable(in vbscript or c# or c++ or any other language someone could suggest)...
What i want to do, overall, is check if an MMC window is open that contains a DHCP snapin. If so, assign it to a variable. If not, create one.
Then it will read from a csv or txt file, and use the values to determine what node to navigate to within the snapin(DHCP>ServerName>IPv4>ScopeName>Scope Options).(I've mostly solved this part in vbscript, but don't know how to do it in C++ or C#)
Finally, I need to be able to execute a right-click menu item to "configure options", navigate the tabs of the popup that comes up, enter a value, and apply the changes/hit ok to close the popup. Worst case, If I can't do it "normally" by actually sending commands to the objects themselves, this part I can do with imitating keystrokes, but i don't want to do that if it's avoidable because it's sloppy.
Then, I basically will just need to somehow alert the powershell script that i'm "finished" so it can continue, or give an alert if there's an error.
I'm not asking anyone to walk me through all this, I just want to know if any of those steps aren't viable as i've described them, especially if I'm going to have to switch to c++ or c# to achieve the first part and therefore relearn the commands needed.
... and only create a new object IF there's not one open already ...
No, this is not possible in VBS, you need to do
Dim objMMC
Set objMMC = WScript.CreateObject("MMC20.Application")
if I create a new object every time the script runs, it will massively delay my overall script
In this case is the VBS the wrong language, you need to use C# or C++ executable.
I'm writing a sinatra app in ruby that gathers information about my network into two different files. The first, a .csv, gathers information on the IP Addresses and given names of all workstations in the network. The second, a .txt, reads into an Asterisk server and gathers information on active SIP channels linking to specified IP Addresses.
My app is merely compiling the information from these two files and creating tables on a webpage matching up users currently logged into specific stations. However, I want the app to feign realtime-use. I have the two files being automatically updated every 5 minutes, but as the files being read by the app are being overwritten, the app's output doesn't change. Is there a way to rig it so the app is reading the "new" files after they are written?
I've dug around on stack overflow, and I've seen things mentioning Kqueue for python users to simply watch for changes in those files before rewriting them, which would be really nice. Is there a ruby version for that? Additionally, I want the app to be accessible at all times, and maybe only "refresh" when it needs to update something, so that would make sense.
I also came to a funny little epiphany when I realized I'm never closing my files after I read them. I won't post the whole app, but here's where I read the files:
#Pulls active SIP channels from Asterisk
$sip = {}
File.open('sip.txt').each do |line|
userid,ip = line.split(" ")
$sip[ip] = userid[0..3]
end
#Prepares hash of all stations, ip addresses
$machines = {}
CSV.foreach('/Volumes/Scripts/report-51.csv') do |row|
name = row[1]
address = row[0]
$machines[name] = address
end
Is it possible that because I never close the files, the program never opens up the "new" documents? Just trying to brainstorm here.
It's hard to tell the overall structure of what's going on, but yeah, whatever code is being called every 5 minutes and which in turn does the file reading, I would make sure that the files are closed and reopened in that code with every call. That should solve your problem.
You may also consider switching to a database approach for more robust results.
Ok, I have tried to google this and keep running into things that are close, but not quite there. I mess with them for a few hours and can't bridge it across to what I need.
Requirements: Read a list of computer names and add them to specific OUs.
The list can be formated however, but right now I have it as a csv.
/////////
Comp1,Computers,cold,Alaska,mydomain,com,
Comp2,servers,New Jersey,test,temp,training,Room3,trainers,mydomain,com,
Comp3,computers,New Jersey,test,temp,training,Room3,students,restricted,mydomain,com
Comp4,computers,New Jersey,test,temp,training,Room3,students,power users,mydomain,com
////////
As you can see, the domains portion is not the same on all the machines.
I tried using a vbscript but all I would get is "unable to connect to LDap" so I was thinking about storing the lines in an array and using dsadd and building the command line from the variables in the array.
I already have the portion written to browse for the file, and dsquery, dsadd, etc are all on the server that this will be run from.
This is probably a lot easier than I am trying to make it, I tend to over complicate things if I don't finish it right away.
Look at this:
Automating the creation of computer accounts