[mythtv-users] Lost Recordings and Database

Stephen Worthington stephen_agent at jsw.gen.nz
Wed Jan 11 11:18:31 UTC 2023


On Tue, 10 Jan 2023 22:32:22 +1300, you wrote:

>On Tue, 10 Jan 2023 14:15:24 +1300, you wrote:
>
>>On Mon, 9 Jan 2023 11:35:39 +0000, you wrote:
>>
>>>Hi All,
>>>
>>>I wonder if someone with more knowledge of the Myth Database schema 
>>>might be able to advise me here. A friends Myth (0.32) system had a disk 
>>>tragedy and he has lost one of two volumes where the recordings are/were 
>>>held. The database entries for those recordings remain intact.
>>>
>>>Would it be possible to construct an SQL query that would take entries 
>>>after a specific date in the Recorded table and arrange for those 
>>>recordings to be entered into the Recording Schedules. In effect a 
>>>"Delete and Re-Record" operation.
>>>
>>>Many thanks
>>>
>>>Ken
>>
>>That certainly sounds possible.  What you would want to do would be to
>>check all recordings and get the basename field for each file, then
>>check if the file can be found on disk.  If not, then do the delete
>>and re-record.  There are API calls to list recordings with various
>>filters, and there is an API to do delete.  I would have to check if
>>the delete API has a re-record option.  If so, it would not be a
>>particularly complicated bit of Python to do this.
>
>The DeleteRecording API does have options to delete metadata if the
>recording file is not present and to re-record.  The GetRecording API
>will return the recording data if the recording is present, and
>presumably will do an error if it is not, so it should be able to be
>used to determine if the recording file exists.  The GetRecordedList
>API will return a list of all recordings.
>
>So what I would do would be to get the full list of recordings, then
>for each one do GetRecording and see if the file exists.  If it does,
>delete that entry in the recordings list.  Then display the list of
>recordings that have no files for the user to check.  After checking,
>the user says whether to proceed with doing a delete-and-re-record on
>each of those recordings, using the option to force a delete if the
>recording file is missing.  All of which is fairly straightforward for
>anyone who has used the MythTV Services API before, but does represent
>a few hours of work to write.
>
>I would recommend only running the program when MythTV is not busy and
>is not going to be busy for a while, as it will do a lot of database
>updates and may make it too busy to start or stop recordings properly.

I am having a go at writing some Python to do this.  So far I have it
getting the recordings list and working out which ones to delete due
to having missing recording files, but I have not yet written the code
to do the deletions (or to create new recording rules if necessary).
If you want to try the work in progress, I have put it on my web
server:

http://www.jsw.gen.nz/mythtv/myth-delete-missing.py

For testing purposes if you do not want too much output, I would
suggest using an SQL option like this:

-s "limit 10"

on the command line or put it in the SQL file.

It creates a myth-delete-missing.py.log file in the current directory
where it puts all the debug output, so if you have any problems with
it, please let me know and send me a copy of the log file, and a copy
of any exception traces.

So far I have not considered how to do username/password where you
have your backend set up to require that - let me know if this is
actually needed.


More information about the mythtv-users mailing list