- DVBLogic, DVBLink 6.0.0
- Windows Scripting Host
DVBLink is a good product which works across a large number of platforms, and, considering how complex it is, it does a good job of interfacing between DVB-T/DVB-S terrestrial TV transmissions and the on-demand world of modern media consumption.
I’ve always had a few niggles with the system (‘clear data’ in Kodi anyone?), but have always found it good, save for one area. It’s recording database mechanic is at best flimsy and at worst out-right fragile.
The number of database corruptions, anomalies and times I have had to restore the database form backup in essence amount to every 6 months. It can be caused by a service crash, the PC restarting without a clean shutdown (power cut), loss of visibility of the disk where the recordings folder target sits (e.g. USB drive, iSCSI recording storage on a SAN/NAS or any other ejectable media) or as a result of installing a DVBLink update (I had a v5 update that trashed my recordings database about 2 months after I first started using it).
To provide a simple summary of the issues with the SQLlite database implementation:
- If the database is lost, that’s it. DVBLink/Kodi etc cannot ‘see’ your recordings, they are lost to the software even though they are still physically on disk and if you know where to look and how to open them, they remain watchable.
- Some failure situations can lead the database to have more in it than the file system does. This leads to the Kodi ‘click of nothing’, where clicking an item in the recordings section does just that, nothing (no error, just nothing)…
- … DVBLink has an option in the server settings to perform a consistency check. This is supposed to fix the ‘I have a database record but no file issue’… yet in reality, in my experience, this far too complicated and (I would assume) tries to be cleverer than asking “is there a recordings file on disk for this recording entry in the database?”. If you have ever tried to manually reconstruct the database with this option on, you’ll know that DVBLink simply deletes the entry…
- … Some failure situations – and the DVBLink provided consistency checking option – can lead the database to not have entries for recordings that do exist in the file system. Referring back to #1, you’ll recall that this means that DVBLink/Kodi etc does not know that they exist and you cannot watch the recordings. Equally there is no way to delete the orphaned files as they are not reported. Consequently your DVBLink system will slowly leak disk space. This is made worse by the fact that the database appears to track deletions, but doesn’t appear to have a (working) mechanism to restore the records again.
- There is no way to automatically recover from these situations.
- Once in these situations, there is no way to recover lost meta data on recording files that are orphaned in the recordings directory.
When a family member with a large pre-existing recording catalogue went away on 22nd December, returned on the 29th December to find that
- The old catalogue was no longer showing in Kodi
- No new programme recorded before 27th December was present
There were plenty of tears before bedtime.
Due to a connectivity problem between the DVBLink service and the recorder disk on the 27th, DVBLink had restarted and decided that as it couldn’t find the recordings folder, it would delete the now missing content form the recordings database.
It started recording from the 27th onwards onto the tiny local SSD that the OS is installed onto as a fail back (fair dues here DVBLink, good move), but come the 29th there were only 6 things (new content from the 28th and 29th) in the database. There should have been around 70 recordings.
There was no database backup available later than 12th December (by luck, I had made one on the 12th). There was no automatic database backup later than October.
I now needed to merge the 12th December backup and the 27th December+ master database back together. This would leave a data gap from 13th-26th December of missing records, so having done this in a SQLLite GUI editor, I started the DVBLink back up and… it promptly deleted 85% of all the material introduced from the 12th December backup.
The mystery of the database reconciliation option strikes again. By checking that all of the filenames in the database, I confirmed that the files were on the disk, including the thumbnails, but it decided to delete the imported old records anyway. Just not all of them for an unknown reason.
I turned off the reconciliation option and repeated the merging process again, and, it worked. The files played back in Kodi. I just cannot enable the database reconciliation feature. Ever.
At this point I turned my attention to the missing 13th-26th period. The file system revealed that this amounted to some 14 recordings. At this point I noticed one slight problem. I was expecting to be recovering around 70 files into the database, yet there were over 180, large, playable .ts files in the recording folder consuming some 360 GB of disk space. These files covered a period starting in April 2015 through to 29th December 2017.
Looking non-exhaustively at very old database backup files, I was able to find several of them, proving that they had at one point existed and had not been deleted by the user, but by the database consistence checked/reconciler. This posed the following chain of problems:
- If I import the contents of all of the old database backups that I have, I will be importing a mass of junk data.
- If I turn on the automatic (and unreliable) consistency checker to clean that up, I will wind up deleting all of the work thus far and likely only be a couple of steps further forward.
- I still have not solved the problem of the completely missing 13th December 2017 – 26th December 2017 database records.
I thus decided to write some code and use programming to help solve the problem. Thus the DVBLink_RecordingsDb Maintenance API was created. The API allows you to view:
- All files in the file system
- All records in the database
- All files in the file system that are not in the database
- All records in the database for which there is no associated file in the file system
In turn it allows you to:
- Remove entries in the database where the is no resultant file (using no other logic beyond is the correct .ts file presence e.g. the presence of a valid recording timer entry in the database to test validity is not used).
- Add entries to the database where there is a file in the file system but no existing database entry. The tool will attempt – i.e. best effort – to populate a new database record with the minimum amount of information necessary to allow DVBLink/Kodi to play the file. This is largely based upon the file name and spoofing channel data.
- Repair file play length information.
- Scan for an eliminate any duplicate records found in the database
The computer running the tool must:
- Windows / Windows Server
- Have the SQLite ODBC Drivers installed (use x86 or x64 depending on your platform)
- Be able to access the dlrecorder.db database file as a file system mount (e.g. a direct drive mount, SMB, NFS etc) – under Windows this is in “C:\Users\Public\Documents\DVBLink\dlrecorder.db” by default.
- Be able to access the recordings folder (the folder where DVBLink writes .ts recording files) as a system mount – under Windows this is in “C:\Users\Public\Documents\DVBLink\recorded” by default.
To run the code you must be running Windows and ensure that you install the correct SQLite ODBC driver first
- Make a manual backup of your dlrecorder.db file. This is found at “C:\Users\Public\Documents\DVBLink\dlrecorder.db”
Note: If you do not make a backup of the database file and something goes wrong, you will at best lose meta data and at worst lost recordings. Don’t risk it, make a backup!
- Download and fully extract the zip file using the link below
Note: Do not run the programme directly from the zip file
- Edit the config.vbs file in notepad or your preferred text editor
- Set the DB_PATH variable to the file system path of the dlrecorded.db file used by your DVBLink install. The default is provided
CONST DB_PATH = “C:\Users\Public\Documents\DVBLink\dlrecorder.db”
- Set the RECORDINGS_PATH variable to the file system path of the recorded folder where DVBLink records .ts files. The default is provided
CONST RECORDINGS_PATH = “T:\DVBLink\recorded”
- Save and close the config.vbs file
- Double click on the DVBLink_RecordingsUtility.wsf file to start the utility
You can download the DVDLink Recordings Utility below. The code is © C:Amie. Please do not redistribute this file, please link them to this page.
No warranty is offered of implied for using the code, nor loss of data/recordings from your DVBLink database. Please ensure that you make a backup of the DVBLink database before using the tool.
Taking all necessary precautions, use this tool at your own risk.
The tool has been tested on DVBLink 6.0.0 under Windows 10 1709.
If you found this tool useful, please consider donating towards the running costs of this site.
Download: DVBLink_RecordingsTool-1.0.0.zip (8.37KB)
Issues / Ideas
If you have any issues or ideas on how the tool can be made to be more useful, please get in touch.
A thought for the DVBLink team
If anyone from the DVBLink team sees this, I really like what you do – it is a great product, it just has a weak link at the moment. I appreciate fully that you are using SQLlite for search and interrogation performance reasons. You could however fairly easily eradicate these problems by:
- Adding granular control to the database consistency checker so that it isn’t so brutal – have whatever mode it currently exists in as an level 2 option and just set a test for the presence of the file in the file system as the level 1 option.
- Write an XML/JSON file into the file system with the same name as the recording .ts file or the .jpg thumbnail file. Keep all of the meta data on the recording in here as well as the database. This allows you to implement file portability. With this in place, the consistency checker can be easily re-written to check whether the .ts file has a meta data file too. If it finds a .ts file that it doesn’t know about that does have a meta data XML/JSON file, simply import the file into the database. The database consistency checker algorithm can do this itself on service start/periodically.
If you do that you have several new features:
- Portability of recordings without transcoding.
- Recording export/import.
- An easy, end-user achievable, self-service recovery path from outdated backups with a process that is simple to write up in a knowledge base article.
- Significantly less risk / reliance on the integrity of the database. Plus reassurance for you that there is significantly less likelihood that users like me will feel compelled to poke around in the database in the first place.
- Support for removable recording targets – when a disk is missing the database is cleared, when it comes back the recordings appear in the database again.
- An easy way to report to the user that there are genuinely orphaned files because there is a .ts file with no meta data.
- Users can drop in their own .ts file and write their own meta data XML/JSON file for it in a text editor using your schema (also allowing import from competitor products).
- A more robust database and file consistency checker / scavenger.
- Preservation of disk space use for the user, something that as I have outlined here, seems to leak over time.