Skip to content

Commit

Permalink
fix(gerbera): import.js didn't work in gerbera 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
masnagam committed Jan 13, 2024
1 parent d1de255 commit a2a29cd
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions gerbera/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,34 @@
// ID-prefix wraps around.
const KEEP_ID_PREFIX = false;

print(1);
// Log levels.
const LOG_LEVEL_OFF = 0;
const LOG_LEVEL_INFO = 1;
const LOG_LEVEL_WARN = 2;
const LOG_LEVEL_ERROR = 3;
const LOG_LEVEL_DEBUG = 4;

print(2);
// Current log level.
const LOG_LEVEL = LOG_LEVEL_OFF;


print(3);
// See https://github.com/svaarala/duktape/issues/253
Error.prototype.toString = function() {
return this.name + ': ' + this.message + ' (at line ' + this.lineNumber + ')';
};

if (getPlaylistType(orig.mimetype) === '') {
print(4);
function importItem(item, cont) {
print(9);
// All virtual objects are references to objects in the
// PC-Directory, so make sure to correctly set the reference ID!
var obj = orig;
obj.refID = orig.id;
var obj = item;
obj.refID = item.id;

print(10);
var title = obj.title.split('.', 2)[1];
if (KEEP_ID_PREFIX) {
title = obj.title;
Expand All @@ -33,6 +40,7 @@ if (getPlaylistType(orig.mimetype) === '') {
print('DEBUG: M_TITLE: ' + title);
}

print(11);
const date = computeStartTime(obj);
if (LOG_LEVEL >= LOG_LEVEL_DEBUG) {
print('DEBUG: M_DATE: ' + date);
Expand All @@ -54,7 +62,7 @@ if (getPlaylistType(orig.mimetype) === '') {
var container = addContainerTree([recorder]);
addCdsObject(obj, container);
if (LOG_LEVEL >= LOG_LEVEL_INFO) {
print('INFO: Imported: ' + orig.location);
print('INFO: Imported: ' + item.location);
}
}

Expand Down Expand Up @@ -89,3 +97,18 @@ function formatDigits(n) {
return '' + n;
}
}

print(5);
// Global Variables
var orig;
var cont;
print(6);
// compatibility with older configurations
if (!cont || cont === undefined) {
cont = orig;
}
print(7);
if (orig && orig !== undefined) {
print(8);
importItem(orig, cont);
}

0 comments on commit a2a29cd

Please sign in to comment.