[mythtv-users] list my "damaged" recordings

Michael T. Dean mtdean at thirdcontact.com
Mon Oct 26 21:07:19 UTC 2015


On 10/26/2015 02:55 PM, Evuraan wrote:
>>> how can i list my damaged recordings (so I can programmatically delete
>>> those..)?
>>>
> thank you for the pointers, that helped immensely!
>
>
> #!/bin/bash
>
> user_name="XXXX"
> pass_word="YYYY"
> RECORDINGDIR="/var/lib/mythtv/recordings"
> SQLSCRIPT="/tmp/recordings.sql-txt-$RANDOM-$RANDOM"
> mysql="mysql -u $user_name -p$pass_word mythconverg"
>
>
> remove_myth(){
> [ -s "${RECORDINGDIR}/${a}" ] && { rm -fv "${RECORDINGDIR}/${a}" ;
>          echo "DELETE FROM mythconverg.recorded WHERE basename = '$a';" > $SQLSCRIPT
>          [ -s "$SQLSCRIPT" ] && $mysql < $SQLSCRIPT
>          }
> }
>
> $mysql -e "select starttime  from recordedprogram where videoprop like
> '%DAMAGED%'"  |  while read b ; do  $mysql -e  " select basename from
> recorded where starttime='$b'" ; done  |grep mpg | while read a
> do
>          remove_myth $a
> done
>
>
> rm $SQLSCRIPT 1>/dev/null 2>&1 || :

Interesting that you replied to Bill Meek's excellent reply that gave 
you a nice Python-bindings-based script to ask MythTV what recordings 
are damaged, but somehow morphed it into a shell script that attempts to 
identify which recordings are damaged by interpreting MythTV's raw data 
in its internal data format and then improperly deletes a recording by 
directly editing MythTV's raw data in its internal data format without 
taking into account cross-table relationships and all the things that 
need to be done to do a safe deletion.  You really need to ask MythTV to 
delete the recording for you or things aren't cleaned up properly.

For anyone reading the list archives, please do not run this script (or 
any like it).

The proper approach is to use something like Bill's suggestion (which 
was cut from this reply, but can be seen at: 
http://www.gossamer-threads.com/lists/mythtv/users/591759#591759 ) to 
identify the damaged recordings and something like 
https://www.mythtv.org/wiki/Delete_recordings.py to ask MythTV to do the 
deletion.

Or, if you really want to do it often, just add delete functionality to 
Bill's script.

So, in short:
   Python bindings ask MythTV for information and MythTV does the 
interpretation of its raw data.  Python bindings ask MythTV to delete 
recordings and MythTV does everything required to properly and 
completely delete the recordings.
   Direct raw data manipulation presumes that you a) know the internal 
MythTV data format and constraints and b) interpret that data properly.  
Putting direct raw-data manipulation into a script presumes that a) 
MythTV won't change its internal data format and constraints or that b) 
you'll know when it does and update the script.

So, please, don't do the work.  Use the bindings to ask MythTV to do the 
work for you.

Mike


More information about the mythtv-users mailing list