Skip to content

Commit

Permalink
Xmltv providers: implement xz compression format (this can be made in…
Browse files Browse the repository at this point in the history
… better way but for now it works)
  • Loading branch information
meo committed Sep 9, 2017
1 parent 969227d commit b78e0f8
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion src/common/xmltv/xmltv_downloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bool xmltv_downloader_channels (char *url, char *dbroot, void(*progress_callback
}

if (xmltv_downloader_extension_check (page, "gz"))
{
{
int fd2 = -1;
char sfn2[256];
sprintf (sfn2, "%s/crossepg.tmp.XXXXXX", dbroot);
Expand All @@ -124,6 +124,32 @@ bool xmltv_downloader_channels (char *url, char *dbroot, void(*progress_callback
if (event_callback) event_callback(4, NULL); // reading message
ret = xmltv_channels_load (sfn2);
unlink (sfn2);
}
}
else if (xmltv_downloader_extension_check (page, "xz"))
{
char cmdxz[256];
int fd2 = -1;
char sfn2[256];
char sfn3[256];
sprintf (sfn2, "%s/crossepg.tmp.XXXXXX", dbroot);
sprintf (sfn3, "%s/cross.xz", dbroot);
if ((fd2 = mkstemp (sfn2)) == -1) log_add ("Cannot get temp file");
else
{
sprintf (cmdxz, "cp %s %s", sfn, sfn3);
system(cmdxz);
sprintf (cmdxz, "xz -d %s", sfn3);
system(cmdxz);
if (event_callback) event_callback(3, NULL); // deflating message
log_add ("Deflating %s", page);
close (fd2);
sprintf (sfn3, "%s/cross", dbroot);
sprintf (cmdxz, "mv -f %s %s", sfn3, sfn2);
system(cmdxz);
if (event_callback) event_callback(4, NULL); // reading message
ret = xmltv_channels_load (sfn2);
unlink (sfn2);
}
}
else
Expand Down Expand Up @@ -229,6 +255,36 @@ bool xmltv_downloader_events (char *url, char *dbroot, void(*progress_callback)(
unlink (sfn2);
}
}

else if (xmltv_downloader_extension_check (page, "xz"))
{
char cmdxz[256];
int fd2 = -1;
char sfn2[256];
char sfn3[256];
sprintf (sfn2, "%s/crossepg.tmp.XXXXXX", dbroot);
sprintf (sfn3, "%s/cross.xz", dbroot);
if ((fd2 = mkstemp (sfn2)) == -1) log_add ("Cannot get temp file");
else
{
sprintf (cmdxz, "cp %s %s", sfn, sfn3);
system(cmdxz);
sprintf (cmdxz, "xz -d %s", sfn3);
system(cmdxz);
if (event_callback) event_callback(6, NULL); // deflating message
log_add ("Deflating %s", page);
close (fd2);
sprintf (sfn3, "%s/cross", dbroot);
sprintf (cmdxz, "mv -f %s %s", sfn3, sfn2);
system(cmdxz);
if (event_callback) event_callback(7, NULL); // parsing events
if (event_callback) event_callback(0, NULL); // turn on progress bar
ret = xmltv_parser_import (sfn2, progress_callback, stop);
if (event_callback) event_callback(1, NULL); // turn off progress bar
unlink (sfn2);
}

}
else
{
if (event_callback) event_callback(7, NULL); // parsing events
Expand Down

1 comment on commit b78e0f8

@lupomeo
Copy link
Member

@lupomeo lupomeo commented on b78e0f8 Sep 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be tested using these providers files ready for CrossEpg:
https://github.com/BlackHole/CrossEpgProviders

Please sign in to comment.