[mythtv-users] Get list of all recordings' filenames and sizes

Michael T. Dean mtdean at thirdcontact.com
Tue Aug 11 18:32:27 UTC 2015


On 08/11/2015 12:30 PM, Ian Oliver wrote:
> Hi,
>
> Yes, I should backup more often! My XFS partition is scrambled
> (partition table and XFS master superblock overwritten) and I'm not
> hopeful of a fast fix.  I'm currently imaging the disk to see if
> xfs_repair can use a secondary, but I'm pretty sure there will be data
> loss.
>
> It occurred to me that I could use xfs_irecover to just get all (or
> most of?) the files off but without handy things like file names and
> dates.
>
> http://man.gnu.org.ua/manpage/?8+xfs_irecover
>
> But mythtv knows about all the recordings, including I hope the exact
> file size, so if someone can tell me how to extract this from mysql I
> can get a file of recovered files and sizes, one of database files and
> sizes, and use Python to rename the files that match. I'm kind of
> hoping that there aren't too many files with exactly the right size!

The attached python script will do it.  I'm sure someone could do much 
prettier python for it, but it works and is relatively easy to 
understand.  It's currently sorting by file size, descending.  And you 
can modify the print statement to do whatever you like--for example, 
output lines you need for a script that renames all the found files.  
You could even have the script alert you to multiple files with 
identical file sizes and such.

> OK, so I might lose my .png files but maybe there is a way to recreate
> these?
They'll be re-created automatically as needed.  No need to worry. 
They're transient files that can be deleted anytime without consequence.

> Is there any merit to this idea?
>

Sounds good to me, though I'm not a file system guy.

Mike
-------------- next part --------------
#!/usr/bin/env python

from MythTV import MythDB
from operator import itemgetter

recs = MythDB().searchRecorded()
recs = sorted(recs, key=lambda rec: rec.filesize, reverse=True)
for rec in recs:
  print '%d\t%s\t%s - %s' % (rec.filesize, rec.basename, rec.title, rec.subtitle)



More information about the mythtv-users mailing list