It always annoying when a commercial unexpectedly interrupts your relaxation and tries to sell you irrelevant products and services again and again every day. Hey, what happened? I want to listen my online radio without ads! With this extension (after configuration) the volume level is automatically set to 0 when an AD is recognized.

CONFIGURATION:
You have to configure which content is recognized as ad. My favorite radio station always sets the title of the ads as "ad|main http://adurl" or "Adcor - ad description" so the configuration in this case is easy! Everything which starts with "ad" is classified as blocked content. Maybe you have to change this simple pattern depending on your broadcasted content.

I hope you are familiar with regular expressions because the title pattern is a LUA regular expression. You can change the filter in the downloaded file at line 18. (Short LUA tutorial http://lua-users.org/wiki/PatternsTutorial)

5 years ago

16 comments

Comments

I rewrote the original script to instead stop and then start playing the stream which I found causes the ad to be skipped entirely. I only tested this with DI.fm, but I would imagine this works with others. Please reach out with any questions.

function descriptor()
return {
title = "Online Radio AD blocker",
author = "joe.meszaros@gmail.com",
version = 0.3,
shortdesc = 'AdBlock',
url = '',
description = "It always annoying when a commercial unexpectedly interrupts your relaxation and tries to sell you irrelevant products and services again and again every day. Hey, what happened? I want to listen my online radio without ads! With this extension (after configuration) the volume level is automatically set to 0 when an AD is recognized",
capabilities = {"input-listener"}
}
end

function get_now_playing(str)
local item = vlc.item or vlc.input.item()
if not item then
return ""
end
local metas = item:metas()
if metas["now_playing"] then
return metas["now_playing"]
else
return ""
end
end

I redesigned slightly the code of the addon:
It is currently not just "ad blocker" but more like "Ad Silencer"
It can be used not only to block (silence) ads but also to boost volume for news or some radio broadcast
It is easier configurable now: every user can add unlimited count of keywords ("adstring")
You can select preferred volume factor for each keyword ("ad_volumefactor" for particular "adstring") - just edit "set_settings()" function.

You can add the feature to the next version if you think it is worth. Cannot insert files, so the code is:

function descriptor()
return {
title = "Online Radio AD blocker/silencer - eXtended",
author = "joe.meszaros@gmail.com, me@serenissima.lt",
version = 1.0,
shortdesc = 'AdBlock eXtended',
url = '',
description = "It always annoying when a commercial unexpectedly interrupts your relaxation and tries to sell you irrelevant products and services again and again every day. Hey, what happened? I want to listen my online radio without ads! With this extension (after configuration) the volume level is automatically reduced to a desirable level when an AD is recognized",
capabilities = {"input-listener"}
}
end

if (curr_volume ~= required_volume) then
if smoth_vol_change then
if curr_volume > required_volume then
step = -vol_change_step
else
step = vol_change_step
end
for setvol = curr_volume, required_volume, step do
vlc.volume.set(setvol)
end
else
vlc.volume.set(required_volume)
end
end
end

function get_now_playing(str)
local item = vlc.item or vlc.input.item()
if not item then
return ""
end
local metas = item:metas()
if metas["now_playing"] then
return metas["now_playing"]
else
return ""
end
end

"smoth_vol_change" means if you need smooth volume change; but this works only with certain output plugins because of the output buffer size...
P.S.: maybe someone know some sort of "wait()" or "sleep()" function in Lua? I'm new to Lua and didn't find anything similar.

if (curr_volume ~= required_volume) then
if smoth_vol_change then
if curr_volume > required_volume then
step = -vol_change_step
else
step = vol_change_step
end
for setvol = curr_volume, required_volume, step do
vlc.volume.set(setvol)
end
else
vlc.volume.set(required_volume)
end
end
end

function get_now_playing(str)
local item = vlc.item or vlc.input.item()
if not item then
return ""
end
local metas = item:metas()
if metas["now_playing"] then
return metas["now_playing"]
else
return ""
end
end

Thank you I managed it meanwhile, which was in Ubuntu a bit more difficult : I had to make a new file and copy and paste the source there ...
But I didnt manage to tell the addon to block ADs ( its checked in the view tab )

You have to configure the extension to block your radio station's ads. This configuration varies from station to station. Please be vigilant and catch the title of the ads and post it to me and I will help you to configure the extension.

if two ads are played consecutively, then volume_level is set to 0. To fix this, you can add an "if" like this:
if block then
vlc.msg.info("Found AD, set volume level to 0")
if not prev then
volume_level = vlc.volume.get()
end
vlc.volume.set(0)

I also have an updated block for di.fm:
block = string.find(t,"Choose premium.*") or string.find(t,"DI - Energizing") or string.find(t,"Digitally Imported.*TAG") or string.find(t, 'More of the show after these messages') or string.find(t, 'Get Digitally Imported Premium') or string.find(t, 'webex') or string.find(t, 'di.fm/premium') or string.find(t, "There's more to Digitally Imported!") or string.find(t, 'PhotonVPS.com')

* for di.fm, I used a block like this one:
block = string.find(t,"Digitally Imported.*TAG") or string.find(t, 'More of the show after these messages') or string.find(t, 'Get Digitally Imported Premium') or string.find(t, 'webex') or string.find(t, 'di.fm/premium') or string.find(t, "There's more to Digitally Imported!") or string.find(t, 'PhotonVPS.com')
the list was taken from here
http://code.google.com/p/quodlibet/source/browse/plugins/events/radioadmute.py?spec=svn0d807ac2a1f919f1e008e0639b1d0ea530504a98&r=0d807ac2a1f919f1e008e0639b1d0ea530504a98