TVServer: XmlTV Importer, Delete on Import not always working (1 Viewer)

SirDester

New Member
January 10, 2011
4
1
Home Country
Italy Italy
MediaPortal Version: 1.2.3

Description
Hi,
I setup my TVServer so that every night, at 3.00 AM, an external process downloads from the web an updated xmltv file and copies it in the directory monitored by TVService for the automatic import.
I noticed that the import sometimes failed, and so I went to tv.log to check the reason. Here is the significant log:

2012-08-19 03:00:22.411531 [XmlTvImporter(24)]: Xmltv: imported 64 channels, 0 programs status:tvguide.xml:Invalid XML file:È già stato aggiunto un elemento con la stessa chiave.;
(it's in italian, it says that an element with the same key was already added)

So I opened the TVService configurator, went to the XmlTv plugin options, and run manually the job with the appropriate button. The result is:

2012-08-19 14:19:43.573374 [SetupTv(1)]: Xmltv: imported 64 channels, 12655 programs status:tvguide.xml:File imported successfully;

Useless to say that the flag "Delete before import" is flagged on the configurator form.

Steps to Reproduce:
The steps to reproduce the problem were written in the description above.
I can add one thing, if it can be usefull for the team.
I downloaded the current sources of all the TVLibrary, and checked for the section where the automatic import is done. I'm trying to understand the differences between the automatic import and the manual one.

If I find something I'll add here.

For now I can send you the current xmltv file that gives me the problem, if you want to try to reproduce the issue.

Thanks all for the support and good work.
 
Last edited:

SirDester

New Member
January 10, 2011
4
1
Home Country
Italy Italy
Ok, after some difficulties, I succeded in compiling the trunk version of the XmlTvImport.dll.
The big problem is that the issue is not so easy to be reproduced, I tried now and it seems to work with current and trunk version of dll.

If it can be usefull, I've found a little issue (which I don't know if can be connected to my problem) in TvEngine.XMLTVImport class, method Import.

Code:
Channel chan = null;
// a guide channel can be mapped to multiple tvchannels
foreach (Channel ch in allChannels)
{
if (ch.ExternalId == id)
{
chan = ch;
chan.ExternalId = id;
}
 
if (chan == null)
{
// no mapping found, ignore channel
continue;
}
 
... other code that follows

In this foreach, the "continue" is hit only before finding a good mapping. From that point, all the code following this is executed for every other channel, even if not mapped, because chan is never resetted to null.

If I can suggest a change in this cycle, I would write something like that (adding System.Linq to using, I love Linq :))

Code:
var mappedChannels = allChannels.Where(i => i.ExternalId == id);
foreach (Channel ch in mappedChannels)
{
Channel chan = ch;
chan.ExternalId = id;
 
... other code that follows

In this way the code is executed exactly for all the mapped channels. I'm not sure if assigning the "ch" to "chan" is necessary, but in this way the following code will work without any other changes.

Thanks.
Maurizio.
 
Last edited:

Users who are viewing this thread

Top Bottom