[vlc-commits] rockbox_fm_presets.lua: big clean up
Pierre Ynard
git at videolan.org
Wed Oct 26 12:11:47 CEST 2016
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Wed Oct 26 11:58:49 2016 +0200| [5f3a29794485aab1516b902b6ffac46b936a1d8d] | committer: Pierre Ynard
rockbox_fm_presets.lua: big clean up
Remove debug output, add license, improve probing...
Ref. #17488
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5f3a29794485aab1516b902b6ffac46b936a1d8d
---
share/lua/playlist/rockbox_fm_presets.lua | 41 ++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/share/lua/playlist/rockbox_fm_presets.lua b/share/lua/playlist/rockbox_fm_presets.lua
index a780afe..ae841f9 100644
--- a/share/lua/playlist/rockbox_fm_presets.lua
+++ b/share/lua/playlist/rockbox_fm_presets.lua
@@ -1,27 +1,44 @@
+--[[
+ $Id$
+
+ Copyright © 2009, 2016 the VideoLAN team
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+--]]
+
-- Parser script from Rockbox FM radio presets
-- See http://www.rockbox.org/wiki/FmPresets
+local MRL_base = "v4l2c:///dev/radio0:tuner-frequency="
+
function probe()
- if not string.match( vlc.path, ".fmr$" ) then return false end
+ if not string.match( vlc.path, "%.[fF][mM][rR]$" ) then return false end
local line = vlc.peek(256)
- vlc.msg.err(line)
- local freq = tonumber(string.match( line, "(%d*):" ))
- if not freq then return false end
- return freq > 80000000 and freq < 110000000
+ local freq = tonumber(string.match( line, "^[^%d]?[^%d]?[^%d]?[^%d]?(%d+):" )) -- handle BOM
+ return freq and freq > 80000000 and freq < 110000000
end
function parse()
- vlc.msg.err("test")
local p = {}
while true do
- line = vlc.readline()
+ local line = vlc.readline()
if not line then break end
- vlc.msg.err(line)
- for freq, name in string.gmatch( line, "(%d*):(.*)" ) do
- vlc.msg.info(freq)
- table.insert( p, { path = "v4l2c:///dev/radio0:tuner-frequency="..freq, name = name } )
+ local freq, name = string.match( line, "(%d+):(.*)" )
+ if freq then
+ table.insert( p, { path = MRL_base..freq, name = name } )
end
end
-vlc.msg.err("test test")
return p
end
More information about the vlc-commits
mailing list