[mythtv-users] Cleanup recordings not in database

Ramon Hofer ramonhofer at bluewin.ch
Thu Jun 23 10:38:11 UTC 2011


On 06/14/2011 06:57 PM, Chris Kapp wrote:
> On Tue, Jun 14, 2011 at 11:54 AM, Ramon Hofer<ramonhofer at bluewin.ch>  wrote:
>> On 06/14/2011 05:45 PM, Ian Clark wrote:
>>> On 14 June 2011 16:13, Ramon Hofer<ramonhofer at bluewin.ch>    wrote:
>>>> Hi all
>>>>
>>>> I've had some problems with my tuner and was playing around.
>>>> Now I have restored a database where there are not all recordings - that
>>>> are on the disk - are in the database.
>>>>
>>> I use this, ymmv, you'll need to either make it accept
>>> username/password or hardcode them into the script like I have (I use
>>> the defaults so I'm unfussed.)
>>>
>>> FWIW I remove the echo from the rm line and just run this, however,
>>> that's at your own risk. :)
>>>
>>> Also, this isn't particularly efficient, but it works.
>>>
>>> <-------------------------------------------------------------------------
>>> mythtv at pvr:~$ cat bin/findorphans.sh
>>> #!/bin/bash
>>>
>>> sql="mysql -umythtv -pmythtv -B -N -e"
>>> dir="/home/mythtv/tv/"
>>> tmpfile=`mktemp`
>>> $sql "select basename from mythconverg.recorded">    $tmpfile
>>>
>>> find $dir -name "*.mpg" | while read line
>>> do
>>>           file=`echo $line | tr "/" "\n" | tail -1`
>>>           if [ "`grep $file $tmpfile`" == "" ]; then
>>>                   echo "$line doesn't exist in the database."
>>>                   echo rm $line
>>>           fi
>>> done
>>>
>>> rm $tmpfile
>>> <-------------------------------------------------------------------------
>>>
> Recently I had a hard drive crash that left records in the database
> without files and files without database records (I managed to get
> some of the files backed up before I completely lost the drive).  I
> found this script worked well:
>
> http://www.mythtv.org/wiki/Find_orphans.py
>

I wanted to test the script as well but I got the following error:

Traceback (most recent call last):
   File "/home/hoferr/bin/find_orphans.py", line 3, in <module>
     from MythTV import MythDB, MythBE, Recorded
ImportError: No module named MythTV


How can I add these modules?


More information about the mythtv-users mailing list