[eStaticServiceDVBPVRInformation] Extraction of name & time from filename can fail

Issue #637 resolved
prl created an issue

In eStaticServiceDVBPVRInformation, extraction of name & time from a recording filename when a .meta file is absent fails if the recording was made with a setting of MENU>Setup>TV>Recording settings>Composition of recording filenames is set to anything other than standard.

For example (filename, then name extracted into .meta file):

standard

(correct extraction)

20180409 1022 - ABC - Antiques Roadshow.ts

Antiques Roadshow

Event name first

Antiques Roadshow - 20180409 1026_ABC.ts

Antiques Roadshow - 20180409 1026_ABC.ts

Short filenames

20180409 - Antiques Roadshow.ts

20180409 - Antiques Roadshow.ts

Long filenames

20180409 1035 - ABC - Antiques Roadshow - A huge turnout of visitors awaits Fiona Bruce & the team at Lincoln Cathedral_ Objects under scrutiny include a gruesome surgeon's set of tools from the 1860s & a plate hidden for years provides its owner .ts

Antiques Roadshow - A huge turnout of visitors awaits Fiona Bruce & the team at Lincoln Cathedral_ Objects under scrutiny include a gruesome surgeon's set of tools from the 1860s & a plate hidden for years provides its owner

---

The extraction is only correct for the standard filename format. The .ts extension is only removed from the extracted name for standard and long filename formats.

There is also perhaps an opportunity to fill the .meta file's description field from the description in the filename, though there may be some ambiguity in that.

The start time extraction only works for those two formats. For event name first and short filenames, the start time falls back to the inode modification time of the recording file (a file date is probably the best that can be done for the short filename format, since it only has the date, not the time.

Even for the standard and long filename formats where a time fields are extracted correctly from the filename, the resulting time_t is incorrect if DST was in effect at the recording time, because eStaticServiceDVBPVRInformation::getName() leaves tm.tm_isdst set to 0 when it calls mktime(). It should be set to -1 to direct mktime() to use the zoneinfo database to convert the struct tm into a time_t.

Finally, the code in dvb/metaparser.cpp that sets the fallback eDVBMetaParser::m_time_create appears to assume that a stat() call's struct stat.st_ctime is the file creation time, when it's the time that the file's inode field was last modified (and which can be no earlier than the files last modified time), but I will write up a separate issue for that.

Replication steps

On a T4 or U4, set MENU>Setup>TV>Recording settings>Composition of recording filenames to each of its four settings, and for each setting, create a short recording timer for HDMI IN and let it run. Set both a name and description for the timer so that the effects on the long filename format can be seen.

That will create .ts files with all four filename formats that lack corresponding .ts.meta files.

View the recordings in the media selection screen (MEDIA from live TV), and note that only the recording with the standard filename format has its recording name correctly extracted. The recordings with short filename and event name first format show their recording end time as their recording time (that is probably the best possible for the short filename format). If DST is currently in force, the displayed recording start time for the standard and long filename formats will be out by one hour.

If DST is not in force, then remove the .ts.meta file for the standard format recording and rename it so that the date in the filename is for a time when DST is in force. When the recording is then viewed in the media selection screen its displayed recording time will differ by 1 hour from the timestamp in the filename.

Comments (1)

  1. Peter Urbanec

    Fix bug #637: [eStaticServiceDVBPVRInformation] Extraction of name & time from filename can fail

    Remove static function looksLikeRecording() which is both not specific enough and fails to detect "short" and "event first" recording filenames.

    In eStaticServiceDVBPVRInformation::getName() replace it with inline code to more accurately detect recording filenames and extract the recording name and recording time from the filename.

    For "short" format names, which only have the recording date in their names, use the fallback recording creation time rather than the date in the filename if the fallback time is not 0.

    Set stm.tm_isdst to -1 before calling mktime() so that it uses the zoneinfo database to determine whether to apply DST to the time conversion.

    In eStaticServiceDVBPVRInformation::getInfo() and eStaticServiceDVBPVRInformation::getInfoString() call getName() to ensure that any fields that are needed to be extracted from the filename are extracted.

    → <<cset 0e7f8e267069>>

  2. Log in to comment