Bug 385356 - Kaffeine does not understand bilingual DVB program guide
Summary: Kaffeine does not understand bilingual DVB program guide
Status: RESOLVED FIXED
Alias: None
Product: kaffeine
Classification: Applications
Component: general (show other bugs)
Version: 2.0.5
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Mauro Carvalho Chehab
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-04 12:42 UTC by Heikki Kantola
Modified: 2017-11-13 16:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot of the EPG (123.09 KB, image/png)
2017-10-04 12:42 UTC, Heikki Kantola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Heikki Kantola 2017-10-04 12:42:03 UTC
Created attachment 108161 [details]
Screenshot of the EPG

Somewhat related to older bug #241232, but 1.x versions did only show bilingual EPG (as provided by Finnish Broadcasting Company YLE) entries in one language (albeit with some version with language you would not liked to see), whereas 2.0.5 (the version in Ubuntu 17.04) shows EPG data for both languages, which is pretty ugly. This is especially nasty when picking a program for recording from EPG as it takes the bilingual title, which is formed by the titles in two different languages combined with no separator.
Comment 1 Mauro Carvalho Chehab 2017-10-04 13:25:49 UTC
(In reply to Heikki Kantola from comment #0)
> Created attachment 108161 [details]
> Screenshot of the EPG
> 
> Somewhat related to older bug #241232, but 1.x versions did only show
> bilingual EPG (as provided by Finnish Broadcasting Company YLE) entries in
> one language (albeit with some version with language you would not liked to
> see), whereas 2.0.5 (the version in Ubuntu 17.04) shows EPG data for both
> languages, which is pretty ugly. This is especially nasty when picking a
> program for recording from EPG as it takes the bilingual title, which is
> formed by the titles in two different languages combined with no separator.

Currently, Kaffeine just assumes that all EPG entries have one language. I can think on two ways to add support for multiple EPG languages:

1) add an option at TV settings that would allow the user to select the language he wants. If not specified, keep the current behavior. Otherwise, it will just discard any EPG entry that doesn't match it;

The drawback is that, if the language is specified wrong, it won't record anything. One advantage is that one could use it to make it to just discard any EPG entries, in order to reduce CPU usage. Another one is that the changes for it would be trivial.

2) store entries of different languages on different entries at the EPG table.

That will require non-trivial changes at Kaffeine, and any already stored EPG database will be incompatible with the changes.

I probably won't have enough time to implement (2) right now, but (1) easier, and I can add an extra optional field there at the database, in order to prepare for (2) on some next version.

Yet, I need a recorded signal with ~60 seconds with dvbv5-zap for one transponder with multi-language EPG tables on it. With such record, I can use my RF generators in order to test the new EPG decoding code.

Please take a look at https://www.linuxtv.org/wiki/index.php/Dvbv5-zap for instructions about how to use it.

PS.: The size of the record is too big for storing at the BZ. You'll likely need to place it at a dropbox or googledriver. Feel free to send the link for me to download via e-mail.
Comment 2 Mauro Carvalho Chehab 2017-11-05 13:13:34 UTC
I added limited support for Kaffeine to handle multi-language EPG.

It will now store the language on its EPG database.

On EPG, it will now show the title only at the first language. The detail window will have both languages (when multiple languages are available).

On OSD, it will show the titles on both languages too (if are there enough space to display both on a single line).

I didn't add yet an option to allow the user to select its default language. 

The reason is that there are a few things to be addressed:

- The title is used by the Kaffeine's record system to check for duplicated records. with multi-language EPG support, switching the language should not invalidate existing records;

- Where would be the best place to put a language selection menu? at program guide? As a button? As a sub-menu?

- The languages are per EPG entry. If one has multiple Digital TV devices, it may want to select more than one language, with makes the logic very complex;

- The ISO-639 language code at the parental control is actually per Country. So, on the stream you provided me, there's just one language: FIN; while for title/subheader/details, there are two: SWE and FIN. I suspect that, on some places, the code there can be actually different than the language options.

So, I need to think a little bit more in order to see how to better address a language selection menu.

There's one drawback on this patchset: if you have already an EPG database stored at ~/.local/share/kaffeine/epgdata.dvb, it will be able to read the old format, but, as it doesn't know the language, it will add the already existing data as a new language ("first") during the initial database import. I opted to do that in order to not break program recordings for people that upgrade Kaffeine to some version after the language patches. Of course, after a few days, the EPG data will be obsoleted.

Anyway, the patches that should be addressing this issue are at:

https://cgit.kde.org/kaffeine.git/commit/?id=31710fa98bf60eb1a3df250c2f81cc0213171ebf

https://cgit.kde.org/kaffeine.git/commit/?id=dbb2550baebc5a22d7e31dd034ed4cacf964f723

