Here is a patch that fixes the fxdhandler, videoitem and __init__ of the
video subsystem. Unless the DTD for video fxd files has changed, the
fxdhandler implementation does not respect the DTD (and none of my fxd
work anymore).

Moreover, the videoitem patch provides a dirty fix for the following
problem: when playing a video with a subtitle file specified in an FXD
file, the subtitle filename is enclosed in "". But this means that the
"" become part of the filename (so mplayer doesn't find the file), and
as the command line passed to mplayer is split on spaces, it doesn't
protect a filename containing spaces to be split, thus messing up the
command line of mplayer completely. The fix just removes the "", thus
forbidding the filenames containing spaces.

The solution to this problem is not trivial, since it requires to modify
a lot of code. There are 5 possibilities:
  - forbid names containing spaces (not user-friendly)
  - use another character than space for separating arguments on the
    command line, and then split it using this character (but what
    character? tabulation for example, since it is not used in
    filenames)
  - replace the command line string by a list (cleanest solution, imho)
  - try to execute the command line as is, without splitting it
    (possible in Perl, when executing through a shell which parses the
    command line; I don't know for Python)
  - parse ``manually'' the command line to take care of the "" (quite
    clean also, doesn't require wide changes in the code, only in a
    couple of places

Matthieu
-- 
 (~._.~)        Matthieu Weber - Université de Jyväskylä         (~._.~)
  ( ? )                email : [EMAIL PROTECTED]                  ( ? ) 
 ()- -()               public key id : 452AE0AD                  ()- -()
 (_)-(_)  "Humor ist, wenn man trotzdem lacht (Germain Muller)"  (_)-(_)
Index: video//__init__.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/video/__init__.py,v
retrieving revision 1.18
diff -u -r1.18 __init__.py
--- video//__init__.py  6 Dec 2003 13:44:11 -0000       1.18
+++ video//__init__.py  8 Dec 2003 09:22:25 -0000
@@ -161,9 +161,6 @@
             if not diritem.xml_file:
                 diritem.xml_file = tvinfo[3]
 
-        
-
-
 def hash_fxd_movie_database():
     """
     hash fxd movie files in some directories. This is used e.g. by the
@@ -217,6 +214,8 @@
             k = vfs.splitext(vfs.basename(info.xml_file))[0]
             tv_show_informations[k] = (info.image, info.info, info.mplayer_options,
                                        info.xml_file)
+            for fo in info.files_options:
+                discset_informations[fo['file-id']] = fo['mplayer-options']
             
     _debug_('done',1)
     return 1
Index: video//fxdhandler.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/video/fxdhandler.py,v
retrieving revision 1.5
diff -u -r1.5 fxdhandler.py
--- video//fxdhandler.py        7 Dec 2003 12:28:25 -0000       1.5
+++ video//fxdhandler.py        8 Dec 2003 09:22:26 -0000
@@ -72,10 +72,12 @@
         parse a subitem from <video>
         """
         filename   = fxd.gettext(node)
+        media_id   = fxd.getattr(node, 'media-id')
+        if media_id == '':
+            filename = vfs.join(dirname, filename)
         mode       = node.name
         id         = fxd.getattr(node, 'id')
-        media_id   = fxd.getattr(node, 'media_id')
-        options    = fxd.getattr(node, 'mplayer_options')
+        options    = fxd.getattr(node, 'mplayer-options')
         player     = fxd.childcontent(node, 'player')
         playlist   = False
 
@@ -131,21 +133,7 @@
             id[info[0]] = info
 
         for variant in variants:
-            audio    = fxd.get_children(variant, 'audio')
-            subtitle = fxd.get_children(variant, 'subtitle')
-
-            if audio:
-                audio = { 'media_id': fxd.getattr(audio[0], 'media_id'),
-                          'file'    : fxd.gettext(audio[0]) }
-            else:
-                audio = {}
-
-            if subtitle:
-                subtitle = { 'media_id': fxd.getattr(subtitle[0], 'media_id'),
-                             'file'    : fxd.gettext(subtitle[0]) }
-            else:
-                subtitle = {}
-
+            mplayer_options += " " + fxd.getattr(variant, 'mplayer-options');
             parts = fxd.get_children(variant, 'part')
             if len(parts) == 1:
                 # a variant with one file
@@ -157,26 +145,62 @@
                 if is_playlist:
                     v.is_playlist  = True
 
-                v.subtitle_file = subtitle
+                audio    = fxd.get_children(parts[0], 'audio')
+                if audio:
+                    audio = { 'media_id': fxd.getattr(audio[0], 'media-id'),
+                              'file'    : fxd.gettext(audio[0]) }
+                    if audio['media_id'] == '':
+                        audio['file'] = vfs.join(dirname, audio['file'])
+                else:
+                    audio = {}
                 v.audio_file    = audio
 
+                subtitle = fxd.get_children(parts[0], 'subtitle')
+                if subtitle:
+                    subtitle = { 'media_id': fxd.getattr(subtitle[0], 'media-id'),
+                                 'file'    : fxd.gettext(subtitle[0]) }
+                    if subtitle['media_id'] == '':
+                        subtitle['file'] = vfs.join(dirname, subtitle['file'])
+                else:
+                    subtitle = {}
+                v.subtitle_file = subtitle
+
                 # global <video> mplayer_options
                 if mplayer_options:
                     v.mplayer_options += mplayer_options
             else:
                 # a variant with a list of files
                 v = VideoItem('', parent=item, parse=False)
-                v.subtitle_file = subtitle
-                v.audio_file    = audio
                 for p in parts:
                     ref = fxd.getattr(p ,'ref')
+                    audio    = fxd.get_children(p, 'audio')
+                    subtitle = fxd.get_children(p, 'subtitle')
+    
+                    if audio:
+                        audio = { 'media_id': fxd.getattr(audio[0], 'media-id'),
+                                  'file'    : fxd.gettext(audio[0]) }
+                        if audio['media_id'] == '':
+                            audio['file'] = vfs.join(dirname, audio['file'])
+                    else:
+                        audio = {}
+                        
+                    if subtitle:
+                        subtitle = { 'media_id': fxd.getattr(subtitle[0], 'media-id'),
+                                     'file'    : fxd.gettext(subtitle[0]) }
+                        if subtitle['media_id'] == '':
+                            subtitle['file'] = vfs.join(dirname, subtitle['file'])
+                    else:
+                        subtitle = {}
+
                     sub = VideoItem(id[ref][1], parent=v, parse=False)
-                    sub.mode, sub.media_id, sub.mplayer_options = id[ref][2:]
+                    sub.mode, sub.media_id, sub.mplayer_options, player, is_playlist 
= id[ref][2:]
+                    sub.subtitle_file = subtitle
+                    sub.audio_file    = audio
                     # global <video> mplayer_options
                     if mplayer_options:
                         sub.mplayer_options += mplayer_options
                     v.subitems.append(sub)
-
+ 
             v.name = fxd.getattr(variant, 'name')
             item.variants.append(v)
 
@@ -198,7 +222,7 @@
         for s in video:
             info = parse_video_child(fxd, s, item, dirname)
             v = VideoItem(info[1], parent=item, parse=False)
-            v.mode, v.media_id, v.mplayer_options = info[2:]
+            v.mode, v.media_id, v.mplayer_options, player, is_playlist = info[2:]
             if info[-2]:
                 v.force_player = info[-2]
             if info[-1]:
@@ -207,14 +231,14 @@
             if mplayer_options:
                 v.mplayer_options += mplayer_options
             item.subitems.append(v)
-        
+
     item.xml_file = fxd_file
     fxd.getattr(None, 'items', []).append(item)
 
 
 
 
-    
+
 def parse_disc_set(fxd, node):
     """
     Callback for VideoItem <disc-set>
@@ -244,11 +268,26 @@
 
         # what to do with the mplayer_options? We can't use them for
         # one disc, or can we? And file_ops? Also only on a per disc base.
+        # Answer: it applies to all the files of the disc, unless there
+        #         are <file-opt> which specify to what files the
+        #         mplayer_options apply. <file-opt> is not such a good
+        #         name,  though.
         # So I ignore that we are in a disc right now and use the 'item'
-        item.mplayer_options = fxd.getattr(disc, 'mplayer_options')
-        for f in fxd.get_children(disc, 'file-opts'):
-            opt = { 'file-d': f.getattr(f, 'media-id'),
-                    'mplayer_options': f.getattr(f, 'mplayer_options') }
+        item.mplayer_options = fxd.getattr(disc, 'mplayer-options')
+        there_are_file_opts = 0
+        for f in fxd.get_children(disc, 'file-opt'):
+            there_are_file_opts = 1
+            file_media_id = fxd.getattr(f, 'media-id')
+            if not file_media_id:
+                file_media_id = id
+            mpl_opts = item.mplayer_options + ' ' + fxd.getattr(f, 'mplayer-options')
+            opt = { 'file-id' : file_media_id + fxd.gettext(f),
+                    'mplayer-options': mpl_opts }
             item.files_options.append(opt)
+        if there_are_file_opts:
+            # in this case, the disc/@mplayer_options is retricted to the set
+            # of files defined in the file-opt elements
+            item.mplayer_options = ''
+    
     item.xml_file = fxd_file
     fxd.getattr(None, 'items', []).append(item)
Index: video//videoitem.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/video/videoitem.py,v
retrieving revision 1.100
diff -u -r1.100 videoitem.py
--- video//videoitem.py 6 Dec 2003 16:25:45 -0000       1.100
+++ video//videoitem.py 8 Dec 2003 09:22:26 -0000
@@ -142,12 +142,16 @@
         
         self.possible_player = []
 
+        self.file_id          = ''
+        if parent and parent.media:
+            self.file_id = parent.media.id + 
filename[len(os.path.join(parent.media.mountdir,"")):]
 
         self.filename = filename
         self.id       = filename
 
         if not self.name:
             self.name     = util.getname(filename)
+    
 
         # find image for tv show and build new title
         if config.VIDEO_SHOW_REGEXP_MATCH(self.name) and filename.find('://') == -1 
and \
@@ -170,6 +174,9 @@
                     if not self.xml_file:
                         self.xml_file = tvinfo[3]
                     self.mplayer_options = tvinfo[2]
+                from video import discset_informations
+                if discset_informations.has_key(self.file_id):
+                    self.mplayer_options = discset_informations[self.file_id]
 
                 self.tv_show = True
                 self.show_name = show_name
@@ -457,18 +464,24 @@
             mplayer_options = ""
 
         if self.subtitle_file:
-            d, f = util.resolve_media_mountdir(self.subtitle_file['media-id'],
+            d, f = util.resolve_media_mountdir(self.subtitle_file['media_id'],
                                                self.subtitle_file['file'])
             if d:
                 util.mount(d)
-            mplayer_options += ' -sub "%s"' % f
+            # If we put "" here, they will become part of the name, and the
+            # filename will be wrong.
+            #mplayer_options += ' -sub "%s"' % f
+            mplayer_options += ' -sub %s' % f
 
         if self.audio_file:
-            d, f = util.resolve_media_mountdir(self.audio_file['media-id'],
+            d, f = util.resolve_media_mountdir(self.audio_file['media_id'],
                                                self.audio_file['file'])
             if d:
                 util.mount(d)
-            mplayer_options += ' -audiofile "%s"' % f
+            # If we put "" here, they will become part of the name, and the
+            # filename will be wrong.
+            #mplayer_options += ' -audiofile "%s"' % f
+            mplayer_options += ' -audiofile %s' % f
 
         if arg:
             mplayer_options += ' %s' % arg

Reply via email to