Virtual VDR directories for surround and HD recordings.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have been thinking for a while about virtual VDR directories
holding symbolic links to recordings that are stored elsewhere
using different sort criteria.

I have been a VDR user since 2000
http://www.tvdr.de/cgi-bin/vdr-counter.pl?action=show&number=3
and I have recorded a lot since then (9245 recordings),
so some kind of structure is required to find things quickly.

For example, I have top level folders for various genres in my
/video directory. So far, I decide after recording and cutting
into which folder I move the recording.

It might be better to have them all on one big RAID and
create symbolic links in /video, so I can find an action comedy
both in /video/Action and in /video/Comedy.

Regarding the genre, I have managed without that feature.
However, many German TV stations are now broadcasting
in HD, sometimes with 5.1 surround sound.
It is really hard to find these high quality recordings directly
among my 9245 recordings.

So I have written a little Python tool that creates "virtual"
recordings in a different folder structure from my "real"
recordings using symbolic links.
This is done by creating top level folders /video/Surround,
/video/HD, /video/Surround+HD and linking matching
recordings into these keeping the original folder structure
intact.

Maybe somebody else finds this useful, so I am attaching
the code. It only considers recordings that are cut
(having a % in the name). Please note that the tool
removes any existing folders /video/Surround,
/video/HD, /video/Surround+HD before re-creating them.
Use at your own risk.


Carsten.

import os
import shutil
import sys

video_dir = "/video"


def linkto(root, name):

   components = []
   for root_component in root.split('/')[2:]:
      components.append(root_component)
      if root_component.startswith('%'):
         break
   source = os.path.join(video_dir, '/'.join(components))
   target = os.path.join(video_dir, name, '/'.join(components))
   target_parent = os.path.join(video_dir, name, '/'.join(components[:-1]))
   if not os.path.exists(target_parent):
      os.makedirs(target_parent)
   os.symlink(source, target)


for subdir in ("Surround", "HD", "Surround+HD"):
   path = os.path.join(video_dir, subdir)
   if os.path.exists(path):
      shutil.rmtree(path)
   os.mkdir(path)

surround_dirs = []
hd_dirs = []
surround_hd_dirs = []
for root, dummy_dirs, files in os.walk(video_dir, followlinks=True):
   if '%' in root and ("info" in files or "info.vdr" in files):
      surround = False
      hd = False
      for line in open(os.path.join(root, "info" if "info" in files else "info.vdr")):
         if line.startswith("X "):
            if " 5.1" in line:
               surround = True
            elif "high definition Video" in line:
               hd = True
      if surround:
         surround_dirs.append(root)
      if hd:
         hd_dirs.append(root)
      if surround and hd:
         surround_hd_dirs.append(root)

for root in surround_dirs:
   linkto(root, "Surround")
for root in hd_dirs:
   linkto(root, "HD")
for root in surround_hd_dirs:
   linkto(root, "Surround+HD")
_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux