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

« back to all changes in this revision

Viewing changes to scripts/js/import-dvd.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:
 
1
// Default MediaTomb dvd import script.
 
2
// see MediaTomb scripting documentation for more information
 
3
 
 
4
/*MT_F*
 
5
    
 
6
    MediaTomb - http://www.mediatomb.cc/
 
7
    
 
8
    import-dvd.js - this file is part of MediaTomb.
 
9
    
 
10
    Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
 
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
 
12
                            Leonhard Wimmer <leo@mediatomb.cc>
 
13
    
 
14
    This file is free software; the copyright owners give unlimited permission
 
15
    to copy and/or redistribute it; with or without modifications, as long as
 
16
    this notice is preserved.
 
17
    
 
18
    This file is distributed in the hope that it will be useful,
 
19
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
21
    
 
22
    $Id: import-dvd.js 2011 2009-01-11 19:14:54Z lww $
 
23
*/
 
24
 
 
25
var title = dvd.title;
 
26
var index = title.lastIndexOf('.');
 
27
if (index > 1)
 
28
    title = title.substring(0, index);
 
29
 
 
30
// we got the ISO here but our virtual items should have the video class
 
31
dvd.upnpclass = UPNP_CLASS_ITEM_VIDEO;
 
32
 
 
33
var title_count = dvd.aux[DVD].titles.length;
 
34
for (var t = 0; t < title_count; t++)
 
35
{
 
36
    var title_name = 'Title';
 
37
 
 
38
    if (t < 9)
 
39
        title_name = title_name + ' 0' + (t + 1);
 
40
    else
 
41
        title_name = title_name + ' ' + (t + 1);
 
42
 
 
43
    var chapter_count = dvd.aux[DVD].titles[t].chapters.length;
 
44
    var audio_track_count = dvd.aux[DVD].titles[t].audio_tracks.length;
 
45
    for (var a = 0; a < audio_track_count; a++)
 
46
    {
 
47
        var chain;
 
48
        var audio_name = ' - Audio Track ' + (a + 1);
 
49
        var audio_language = dvd.aux[DVD].titles[t].audio_tracks[a].language;
 
50
        var audio_format = dvd.aux[DVD].titles[t].audio_tracks[a].format;
 
51
        if (audio_format != '')
 
52
        {
 
53
            if (audio_language != '')
 
54
                audio_name = audio_name + ' - ' + audio_language;
 
55
 
 
56
            chain = new Array('Video', 'DVD', title, 'Audio Formats', 
 
57
                              audio_format, title_name + audio_name);
 
58
 
 
59
            for (var c = 0; c < chapter_count; c++) 
 
60
            {
 
61
                if (c < 9)
 
62
                    dvd.title = "Chapter 0" + (c + 1);
 
63
                else
 
64
                    dvd.title = "Chapter " + (c + 1);
 
65
 
 
66
                addDVDObject(dvd, t, c, a, createContainerChain(chain));
 
67
            } 
 
68
        }
 
69
 
 
70
        if (audio_language != '')
 
71
        {
 
72
            chain = new Array('Video', 'DVD', title, 'Languages', 
 
73
                              audio_language);
 
74
            if (audio_format != '')
 
75
                chain.push(title_name + audio_name + ' - ' + audio_format);
 
76
            else 
 
77
                chain.push(title_name + audio_name);
 
78
 
 
79
            for (var c = 0; c < chapter_count; c++)
 
80
            {
 
81
                if (c < 9)
 
82
                    dvd.title = "Chapter 0" + (c + 1);
 
83
                else
 
84
                    dvd.title = "Chapter " + (c + 1);
 
85
 
 
86
                addDVDObject(dvd, t, c, a, createContainerChain(chain));
 
87
            } 
 
88
        }
 
89
 
 
90
        chain = new Array('Video', 'DVD', title, 'Titles');
 
91
 
 
92
        var titles = title_name + ' - Audio Track ' + (a + 1);
 
93
 
 
94
        if (audio_format != '')
 
95
            titles = titles + ' - ' + audio_format;
 
96
 
 
97
        if (audio_language != '')
 
98
            titles = titles + ' - ' + audio_language;
 
99
 
 
100
        chain.push(titles);
 
101
        
 
102
        for (var c = 0; c < chapter_count; c++)
 
103
        {
 
104
            if (c < 9)
 
105
                dvd.title = "Chapter 0" + (c + 1);
 
106
            else
 
107
                dvd.title = "Chapter " + (c + 1);
 
108
 
 
109
            addDVDObject(dvd, t, c, a, createContainerChain(chain));
 
110
        } 
 
111
    }
 
112
}
 
113