File: import.js

package info (click to toggle)
gerbera 2.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,412 kB
  • sloc: cpp: 44,738; javascript: 13,430; xml: 5,730; ansic: 2,692; sh: 1,555; sql: 237; python: 191; makefile: 13
file content (129 lines) | stat: -rw-r--r-- 5,134 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*GRB*
  Gerbera - https://gerbera.io/

  import.js - this file is part of Gerbera.

  Copyright (C) 2018-2025 Gerbera Contributors

  Gerbera is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 2
  as published by the Free Software Foundation.

  Gerbera 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 Gerbera.  If not, see <http://www.gnu.org/licenses/>.

  $Id$
*/

function importItem(item, cont) {
    if (getPlaylistType(item.mimetype) === '') {
        var arr = item.mimetype.split('/');
        var mime = arr[0];

        // All virtual objects are references to objects in the
        // PC-Directory, so make sure to correctly set the reference ID!
        var obj = item;
        obj.refID = item.id;

        const upnpClass = item.upnpclass;
        var audioLayout = config['/import/scripting/virtual-layout/attribute::audio-layout'];
        if (!audioLayout) {
            audioLayout = 'Default';
        }
        switch (upnpClass) {
            case "object.item.audioItem":
            case "object.item.audioItem.musicTrack":
            case "object.item.audioItem.audioBook":
            case "object.item.audioItem.audioBroadcast":
                switch (audioLayout) {
                case 'Structured':
                    return addAudioStructured(obj, cont, object_script_path, grb_container_type_audio);
                    break;
                default:
                    return addAudio(obj, cont, object_script_path, grb_container_type_audio);
                    break;
                }
                break;
            case "object.item.videoItem":
            case "object.item.videoItem.movie":
                return addVideo(obj, cont, object_script_path, grb_container_type_video);
                break;
            case "object.item.videoItem.musicVideoClip":
            case "object.item.videoItem.videoBroadcast":
                return addTrailer(obj);
                break;
            case "object.item.imageItem":
            case "object.item.imageItem.photo":
                return addImage(obj, cont, object_script_path, grb_container_type_image);
                break;
            case "object.item.textItem":
            case "object.item.bookmarkItem":
            case "object.item.playlistItem":
                print2("Error", "Unable to handle upnp class '" + item.upnpclass + "' for " + obj.location);
                break;
            default:
                print2("Warning", "Unable to handle unknown upnp class '" + item.upnpclass + "' for " + obj.location);
                if (item.mimetype === 'application/ogg') {
                    mime = (item.theora === 1) ? 'video' : 'audio';
                }
                switch (mime) {
                    case "audio":
                        switch (audioLayout) {
                        case 'Structured':
                            return addAudioStructured(obj, cont, object_script_path, grb_container_type_audio);
                            break;
                        default:
                            return addAudio(obj, cont, object_script_path, grb_container_type_audio);
                            break;
                        }
                        break;
                    case "video":
                        return addVideo(obj, cont, object_script_path, grb_container_type_video);
                        break;
                    case "trailer":
                        return addTrailer(obj);
                        break;
                    case "image":
                        return addImage(obj, cont, object_script_path, grb_container_type_image);
                        break;
                    default:
                        print2("Error", "Unable to handle mime type '" + item.mimetype + "' for " + obj.location);
                        break;
                }
                break;
        }
    }
}

// doc-import-begin
function importAudio(obj, cont, rootPath, autoscanId, containerType) {
    return addAudio(obj, cont, rootPath, containerType);
}
function importAudioStructured(obj, cont, rootPath, autoscanId, containerType) {
    return addAudioStructured(obj, cont, rootPath, containerType);
}
function importVideo(obj, cont, rootPath, autoscanId, containerType) {
    return addVideo(obj, cont, rootPath, containerType);
}
function importImage(obj, cont, rootPath, autoscanId, containerType) {
    return addImage(obj, cont, rootPath, containerType);
}
function importOnlineItem(obj, cont, rootPath, autoscanId, containerType) {
    return addTrailer(obj);
}
// doc-import-end

// Global Variables
var orig;
var cont;
var object_ref_list;
// compatibility with older configurations
if (!cont || cont === undefined)
    cont = orig;
if (orig && orig !== undefined)
    object_ref_list = importItem(orig, cont);