Please test.
Comment 3 Mauro Carvalho Chehab 2017-11-06 09:42:25 UTC
(In reply to Mauro Carvalho Chehab from comment #2)
> I added limited support for Kaffeine to handle multi-language EPG.
> 
> It will now store the language on its EPG database.
> 
> On EPG, it will now show the title only at the first language. The detail
> window will have both languages (when multiple languages are available).

Ok, I added a patch adding language selection at the program guide menu:

   https://commits.kde.org/kaffeine/bbae78f3cc9b11ffed5c3b34445249bdb7f21b17

Now, by default, it will show all languages together, but it is possible to select any of the languages that were found at the program guide. I guess this address this bug.

Please test.
Comment 4 Heikki Kantola 2017-11-07 18:15:53 UTC
The patches seem to work pretty well, but there is one minor detail that bugs me: when you select a program from EPG for recording, Kaffeine still picks the title in the first available language rather than in the one you have selected.
Comment 5 Mauro Carvalho Chehab 2017-11-07 21:19:02 UTC
(In reply to Heikki Kantola from comment #4)
> The patches seem to work pretty well, but there is one minor detail that
> bugs me: when you select a program from EPG for recording, Kaffeine still
> picks the title in the first available language rather than in the one you
> have selected.

Yeah, also at OSD it won't honor the selected language. 

In the case of EPG recording, it only uses the first language internally, as it simplifies the logic. It shouldn't be hard to display a different language, but it sounds counter-intuitive to set a global language preference at the "Program  Guide" window, but moving it to the TV Setting windows (where such kind of global preferences belong) would be weird, as this is the kind of window that it is set before TV scan. On that time, Kaffeine still doesn't know what languages are actually present at the received streams.

I could perhaps write a table of ISO 639-2 codes and use such table to setup the language default, allowing the user to select any existing language code there, but I guess qt5 doesn't have a library that I could use, and having to maintain such table inside Kaffeine could be painful as times goes by.

Do you have any other suggestions?
Comment 6 Mauro Carvalho Chehab 2017-11-08 17:01:31 UTC
(In reply to Mauro Carvalho Chehab from comment #5)
> (In reply to Heikki Kantola from comment #4)
> > The patches seem to work pretty well, but there is one minor detail that
> > bugs me: when you select a program from EPG for recording, Kaffeine still
> > picks the title in the first available language rather than in the one you
> > have selected.
> 
> Yeah, also at OSD it won't honor the selected language. 
> 
> In the case of EPG recording, it only uses the first language internally, as
> it simplifies the logic. It shouldn't be hard to display a different
> language, but it sounds counter-intuitive to set a global language
> preference at the "Program  Guide" window, but moving it to the TV Setting
> windows (where such kind of global preferences belong) would be weird, as
> this is the kind of window that it is set before TV scan. On that time,
> Kaffeine still doesn't know what languages are actually present at the
> received streams.
> 
> I could perhaps write a table of ISO 639-2 codes and use such table to setup
> the language default, allowing the user to select any existing language code
> there, but I guess qt5 doesn't have a library that I could use, and having
> to maintain such table inside Kaffeine could be painful as times goes by.
> 
> Do you have any other suggestions?

After sleeping on it, I decided to keep the language dialog at the Program Guide. After all, it is all related to EPG parsing.

Now, if a language is selected via the Program guide, it will use it also for OSD.

In the specific case of recording, it will use the language that was used when a program is selected to be recorded. So, if, for instance, a program was originally scheduled to be recorded when the Program Guide is in Finish, it will show it in Finish at the recording display, even if the language was switched later to some other language.

I also made the language more persistent, in the sense that, if you close and re-open the EPG guide, it will use the latest value. The EPG language is not saved, though, so if you close and re-open Kaffeine, it will reset to "Any language".

It shouldn't be hard to save its value as well, but, on such case, it shoudn't be just an EPG program display option, but something to be set via the TV configuration panel. Considering the usecase of someone with multiple DVB-S dishes, I don't think that a single option among languages should be recorded, as different satellites may have different sets of EPG languages.

So, for now, let's not save the language definition.
Comment 7 Mauro Carvalho Chehab 2017-11-08 17:02:50 UTC
Forgot to mention: Patches are available at Kaffeine development tree, up to this one:

https://commits.kde.org/kaffeine/f0a74c38ebc4494a13eed79b5a64d85f33f5b82e
Comment 8 Mauro Carvalho Chehab 2017-11-13 16:06:14 UTC
FYI,

I had to change the format of the EPG file, in order to solve a minor issue related to parental control. As I didn't release a new Kaffeine version, I opted to not add backward compatibility parser for the intermediate version. The net result is that, if you're using a version from Kaffeine's git tree with multilanguage EPG before this changeset:
   2630fc066694 dvbepg: move parental control data out of language-dependent info

Then Kaffeine will detect an unknown version version and will discard the EPG data.