[mythtv-users] find orphans.py question

Michael T. Dean mtdean at thirdcontact.com
Wed Apr 13 19:30:15 UTC 2011

On 04/13/2011 03:06 PM, Raymond Wagner wrote:
> On 4/13/2011 14:41, Warpme wrote:
>> use DBI;
> You should be using the MythTV module, rather than direct database
> access.  It will read the necessary config files to find the database,
> and fall back to UPnP detection if the config files do not exist.
>> &dir_lookup("SELECT data FROM settings WHERE value='RecordFilePrefix'
>> AND hostname=(?)");
> This hasn't been used since 0.19.  Does it still need checking?
>> my $q = "SELECT title, subtitle, description, starttime, endtime,
>> chanid, basename FROM recorded WHERE hostname=(?)
> Limiting yourself to a specific hostname can be dangerous.  In
> situations with multiple backends using shared storage, one backend
> would see recordings from another as an orphaned file.
>>              my $sql = sprintf "DELETE FROM oldrecorded WHERE title
>> LIKE \"%s\" AND subtitle LIKE \"%s\" AND description LIKE \"%s\" LIMIT
>> 1", $title, $subtitle, $description;
>>              my $sql = sprintf "DELETE FROM recorded WHERE basename
>> LIKE \"%s\" LIMIT 1",$basename;
>>                  my $sql = sprintf "UPDATE oldrecorded SET duplicate =
>> 0 where title = \"%s\" and starttime = \"%s\" and chanid = \"%s\"",
> You should be using MythProto calls for all of these.  There is a
> _whole_ lot more to removing a recording from the database than just
> removing its entry in `recorded`.  All of these should be accompanied by
> a call to rerun the scheduler.
>>                          unlink "$this_dir/$this_file";
> Again, you should be using MythProto calls for this.  Unlinking a file
> on an ext3 filesystem has some serious implications, and can result in
> the damaging of in-progress recordings.  Using the MythProto call to
> delete the file will allow it to follow the slow delete setting.

Or, better, rather than work on bringing the old code from the old, 
legacy, unmaintained myth.find_orphans.pl up to speed, just start with 
the new, maintained, up-to-date, properly-designed-for-current-MythTV 
find_orphans.py and add in your own additions--or create a separate 
script to do the extras you want.


More information about the mythtv-users mailing list