// Ignore: '{"channel_groups":'
// a channel-definition begins with "display_alias": "
PosNext := PosEx('
"display_alias"', Data, 1);
// get begin of first channel
id := 0;
n := 0;
//Log('UPDCHL', 'LEN: ' + inttostr(length(data)));
while (PosNext > 0)
do
begin
//LOG('UPDCHL', '------------------------');
inc(PosNext, 1);
inc(n);
Application.ProcessMessages;
// --- Read all values in order of apperance:
// "display_alias" - NOZ USED // 1)
sha := GetBool(posnext, Data, '
"sharing": ');
// 2)
rad := GetBool(posnext, Data, '
"is_radio": ');
// 3)
tit := GetStr(PosNext, Data, '
"title": "', '
"');
// 4)
tit := DecodeJString(tit);
cid := GetStr(posnext, Data, '
"cid": "', '
"');
// 5)
//Log('UPDCHL', inttostr(PosNext) + ' | CID: ' + cid);
num := GetStr(PosNext, Data, '
"number": ','
,');
// 6)
//Log('UPDCHL', inttostr(PosNext) + ' | ZatNum: ' + num + ' | RecNum: ' + inttostr(n));
// Here: ... EPG-NEXT 7)
rec := GetBool(posnext, Data, '
"recording": ');
// 8)
// --- Check if Channel already exists:
x := GetChlbyCID(1, cid, ChlRec);
if (x < 0)
then
begin
// NOT FOUND !!! New ChlRec
New(ChlRec);
// create a new record:
id := FCHLList.Add(ChlRec);
//Log('UPDCHL', 'New ChlRec: '); // + inttostr(id +1) + ' - ' +booltostr(rad, true));
CHLrec.SortNum := -1;
CHLrec.QSelect := -1;
// no Quality-Rec selected
// ----- DYNAMIC-DATA -----
ChlRec.Qualy := TList.Create;
CHLrec.EPG := TList.Create;
end;
// else
// Log('UPDCHL', '********** CHL AVAILABLE: ' + booltostr(ChlRec.Is_Radio, true));
// --- Set values new:
ChlRec.Sharing := sha;
ChlRec.Is_Radio :=
rad;
StrLCopy(CHLrec.Title, PAnsiChar(tit), High(ChLrec.Title) - 1);
StrLCopy(CHLrec.CID, PAnsiChar(cid), High(CHLrec.CID) - 1);
ChlRec.Num := StrToInt(num);
ChlRec.Recording := rec;
// --- check CHANNEL-QUALITIES:
// Section "qualities" will / must be present
// we should have min. 1 (SD) , mostly 2 (HD+SD), more ?
// TRICKY: first read "recommendations" for max. loop-position !
posrem:= PosEx('
"recommendations"', Data, posnext);
// REMAIN "JUMP"
numQRec := -1;
// --- Clear QRecs if available:
for i := 1
to ChlRec.Qualy.Count
do
Dispose(PChlQualyRec(ChlRec.Qualy[i - 1]));
ChlRec.Qualy.Clear;
// --- Read QRecs new
s := GetStr(posnext, Data, '
"stream_types": [', '
],');
// get first qualy-data
while (PosNext > 0)
AND (PosRem > PosNext)
do
begin
inc(numQrec);
New(QRec);
// 10)
ChlRec.Qualy.Add(QRec);
FillChar(QRec^, sizeof(TChlQualyRec), 0);
// title - UNUSED HERE
QRec.stream_types := GetSTreamTypes(s);
QRec.level := 0;
// default undefined
s := GetStr(posnext, Data, '
"level": "', '
",');
if (s = '
hd')
then QRec.level := 2;
if (s = '
sd')
then QRec.level := 1;
s := GetStr(posnext, Data, '
"logo_token": "', '
",');
StrLCopy(QRec.logo_token , PAnsiChar(s), High(QRec.logo_token) - 1);
s := GetStr(posnext, Data, '
"availability": "', '
"');
QRec.available := (s = '
available');
inc(PosNext, 5);
// jump over last bracketsm komma & spaces !
//LOG('UPDCHL', '--- Q' + inttostr(numQRec) + ' - avail: ' + booltostr(QRec.available, true) +
// ' | level: ' + inttostr(QRec.level));
// ----- Check if selectable:
if (ChlRec.QSelect < 0)
then
if QRec.available
then ChlRec.QSelect := ChlRec.Qualy.Count - 1;
s := GetStr(posnext, Data, '
"stream_types": [', '
],');
// get next qualy-data
end;
//LOG('UPDCHL', '--- selected: ' + inttostr(ChlRec.QSelect));
PosNext := PosRem;
// !!! ... because PosNext is in range of next channel !
// Ignore: "recommendations" // 11)
// Here: ... EPG-Now 7)
// Ignore: "id": "ard", // 13)
// Ignore: "aliases": ["daserste"] // 14)
// IGNORE: FAV-block
PosNext := PosEx('
"display_alias"', Data, PosNext);
// // get begin of next channel
end;