Online Radio AD Blocker
VLC Extensions
Score 56%
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.

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)

INSTALLATION:
- click on the download button below
- save the file and extract "online_radio_adblocker.lua"
- create a directory "extensions" at this location and put the file "online_radio_adblocker.lua" inside:
* Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\
* Windows (current user): %APPDATA%\vlc\lua\extensions\
* Linux (all users): /usr/lib/vlc/lua/extensions/
* Linux (current user): ~/.local/share/vlc/lua/extensions/
* Mac OS X (all users): /Applications/VLC.app/Contents/MacOS/share/lua/extensions/
* Mac OS X (current user): /Users/%your_name%/Library/Application Support/org.videolan.vlc/lua/extensions/

To start the extension click on View > Online radio AD blocker.

Any comments, idea would be highly appreciated.

You can find the project on github as well : https://github.com/joemeszaros/vlc-ad-blocker.

Last changelog:

4 years ago

version 0.2:
-fix : if two ads are played consecutively, then volume_level is set to 0

OneBadV8

2 years ago

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 meta_changed()
vlc.msg.info("... meta_changed ...")
t = get_now_playing()
vlc.msg.info("Now playing:")
vlc.msg.info(t)
prev = block
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') or string.find(t, 'DI.fm')
if block then
vlc.msg.info("Found AD, stop")
vlc.playlist.stop()
vlc.msg.info("Go to first track in playlist")
vlc.playlist.goto(1)
vlc.msg.info("Replay stream to skip ad")
vlc.playlist.play()
end
end

function activate()
end

function deactivate()
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

Report

legendinis

3 years ago

Hello dear Joe Meszaros,

Thank you for great addon! It is very handy!

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

function set_settings()
ad_array = {}
ad_volumefactor = {}

smoth_vol_change = true
vol_change_step = 1

adstring = 1
ad_array[adstring] = "AD"
ad_volumefactor[adstring] = 1/3

adstring = 2
ad_array[adstring] = "SALE"
ad_volumefactor[adstring] = 0.5

adstring = 3
ad_array[adstring] = "NEWS"
ad_volumefactor[adstring] = 1.2
end

function meta_changed()
now_playing = get_now_playing()
vlc.msg.info('Now playing: '..now_playing)

curr_volume = vlc.volume.get()
if not ad_found then
normal_volume = vlc.volume.get()
end

for vol_key,ad_value in pairs(ad_array) do
if string.find(now_playing, ad_value) then
required_volume = round(normal_volume * ad_volumefactor[vol_key], 0)
ad_found = true
break
end
required_volume = normal_volume
ad_found = false
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 activate()
ad_found = false
normal_volume = vlc.volume.get()
set_settings()
end

function deactivate()
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

function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end


Usage:
Modify "set_settings()" function to meet your requirements:
If you need more ad-strings - just copy all 3 lines beginning with "adstring = n" (where n=1,2,3,...) and assign n successive bigger number;
Assign preferred "ad_volumefactor" for the configured "adstring": 1/2 (or 0.5) means the half as loud as normal (e.g. 50%); 1.2 means 20% louder than normal and so on.

"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.

P.P.S.: sorry for so big comment.. :]

Report

legendinis

3 years ago

Sorry, because mixed "Tab" and "Space" indents in the code - source becomes completely non-understandable. Try to solve that:

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

function set_settings()
ad_array = {}
ad_volumefactor = {}

smoth_vol_change = true
vol_change_step = 1

adstring = 1
ad_array[adstring] = "AD"
ad_volumefactor[adstring] = 1/3

adstring = 2
ad_array[adstring] = "SALE"
ad_volumefactor[adstring] = 0.5

adstring = 3
ad_array[adstring] = "NEWS"
ad_volumefactor[adstring] = 1.2
end

function meta_changed()
now_playing = get_now_playing()
vlc.msg.info('Now playing: '..now_playing)

curr_volume = vlc.volume.get()
if not ad_found then
normal_volume = vlc.volume.get()
end

for vol_key,ad_value in pairs(ad_array) do
if string.find(now_playing, ad_value) then
required_volume = round(normal_volume * ad_volumefactor[vol_key], 0)
ad_found = true
break
end
required_volume = normal_volume
ad_found = false
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 activate()
ad_found = false
normal_volume = vlc.volume.get()
set_settings()
end

function deactivate()
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

function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end

Report

Breity

4 years ago

I wasn't even able to download, when I pressed the download-Button a text page appeared which seems to be the sourcecode of the site

Report

C

joemeszaros

4 years ago

It is the source code of the extension not the site. Please click on 'File/Save as' in the menu when you see the this source code. Thus you can download the file and save it to the right place.

If you have further problems feel free to ask again :-)

Report

Breity

4 years ago

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 )

Report

C

joemeszaros

4 years ago

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.

Report

Breity

4 years ago

Here are some of the ADs:

Choose premium for the best audio experience - Soulful House - DIGITALLY IMPORTED - house music selected from Paris with love!

There's more to Digitally Imported! - Soulful House - DIGITALLY IMPORTED - house music selected from Paris with love!

Digitally Imported TSTAG_60 ADWTAG - Soulful House - DIGITALLY IMPORTED - house music selected from Paris with love!

Report

arnongold

4 years ago

was not listed in menu View
ubuntu 13.10
vlc new 2.0.6
cannt post output of vlc -vvv it's too long

Report

C

joemeszaros

4 years ago

Where did you save the file? If it's a mysterious
phenomenon I will install a fresh Ubuntu 13.10 VM.

Report

arnongold

4 years ago

if U send me an E-Mail I'll send U the output of vlc -vvv

Report

honkerdown

4 years ago

Just a comment to confirm that this extension does appear to be working fine with VLC 2.1 on Windows 7.

Report

zipzipsaib

4 years ago

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')

have fun!

Report

C

joemeszaros

4 years ago

zipzipsaib, thanks for the comments and the bug report. Now everybody can download the updated file with the bug fix.

Report

honkerdown

4 years ago

Thanks for the update. I just made the recommended change late yesterday and was testing it this morning. Seems to work well for me.

Report

zipzipsaib

4 years ago

nice addon, but wasn't easy to make it work for a beginner.

* when I saved the file, some xml markup was added by my browser, so you want to check the content of the file and make sure nothing is appended.

* to get the %APPDATA% folder, you can press start, type cmd, type: echo %APPDATA%

* vlc 2.0.8 complained about missing descriptor() function, I added to the beginning of the script:
function descriptor()
return {
title = "AdBlock",
version = "0.1",
author = "joemeszaros",
url = 'hello',
shortdesc = "AdBlock";
}
end

* 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

Report

4 years ago

version 0.2:
-fix : if two ads are played consecutively, then volume_level is set to 0

File (click to download) Version Description Filetype Packagetype License Downloads Date Filesize OCS-Install DL
Details
version
updated Aug 13 2015
added Sep 02 2013
downloads today
0
page views today 12