Author: dmeyer
Date: Sun Dec  3 14:01:42 2006
New Revision: 2148

Modified:
   trunk/beacon/TODO
   trunk/beacon/src/db.py
   trunk/beacon/src/item.py
   trunk/beacon/src/server/crawl.py
   trunk/beacon/src/server/parser.py

Log:
start dvd on hd support

Modified: trunk/beacon/TODO
==============================================================================
--- trunk/beacon/TODO   (original)
+++ trunk/beacon/TODO   Sun Dec  3 14:01:42 2006
@@ -1,5 +1,9 @@
 1. Support DVD directories
 
+   Right now it works a little bit. But if a dir is a DVD dump, there
+   is no inotify support in the VIDEO_TS subdir. The items itself also
+   use the file:// scheme which is not correct.
+
 2. Update Monitor class
 
    o Handle dirname searches on directories not monitored by inotify

Modified: trunk/beacon/src/db.py
==============================================================================
--- trunk/beacon/src/db.py      (original)
+++ trunk/beacon/src/db.py      Sun Dec  3 14:01:42 2006
@@ -353,10 +353,8 @@
             e = self._db.query(parent=parent._beacon_id, name=basename)
             if e:
                 # entry is in the db
-                basename = e[0]
-        if os.path.isdir(filename):
-            return create_file(basename, parent, isdir=True)
-        return create_file(basename, parent)
+                return create_file(e[0], parent, isdir=e[0]['type'] == 'dir')
+        return create_file(basename, parent, isdir=os.path.isdir(filename))
 
 
     @kaa.notifier.yield_execution()

Modified: trunk/beacon/src/item.py
==============================================================================
--- trunk/beacon/src/item.py    (original)
+++ trunk/beacon/src/item.py    Sun Dec  3 14:01:42 2006
@@ -215,6 +215,7 @@
         """
         Callback from db with new data
         """
+        self._beacon_isdir = (data['type'] == 'dir')
         self._beacon_data = dict(data)
         self._beacon_id = (data['type'], data['id'])
         for key, value in self._beacon_changes.items():
@@ -293,6 +294,7 @@
 
 
 def create_item(data, parent):
+    data = dict(data)
     if 'url' in data:
         url = data['url']
     else:

Modified: trunk/beacon/src/server/crawl.py
==============================================================================
--- trunk/beacon/src/server/crawl.py    (original)
+++ trunk/beacon/src/server/crawl.py    Sun Dec  3 14:01:42 2006
@@ -75,7 +75,7 @@
     def remove(self, dirname, recursive=False):
         if recursive:
             for d in self.keys()[:]:
-                if s.startswith(dirname):
+                if d.startswith(dirname):
                     self.remove(d)
             return
         if self.pop(dirname):
@@ -251,6 +251,9 @@
             if item._beacon_isdir:
                 # It is a directory. Just do a full directory rescan.
                 self._scan_add(item, recursive=False)
+                if name.lower().endswith('/video_ts'):
+                    # it could be a dvd on hd
+                    self._scan_add(item._beacon_parent, recursive=False)
                 return True
 
             # handle bursts of inotify events when a file is growing very
@@ -423,6 +426,14 @@
         """
         log.info('scan directory %s', directory.filename)
 
+        if directory._beacon_parent and \
+               not directory._beacon_parent._beacon_isdir:
+            log.warning('parent of %s is no directory item', directory)
+            if hasattr(directory, 'filename') and \
+                   directory.filename + '/' in self.monitoring:
+                self.monitoring.remove(directory.filename + '/', 
recursive=True)
+            yield []
+            
         # parse directory
         if parse(self.db, directory, check_image=self._startup):
             yield kaa.notifier.YieldContinue

Modified: trunk/beacon/src/server/parser.py
==============================================================================
--- trunk/beacon/src/server/parser.py   (original)
+++ trunk/beacon/src/server/parser.py   Sun Dec  3 14:01:42 2006
@@ -144,7 +144,11 @@
 
     attributes = { 'mtime': mtime, 'image': metadata.get('image') }
 
-    if db.object_types().has_key(metadata.get('media')):
+    if metadata.get('media') == 'disc' and \
+           db.object_types().has_key(metadata.get('subtype')):
+        type = metadata['subtype']
+        item._beacon_isdir = False
+    elif db.object_types().has_key(metadata.get('media')):
         type = metadata['media']
     elif item._beacon_isdir:
         type = 'dir'
@@ -235,15 +239,19 @@
     # to the db.
     attributes['metadata'] = metadata
 
-    # TODO: do some more stuff here:
-    # - add subitems like dvd tracks for dvd images on hd
-
     # now call extention plugins
     ext = os.path.splitext(item.filename)[1]
     if ext in extention_plugins:
         for function in extention_plugins[ext]:
             function(item, attributes)
 
+    if item._beacon_id and item._beacon_id[0] != type:
+        # the type changed, we need to delete the old entry
+        log.warning('change %s to %s for %s', item._beacon_id, type, item)
+        db.delete_object(item._beacon_id)
+        item._beacon_id = None
+        db.commit()
+        
     # Note: the items are not updated yet, the changes are still in
     # the queue and will be added to the db on commit.
 
@@ -261,6 +269,27 @@
                       callback=item._beacon_database_update,
                       media=item._beacon_media._beacon_id[1],
                       **attributes)
+
+    if hasattr(metadata, 'tracks'):
+        # The item has tracks, e.g. a dvd image on hd. Sync with the database
+        # now and add the tracks.
+        db.commit()
+        if not metadata.get('type'):
+            log.error('%s metadata has no type', item)
+            return produced_load
+        if not 'track_%s' % metadata.get('type').lower() in \
+           db.object_types().keys():
+            log.error('track_%s not in database keys', 
metadata.get('type').lower())
+            return produced_load
+        type = 'track_%s' % metadata.get('type').lower()
+        for track in metadata.tracks:
+            db.add_object(type, name=str(track.trackno),
+                               parent=item._beacon_id,
+                               media=item._beacon_media._beacon_id[1],
+                               mtime=0,
+                               metadata=track)
+        db.commit()
+        
     if store:
         db.commit()
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to