From: Rémi Duraffort Date: Sun, 22 Aug 2010 07:09:57 +0000 (+0200) Subject: appletrailer: sort the elements of the playlist. X-Git-Tag: 1.2.0-pre1~5372 X-Git-Url: https://git.sesse.net/?p=vlc;a=commitdiff_plain;h=e0b2c38dc2563c08c1746a69b78f5694562fbb74 appletrailer: sort the elements of the playlist. --- diff --git a/share/lua/playlist/appletrailers.lua b/share/lua/playlist/appletrailers.lua index ad6437fd95..434300f830 100644 --- a/share/lua/playlist/appletrailers.lua +++ b/share/lua/playlist/appletrailers.lua @@ -3,7 +3,7 @@ movie URL $Id$ - Copyright © 2007 the VideoLAN team + Copyright © 2007-2010 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 @@ -31,6 +31,27 @@ function find( haystack, needle ) return r end +function sort(a, b) + if(a == nil) then return false end + if(b == nil) then return false end + + local str_a + local str_b + + if(string.find(a.name, '%(') == 1) then + str_a = tonumber(string.sub(a.name, 2, string.find(a.name, 'p') - 1)) + str_b = tonumber(string.sub(b.name, 2, string.find(b.name, 'p') - 1)) + else + str_a = string.sub(a.name, 1, string.find(a.name, '%(') - 2) + str_b = string.sub(b.name, 1, string.find(b.name, '%(') - 2) + if(str_a == str_b) then + str_a = tonumber(string.sub(a.name, string.len(str_a) + 3, string.find(a.name, 'p', string.len(str_a) + 3) - 1)) + str_b = tonumber(string.sub(b.name, string.len(str_b) + 3, string.find(b.name, 'p', string.len(str_b) + 3) - 1)) + end + end + if(str_a > str_b) then return false else return true end +end + -- Parse function. function parse() local playlist = {} @@ -43,7 +64,7 @@ function parse() if not line then break end if string.match( line, "class=\".-first" ) then - description = find( line, "h%d.->(.-)(.-)