Go Back   MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 20, 2012, 04:32 PM   #1
ctferrara
macrumors newbie
 
Join Date: Nov 2008
Mute Spotify Ads Automatically [App]

Hey guys,

I was messing around last night with some of the applescript capabilities for Spotify and was able to come up with a nice little solution for automatically detecting and muting ads in the free version of Spotify. I think I was able to write it in the most efficient way where it's not polling Spotify every second, only when it needs to. Let me know what you think.


Here's the applescript code:
Code:
repeat
	tell application "Spotify"
		set cur_vol to sound volume
		set trackk to track number of current track
		set namme to name of current track
		set pop to popularity of current track
		set dur to duration of current track
		set pos to player position
	end tell
	
	if pop is 0 and dur is less than 31 then
		tell application "Spotify"
			pause
			set sound volume to 0
			play
		end tell
		delay dur - pos + 1
		tell application "Spotify"
			set sound volume to cur_vol
		end tell
	else
		if dur - pos is less than 30 then
			delay dur - pos
		else
			delay 30
		end if
	end if
	
end repeat

Here's a link to github GitHub

Last edited by ctferrara; Dec 6, 2012 at 03:17 PM.
ctferrara is offline   0 Reply With Quote
Old Oct 13, 2012, 03:00 AM   #2
Mephistopelus
macrumors newbie
 
Join Date: Oct 2012
Hi! The link seems to be broken. Would you please upload your app again?
Mephistopelus is offline   0 Reply With Quote
Old Oct 13, 2012, 04:16 PM   #3
br3nt
macrumors member
 
Join Date: Jul 2012
Quote:
Originally Posted by Mephistopelus View Post
Hi! The link seems to be broken. Would you please upload your app again?
you can just the code to apple script editor and run it
I don't know how to keep it running in the background though. Make it an app and add it to start up list?


Did a dry run, caught 2 commercials in a row and then setting the volume to previous level.
Nice work!

Last edited by br3nt; Oct 13, 2012 at 04:27 PM.
br3nt is offline   0 Reply With Quote
Old Oct 13, 2012, 04:27 PM   #4
1member1
macrumors 6502
 
Join Date: Sep 2012
No offense but I think spotify should be with ads unless you paid. this is not so bad. I listen to spotify a lot (free version) and i appriciate their free service.

I think you can find better things to do with scripting.
1member1 is offline   1 Reply With Quote
Old Oct 14, 2012, 06:43 AM   #5
br3nt
macrumors member
 
Join Date: Jul 2012
Quote:
Originally Posted by 1member1 View Post
No offense but I think spotify should be with ads unless you paid. this is not so bad. I listen to spotify a lot (free version) and i appriciate their free service.

I think you can find better things to do with scripting.
you know they still get paid for the ads right?
it's like you walking out of the area when the commercials start and get back when the song is there... you're not removing anything/altering the client
br3nt is offline   3 Reply With Quote
Old Oct 14, 2012, 12:25 PM   #6
Mephistopelus
macrumors newbie
 
Join Date: Oct 2012
Thanks so much!
I've changed it a little bit, and posted to the GitHub. Here.

Last edited by Mephistopelus; Oct 16, 2012 at 01:52 AM.
Mephistopelus is offline   0 Reply With Quote
Old Oct 14, 2012, 03:22 PM   #7
br3nt
macrumors member
 
Join Date: Jul 2012
Quote:
Originally Posted by Mephistopelus View Post
Thanks so much!
I've changed it a little bit posted to the GitHub. Here.
any changelog except making it an app and raising the duration to 40s?
br3nt is offline   0 Reply With Quote
Old Oct 15, 2012, 01:48 AM   #8
Mephistopelus
macrumors newbie
 
Join Date: Oct 2012
Quote:
Originally Posted by br3nt View Post
any changelog except making it an app and raising the duration to 40s?
I've commented the script, so you can read it all yourself now

In short:
  1. Added error handling
  2. Now it runs every 0.5 seconds instead of 5+ seconds
  3. Deleted the automatic delay in the latest "else". It misses an ad if you skip the song before it.
Mephistopelus is offline   0 Reply With Quote
Old Oct 15, 2012, 03:43 PM   #9
br3nt
macrumors member
 
Join Date: Jul 2012
Quote:
Originally Posted by Mephistopelus View Post
I've commented the script, so you can read it all yourself now

In short:
  1. Added error handling
  2. Now it runs every 0.5 seconds instead of 5+ seconds
  3. Deleted the automatic delay in the latest "else". It misses an ad if you skip the song before it.
thanks for the reply!
br3nt is offline   0 Reply With Quote
Old Oct 15, 2012, 04:00 PM   #10
Mephistopelus
macrumors newbie
 
Join Date: Oct 2012
Quote:
Originally Posted by br3nt View Post
thanks for the reply!
You're very welcome!
Mephistopelus is offline   0 Reply With Quote
Old Dec 6, 2012, 12:22 AM   #11
ctferrara
Thread Starter
macrumors newbie
 
Join Date: Nov 2008
Update

Hey guys,

Just noticed that this has gotten some attention after uploading it and never giving it a second though. Just a few things;

1) The link should work again now. I had it saved in my dropbox public folder and had removed it (thinking nobody would ever download it). I have replaced it with an updated version.


I really do suggest using Mephistopelus's version though. He got it to run invisibly somthing I had not known how to do before. That and making the startup item prompt were great. Link here. Just consider my ideas below. Thanks



