~vanvugt/ubuntu/oneiric/mediatomb/fix-770964-784431

« back to all changes in this revision

Viewing changes to scripts/js/playlists.js

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2009-04-22 21:39:19 UTC
  • mto: (4.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090422213919-52m015y6gcpv1m1g
Tags: upstream-0.12.0~svn2018
ImportĀ upstreamĀ versionĀ 0.12.0~svn2018

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    
12
12
    playlists.js - this file is part of MediaTomb.
13
13
    
14
 
    Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
 
14
    Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
15
15
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
16
16
                            Leonhard Wimmer <leo@mediatomb.cc>
17
17
    
23
23
    but WITHOUT ANY WARRANTY; without even the implied warranty of
24
24
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25
25
    
26
 
    $Id: playlists.js 1698 2008-02-23 20:48:30Z lww $
 
26
    $Id: playlists.js 2010 2009-01-11 19:10:43Z lww $
27
27
*/
28
28
 
29
29
var playlistOrder = 1;
72
72
var type = getPlaylistType(playlist.mimetype);
73
73
 
74
74
// the function createContainerChain is defined in common.js
75
 
var playlistChain = createContainerChain(new Array('Playlists', playlist.title));
 
75
var playlist_title = playlist.title
 
76
var dot_index = playlist_title.lastIndexOf('.');
 
77
if (dot_index > 1)
 
78
        playlist_title = playlist_title.substring(0, dot_index);
 
79
 
 
80
var playlistChain = createContainerChain(new Array('Playlists', 'All Playlists', playlist_title));
 
81
 
 
82
var playlistDirChain;
 
83
 
 
84
var last_path = getLastPath(playlist.location);
 
85
if (last_path)
 
86
    playlistDirChain = createContainerChain(new Array('Playlists', 'Directories', last_path, playlist_title));
76
87
 
77
88
if (type == '')
78
89
{
84
95
    var line = readln();
85
96
    do
86
97
    {
87
 
        if (line.match(/^#EXTINF:(\d+),(\S.+)$/i))
 
98
        if (line.match(/^#EXTINF:(-?\d+),(\S.+)$/i))
88
99
        {
89
100
            // duration = RegExp.$1; // currently unused
90
101
            title = RegExp.$2;
92
103
        else if (! line.match(/^(#|\s*$)/))
93
104
        {
94
105
            addPlaylistItem(line, title, playlistChain);
 
106
            if (playlistDirChain)
 
107
                addPlaylistItem(line, title, playlistDirChain);
 
108
 
95
109
            title = null;
96
110
        }
97
111
        
129
143
            if (lastId != id)
130
144
            {
131
145
                if (file)
 
146
                {
132
147
                    addPlaylistItem(file, title, playlistChain, lastId);
 
148
                    if (playlistDirChain)
 
149
                        addPlaylistItem(file, title, playlistDirChain, lastId);
 
150
                }
 
151
 
133
152
                title = null;
134
153
                lastId = id;
135
154
            }
144
163
            if (lastId != id)
145
164
            {
146
165
                if (file)
 
166
                {
147
167
                    addPlaylistItem(file, title, playlistChain, lastId);
 
168
                    if (playlistDirChain)
 
169
                        addPlaylistItem(file, title, playlistDirChain, lastId);
 
170
                }
 
171
 
148
172
                file = null;
149
173
                lastId = id;
150
174
            }
160
184
    while (line);
161
185
    
162
186
    if (file)
 
187
    {
163
188
        addPlaylistItem(file, title, playlistChain, lastId);
 
189
        if (playlistDirChain)
 
190
            addPlaylistItem(file, title, playlistDirChain, lastId);
 
191
    }
164
192
}