[vlc-commits] cue.lua: remove tabs
Ludovic Fauvet
git at videolan.org
Wed Aug 28 17:55:31 CEST 2013
vlc | branch: master | Ludovic Fauvet <etix at videolan.org> | Wed Aug 28 17:40:35 2013 +0200| [43567b83e36b3facbb2fc31e2a75de2f631b212b] | committer: Ludovic Fauvet
cue.lua: remove tabs
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=43567b83e36b3facbb2fc31e2a75de2f631b212b
---
share/lua/playlist/cue.lua | 162 ++++++++++++++++++++++----------------------
1 file changed, 81 insertions(+), 81 deletions(-)
diff --git a/share/lua/playlist/cue.lua b/share/lua/playlist/cue.lua
index 7854b9e..dbfd83c 100644
--- a/share/lua/playlist/cue.lua
+++ b/share/lua/playlist/cue.lua
@@ -21,13 +21,13 @@
-- Probe function.
function probe()
- if( not string.match( string.upper( vlc.path ), ".CUE$" ) ) then
- return false
- end
- header = vlc.peek( 2048 )
- return string.match( header, "FILE.*WAVE%s*[\r\n]+" ) or
- string.match( header, "FILE.*AIFF%s*[\r\n]+" ) or
- string.match( header, "FILE.*MP3%s*[\r\n]+" )
+ if( not string.match( string.upper( vlc.path ), ".CUE$" ) ) then
+ return false
+ end
+ header = vlc.peek( 2048 )
+ return string.match( header, "FILE.*WAVE%s*[\r\n]+" ) or
+ string.match( header, "FILE.*AIFF%s*[\r\n]+" ) or
+ string.match( header, "FILE.*MP3%s*[\r\n]+" )
end
-- Helpers
@@ -36,106 +36,106 @@ function is_utf8( src )
end
function cue_string( src )
- if not is_utf8( src ) then
- -- Convert to UTF-8 since it's probably Latin1
- src = vlc.strings.from_charset( "ISO_8859-1", src )
- end
- local sub = string.match( src, "^\"(.*)\".*$" );
- if( sub ) then
- return sub
- end
- return string.match( src, "^(%S+).*$" )
+ if not is_utf8( src ) then
+ -- Convert to UTF-8 since it's probably Latin1
+ src = vlc.strings.from_charset( "ISO_8859-1", src )
+ end
+ local sub = string.match( src, "^\"(.*)\".*$" );
+ if( sub ) then
+ return sub
+ end
+ return string.match( src, "^(%S+).*$" )
end
function cue_path( src )
- if( string.match( src, "^/" ) or
- string.match( src, "^\\" ) or
- string.match( src, "^[%l%u]:\\" ) ) then
- return vlc.strings.make_uri(src)
- end
+ if( string.match( src, "^/" ) or
+ string.match( src, "^\\" ) or
+ string.match( src, "^[%l%u]:\\" ) ) then
+ return vlc.strings.make_uri(src)
+ end
- local slash = string.find( string.reverse( vlc.path ), '/' )
+ local slash = string.find( string.reverse( vlc.path ), '/' )
local prefix = vlc.access .. "://" .. string.sub( vlc.path, 1, -slash )
-- FIXME: postfix may not be encoded correctly (esp. slashes)
local postfix = vlc.strings.encode_uri_component(src)
- return prefix .. postfix
+ return prefix .. postfix
end
function cue_track( global, track )
- if( track.index01 == nil ) then
- return nil
- end
-
- t = {}
- t.path = cue_path( track.file or global.file )
- t.title = track.title
- t.album = global.title
- t.artist = track.performer or global.performer
- t.genre = track.genre or global.genre
- t.date = track.date or global.date
- t.description = global.comment
- t.tracknum = track.num
- t.options = { ":start-time=" .. math.floor(track.index01) }
-
- return t
+ if( track.index01 == nil ) then
+ return nil
+ end
+
+ t = {}
+ t.path = cue_path( track.file or global.file )
+ t.title = track.title
+ t.album = global.title
+ t.artist = track.performer or global.performer
+ t.genre = track.genre or global.genre
+ t.date = track.date or global.date
+ t.description = global.comment
+ t.tracknum = track.num
+ t.options = { ":start-time=" .. math.floor(track.index01) }
+
+ return t
end
function cue_append( tracks, global, track )
- local t = cue_track( global, track )
- if( t ~= nil ) then
- if( #tracks > 0 ) then
- local prev = tracks[#tracks]
- table.insert( prev.options, ":stop-time=" .. math.floor(track.index01) )
- end
- table.insert( tracks, t )
- end
+ local t = cue_track( global, track )
+ if( t ~= nil ) then
+ if( #tracks > 0 ) then
+ local prev = tracks[#tracks]
+ table.insert( prev.options, ":stop-time=" .. math.floor(track.index01) )
+ end
+ table.insert( tracks, t )
+ end
end
-- Parse function.
function parse()
p = {}
- global_data = nil
- data = {}
- file = nil
+ global_data = nil
+ data = {}
+ file = nil
while true
do
line = vlc.readline()
if not line then break end
- cmd, arg = string.match( line, "^%s*(%S+)%s*(.*)$" )
-
- if( cmd == "REM" and arg ) then
- subcmd, value = string.match( arg, "^(%S+)%s*(.*)$" )
- if( subcmd == "GENRE" and value ) then
- data.genre = cue_string( value )
- elseif( subcmd == "DATE" and value ) then
- data.date = cue_string( value )
- elseif( subcmd == "COMMENT" and value ) then
- data.comment = cue_string( value )
- end
- elseif( cmd == "PERFORMER" and arg ) then
- data.performer = cue_string( arg )
- elseif( cmd == "TITLE" and arg ) then
- data.title = cue_string( arg )
- elseif( cmd == "FILE" ) then
- file = cue_string( arg )
- elseif( cmd == "TRACK" ) then
- if( not global_data ) then
- global_data = data
- else
- cue_append( p, global_data, data )
- end
- data = { file = file, num = string.match( arg, "^(%d+)" ) }
- elseif( cmd == "INDEX" ) then
- local idx, m, s, f = string.match( arg, "(%d+)%s+(%d+):(%d+):(%d+)" )
- if( idx == "01" and m ~= nil and s ~= nil and f ~= nil ) then
- data.index01 = m * 60 + s + f / 75
- end
- end
+ cmd, arg = string.match( line, "^%s*(%S+)%s*(.*)$" )
+
+ if( cmd == "REM" and arg ) then
+ subcmd, value = string.match( arg, "^(%S+)%s*(.*)$" )
+ if( subcmd == "GENRE" and value ) then
+ data.genre = cue_string( value )
+ elseif( subcmd == "DATE" and value ) then
+ data.date = cue_string( value )
+ elseif( subcmd == "COMMENT" and value ) then
+ data.comment = cue_string( value )
+ end
+ elseif( cmd == "PERFORMER" and arg ) then
+ data.performer = cue_string( arg )
+ elseif( cmd == "TITLE" and arg ) then
+ data.title = cue_string( arg )
+ elseif( cmd == "FILE" ) then
+ file = cue_string( arg )
+ elseif( cmd == "TRACK" ) then
+ if( not global_data ) then
+ global_data = data
+ else
+ cue_append( p, global_data, data )
+ end
+ data = { file = file, num = string.match( arg, "^(%d+)" ) }
+ elseif( cmd == "INDEX" ) then
+ local idx, m, s, f = string.match( arg, "(%d+)%s+(%d+):(%d+):(%d+)" )
+ if( idx == "01" and m ~= nil and s ~= nil and f ~= nil ) then
+ data.index01 = m * 60 + s + f / 75
+ end
+ end
end
- cue_append( p, global_data, data )
+ cue_append( p, global_data, data )
return p
end
More information about the vlc-commits
mailing list