2) Updated Version: Just changes a few things.
a) If you quit Spotify the app Spotimute will now quit once it realizes Spotify is closed. You don't want it running all the time using resources and clogging your dock.
b) Option to have a growl notification show reminding you if you have the music paused for more than 1.5 minutes. I find this useful when you pause for a second to talk to someone or watch a quick video but forget to resume the music.

You can change both of these functions if you want by dragging the app into AppleScript Editor and changing the first two lines:

Code:
set always_on to true
set use_growl to true
ex. set always_on to true if you want to use it as a startup item and have it never quit.
ex2. set always_on to false if you want to use it like I do. I use Keyboard Maestro to automatically open Spotimute when Spotify opens. Then when I quit Spotify, Spotimute quits too. This way it's not always open sucking up resources.
ex3. Set use_growl true/false to choose whether or not to display growl notifications when musics been paused for a while.
c) Thanks @Mephistopelus for updating it and commenting but just a few issues..
1. Changing my name? Comon man...
2. Same thing with the icon...
3. (This one's real haha) There was no need to change the pause time in the repeat loop to .3 seconds. I wrote it the original very carefully in order to avoid having it run every second..

By reading the current position in the track we can figure out how long until we test again. Granted, this could pose a problem if we tested at the start of the song and then left it alone. What if we changed the song!! Well I set it up so that if there is more than 30 seconds left in a song it just runs though again.

In short: If theres more than 30 seconds in the song left it should wait 30 more seconds to test again. If it's less than 30 seconds it waits the remaining time, checks if it's an ad, then reacts to it.

By doing so we never hear ads and we arn't looping through the AppleScript literally 200 times a minute, but more like 4 times a minute. No need for that.
If you guys have any questions, comments, or requests let me know. I'm going to subscribe to this post now (don't know why I didnt beore) so I'll get them.


Thanks again for all your support.

ps. Hilarious story about how I remembered this app. While I use the app everyday I had completely forgotten I posted it here. Well, tonight me and my buddy were watching a movie that involves hackers (Die Hard 4) and he makes a quip about him being a hacker himself, as he recently downloaded a script that mutes Spotify on ads. Low and behold, he had download my app this morning, without even knowing I made it. Small world right..
__________________
iPhone 4 - 8GB
2007 White Macbook - 3GB RAM - 120 SSD

Last edited by ctferrara; Dec 6, 2012 at 03:20 PM.
ctferrara is offline   0 Reply With Quote
Old Feb 18, 2014, 08:22 PM   #12
toronado455
macrumors regular
 
Join Date: Apr 2009
Quote:
Originally Posted by ctferrara View Post
Hey guys,

Just noticed that this has gotten some attention after uploading it and never giving it a second though. Just a few things;

1) The link should work again now. I had it saved in my dropbox public folder and had removed it (thinking nobody would ever download it). I have replaced it with an updated version.


I really do suggest using Mephistopelus's version though. He got it to run invisibly somthing I had not known how to do before. That and making the startup item prompt were great. Link here. Just consider my ideas below. Thanks



2) Updated Version: Just changes a few things.
a) If you quit Spotify the app Spotimute will now quit once it realizes Spotify is closed. You don't want it running all the time using resources and clogging your dock.
Just to clarify... is the Mephistopelus version the one that is now a native OS X app "Spotifree", or is this something different?

Did this start out as an AppleScript and was changed into an app?

Also, I'm confused because you mention a "Spotimute", what is that?
toronado455 is offline   0 Reply With Quote
Old Feb 18, 2014, 08:27 PM   #13
ctferrara
Thread Starter
macrumors newbie
 
Join Date: Nov 2008
Quote:
Originally Posted by toronado455 View Post
Just to clarify... is the Mephistopelus version the one that is now a native OS X app "Spotifree"? Did this start out as an AppleScript and was changed into an app? Also, I'm confused because you mention a "Spotimute", what is that?
I only mention Spotimute because that is what I originally named it when I posted the app. Because the link to the app went dead but the code posted stayed on this page Mephistopelus was able to repackage it into an app. He never was able to download the original app so he never knew the original name, thus making up his own.


To the best of my knowledge the timeline is as follows:
  1. I created the inital applescript and shared it here
  2. I forgot that I posted it and never replied to any comments for a while
  3. Mephistopelus copied my code, changed a few variables and packaged it up and called it Spotifree
  4. Mephistopelus improved upon code and code website, eventually turning it its own native app.
__________________
iPhone 4 - 8GB
2007 White Macbook - 3GB RAM - 120 SSD
ctferrara is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Tags
applescript, spotify

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone: Tweak to mute when unlocked and mute when locked Grolubao Jailbreaks and iOS Hacks 5 Feb 5, 2014 08:53 AM
iPhone: Spotify or Apples music app? NickyLanzz iOS 7 6 Oct 19, 2013 06:45 AM
Spotify Announces AirPlay-Like 'Spotify Connect' for Wireless Audio Streaming MacRumors iOS Blog Discussion 36 Sep 26, 2013 08:21 AM
Cannot Empty Trash with Spotify App File SteinMaster Mac Applications and Mac App Store 12 Jan 11, 2013 07:11 PM
Music Control App for itunes + spotify irfan22 Mac Basics and Help 3 Aug 29, 2012 11:11 PM

Forum Jump

All times are GMT -5. The time now is 07:15 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC