Hello,

I was unable to attach files in the tracker so I am replying to this
email with attachments. I made some changes to the webserver so that
it can make use of child resources instead of creating several links
in /var/cache/freevo. Not that I have anything against having all the
links but it is easier making use of available features of twisted.

In addition I added code to display .jpg file if a fxd file is missing
and the .jpg file matches with the directory or file because that is
how Freevo was doing it. I have some folders where I just have .jpg
files with the name matching the movie file with no fxd and freevo
displays the image but the webserver was not. With the modifications I
made it is much closer to what Freevo does. You might want to add more
formats (.png etc) if you like or I can add them if you tell me which
formats to add.

Finally I changed the way the fxd file is parsed to display
"cover-img", since I am always getting index out of bounds exceptions
for

cover = str(b.attrs.values()[0])

although I am using the fxd file as given in the examples. Freevo is
able to display it fine on my TV. With the code changes I made, I am
not getting any more exceptions.

Please review the code and merge it if you like.

However I could not solve one problem, I am unable to click on
recorded TV programs from webpage. They are not active links. Is
anyone facing the same problem?

Another question I always wanted to ask was, where do all the images
for recorded TV go? There are no jpg files in my recording directory,
but in Freevo I see the cover image. The .fxd files do not have
cover-img tag. It would be nice to show them in the webserver.

Regards,
Chandan


On 12/27/06, SourceForge.net <[EMAIL PROTECTED]> wrote:
Bugs item #1604844, was opened at 2006-11-28 23:08
Message generated for change (Comment added) made by reudeudeu
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=446895&aid=1604844&group_id=46652

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: other
Group: 1.x svn (rel-1)
Status: Open
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Sylvain FABRE (reudeudeu)
Assigned to: Nobody/Anonymous (nobody)
Summary: 1.7RC1 - Webserver issue

Initial Comment:
In 1.7 RC1, the current_path variable in library.rpy and fileinfo.py should 
configurable in a way or another : in my system, freevo runs from a home folder 
and does not rely at all on the /usr/share/freevo folders ...

----------------------------------------------------------------------

>Comment By: Sylvain FABRE (reudeudeu)
Date: 2006-12-27 14:46

Message:
Logged In: YES
user_id=334676
Originator: YES

Custom installation: Freevo is installed in /home/freevo/freevo and there
is no particular log messages in the webserver log.

----------------------------------------------------------------------

Comment By: wout (woutc)
Date: 2006-12-27 14:29

Message:
Logged In: YES
user_id=1421759
Originator: NO

Indeed i misunderstood your issue.

Do you run freevo from a directory or did you install it on your system?
Do you see any error messages in the freevo webserver log file?


----------------------------------------------------------------------

Comment By: wout (woutc)
Date: 2006-12-27 13:53

Message:
Logged In: YES
user_id=1421759
Originator: NO

Indeed i misunderstood your issue.

Do you run freevo from a directory or did you install it on your system?
Do you see any error messages in the freevo webserver log file?


----------------------------------------------------------------------

Comment By: Sylvain FABRE (reudeudeu)
Date: 2006-12-27 13:41

Message:
Logged In: YES
user_id=334676
Originator: YES

??? Ok, but what is the interest of the webserver if it is no tbale to
display the pictures ? Seems to me that you misunderstood my issue : the
cache folders are filled with links, but nothing is displayed in the
webserver interface.

----------------------------------------------------------------------

Comment By: wout (woutc)
Date: 2006-12-27 12:18

Message:
Logged In: YES
user_id=1421759
Originator: NO

it is normal that you do not see the picture because the files in the
cache folder or softlinks to the original image (to save harddisk space)

----------------------------------------------------------------------

Comment By: Sylvain FABRE (reudeudeu)
Date: 2006-12-25 17:47

Message:
Logged In: YES
user_id=334676
Originator: YES

The files seems to be placed in the cache folder, but i do not see any
pictures, only the filename.

----------------------------------------------------------------------

Comment By: Duncan Webb (duncanwebb)
Date: 2006-12-22 10:04

Message:
Logged In: YES
user_id=104395
Originator: NO

They will now go into the FREEVO_CACHEDIR

Please try rel-1 branch at r8787



----------------------------------------------------------------------

Comment By: Duncan Webb (duncanwebb)
Date: 2006-12-20 22:33

Message:
Logged In: YES
user_id=104395
Originator: NO

File Added: fileinfo.rpy.diff

----------------------------------------------------------------------

Comment By: Duncan Webb (duncanwebb)
Date: 2006-12-20 22:32

Message:
Logged In: YES
user_id=104395
Originator: NO

File Added: library.rpy.diff

----------------------------------------------------------------------

Comment By: ryan (ryanroth)
Date: 2006-12-20 22:24

Message:
Logged In: YES
user_id=1196812
Originator: NO

These patches should do the trick.  Just set WWW_PATH in local_conf to the
location desired.  If it is not set it will revert to the default.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=446895&aid=1604844&group_id=46652

-------------------------------------------------------------------------
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-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Index: src/helpers/webserver.py
===================================================================
--- src/helpers/webserver.py    (revision 8820)
+++ src/helpers/webserver.py    (working copy)
@@ -92,6 +92,13 @@

     root = static.File(docRoot)
     root.processors = { '.rpy': script.ResourceScript, }
+    for (item, dir_str) in config.VIDEO_ITEMS:
+        root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
+    for (item, dir_str) in config.AUDIO_ITEMS:
+        root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
+    for (item, dir_str) in config.IMAGE_ITEMS:
+        root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
+    root.putChild(config.TV_RECORD_DIR.replace("/", "_"), 
static.File(config.TV_RECORD_DIR))

     root.putChild('vhost', vhost.VHostMonsterResource())
     rewriter =  rewrite.RewriterResource(root, helpimagesrewrite)

Index: src/www/htdocs/fileinfo.rpy
===================================================================
--- src/www/htdocs/fileinfo.rpy (revision 8820)
+++ src/www/htdocs/fileinfo.rpy (working copy)
@@ -41,6 +41,11 @@
         self.cache_dir = '%s/link_cache/' % (config.FREEVO_CACHEDIR)
         if not os.path.isdir(self.cache_dir):
             os.mkdir(self.cache_dir, 
stat.S_IMODE(os.stat(config.FREEVO_CACHEDIR)[stat.ST_MODE]))
+        self.allowed_dirs = []
+        self.allowed_dirs.extend(config.VIDEO_ITEMS)
+        self.allowed_dirs.extend(config.AUDIO_ITEMS)
+        self.allowed_dirs.extend( [ ('Recorded TV', config.TV_RECORD_DIR) ])
+        self.allowed_dirs.extend(config.IMAGE_ITEMS)

     def _render(self, request):
         fv = HTMLResource()
@@ -87,7 +92,7 @@
             info+='<tr><td><b>Size: 
</b></td><td>'+str((os.stat(file)[6]/1024)/1024)+' MB</td></tr>'
             info+= "</table>"

-            file_link = self.create_file_link(file)
+            file_link = self.convert_dir(file)

             fv.res += (
                u"<script>\n" \
@@ -98,8 +103,8 @@
                u"doc.getElementById('program-waiting').style.display = 
'none';\n" \
                u"doc.getElementById('program-info').style.visibility = 
'visible';\n" \
                u"</script>\n"
-            ) % ( title ,
-                  info,
+            ) % ( title.replace("'", "\\'"),
+                  info.replace("'", "\\'"),
                   "function() { window.open(\"%s\"); }" % (file_link),
             )

@@ -117,12 +122,6 @@

         return String(fv.res)

-    def create_file_link(self, file):
-        cache_link = self.cache_dir + file.replace("/", "_")
-        if not os.path.exists(cache_link):
-            os.symlink(file, cache_link)
-        return cache_link
-
     def get_fxd_info(self, fxd_file):
         fxd_info = {}
         parser = util.fxdparser.FXD(fxd_file)
@@ -130,12 +129,20 @@
         for a in parser.tree.tree.children:
             if a.name == 'movie':
                 fxd_info.update({'title':str(a.attrs.values()[0])})
+            cover = parser.childcontent(a, "cover-img")
+            if cover != '':
+                fxd_info.update({'cover-img':cover})
             for b in a.children:
-                if b.name == 'cover-img':
-                    fxd_info.update({'cover-img':str(b.attrs.values()[0])})
                 if b.name == 'info':
                     for c in b.children:
                         fxd_info.update({str(c.name):str(c.first_cdata)})
         return fxd_info

+    def convert_dir(self, dir_str):
+        for i in range(len(self.allowed_dirs)):
+            val = self.allowed_dirs[i][1]
+            if dir_str.startswith(val):
+                return val.replace("/", "_") + dir_str[len(val):]
+        return dir_str
+
 resource = FileInfoResource()
Index: src/www/htdocs/library.rpy
===================================================================
--- src/www/htdocs/library.rpy  (revision 8820)
+++ src/www/htdocs/library.rpy  (working copy)
@@ -55,19 +55,26 @@
         self.cache_dir = '%s/image_cache/' % (config.FREEVO_CACHEDIR)
         if not os.path.isdir(self.cache_dir):
             os.mkdir(self.cache_dir, 
stat.S_IMODE(os.stat(config.FREEVO_CACHEDIR)[stat.ST_MODE]))
+        self.allowed_dirs = []
+        self.allowed_dirs.extend(config.VIDEO_ITEMS)
+        self.allowed_dirs.extend(config.AUDIO_ITEMS)
+        self.allowed_dirs.extend( [ ('Recorded TV', config.TV_RECORD_DIR) ])
+        self.allowed_dirs.extend(config.IMAGE_ITEMS)

     def is_access_allowed(self, dir_str):
-        allowed_dirs = []
-        allowed_dirs.extend(config.VIDEO_ITEMS)
-        allowed_dirs.extend(config.AUDIO_ITEMS)
-        allowed_dirs.extend( [ ('Recorded TV', config.TV_RECORD_DIR) ])
-        allowed_dirs.extend(config.IMAGE_ITEMS)
-        for i in range(len(allowed_dirs)):
-            val = allowed_dirs[i][1]
+        for i in range(len(self.allowed_dirs)):
+            val = self.allowed_dirs[i][1]
             if dir_str.startswith(val):
                 return TRUE
         return FALSE

+    def convert_dir(self, dir_str):
+        for i in range(len(self.allowed_dirs)):
+            val = self.allowed_dirs[i][1]
+            if dir_str.startswith(val):
+                return val.replace("/", "_") + dir_str[len(val):]
+        return dir_str
+
     def get_suffixes (self, media):
         suffixes = []
         if media == 'music':
@@ -368,7 +375,7 @@
                 if action_mediatype == "music":
                     y = self.cover_filter(mydir)
                     if y:
-                        image_link = self.get_images(mydir + str(y))
+                        image_link = self.convert_dir(mydir + str(y))
                     else:
                         image_link = "images/library/music.png"
                     mydirlink = '<a href="'+ action_script 
+'?media='+action_mediatype+'&dir='+urllib.quote(mydir)+'">'\
@@ -377,11 +384,11 @@
                 elif action_mediatype == "movies":
                     y = self.cover_filter(mydir)
                     if y:
-                        image_link = self.get_images(mydir + str(y))
+                        image_link = self.convert_dir(mydir + str(y))
                     else:
                         image_link = "images/library/movies.png"
                     mydirlink = '<a 
href="'+action_script+'?media='+action_mediatype+'&dir='+urllib.quote(mydir)+'">'\
-                        +'"<img src="' + image_link + '" height="200px" 
width="200px" /><br />'+mydispdir+'</a>'
+                        +'<img src="' + image_link + '" height="200px" 
width="200px" /><br />'+mydispdir+'</a>'
                 ### show image cover
                 elif action_mediatype == "images":
                     image_link = "images/library/images.png"
@@ -409,8 +416,11 @@
             for item in items:
                 #check for fxd file
                 fxd_file = item[:item.rindex('.')] + ".fxd"
+                jpg_file = item[:item.rindex('.')] + ".jpg"
                 if os.path.exists(fxd_file):
                     image = self.get_fxd_cover(fxd_file)
+                elif os.path.exists(jpg_file):
+                    image = jpg_file

                 if i == 0:
                     fv.tableRowOpen('class="chanrow"')
@@ -430,7 +440,7 @@
                     status = 'favorite'
                 ### show image
                 if action_mediatype == "images":
-                    image_link = self.get_images(basedir + "/" + file)
+                    image_link = self.convert_dir(basedir + "/" + file)
                     size = imlib2.open(basedir+"/"+file).size
                     new_size = self.resize_image(image_link, size)
                     fv.tableCell('<a 
href="javascript:openfoto(\''+image_link+'\','+str(size[0])+','+str(size[1])+')">'\
@@ -438,8 +448,9 @@
                         +'<br />'+Unicode(file)+'</a>', 'class="'+status+'" 
colspan="1"')
                 ### show movie
                 elif action_mediatype == "movies":
+                    image_link = self.convert_dir(image)
                     fv.tableCell('<a onclick="info_click(this, event)" 
id="'+filepath+'">'\
-                        +'<img src="'+image+'" height="200px" width="200px" 
/><br />'+Unicode(file)+'</a>',\
+                        +'<img src="'+image_link+'" height="200px" 
width="200px" /><br />'+Unicode(file)+'</a>',\
                         'class="'+status+'" colspan="1"')
                 ### show music
                 elif action_mediatype == "music":
@@ -524,27 +535,32 @@

         return String(fv.res)

-    def get_images(self, file):
-        cache_link = self.cache_dir + file.replace("/", "_")
-        if not os.path.exists(cache_link):
-            os.symlink(file, cache_link)
-        return cache_link
-
     def cover_filter(self, x):
         for i in os.listdir(x):
             cover = re.search(config.AUDIO_COVER_REGEXP, i, re.IGNORECASE)
             if cover:
                 return "/" + i
+            else:
+                fname = x[x.rfind("/"):]
+                fxd_file = fname + ".fxd"
+                cover = self.get_fxd_cover(x + fxd_file)
+                if cover != '':
+                    return "/" + cover
+                else:
+                    jpg_file = fname + ".jpg"
+                    if os.path.exists(x + jpg_file):
+                        return jpg_file

+
     def get_fxd_cover(self, fxd_file):
         cover = ""
         fxd_info = {}
         parser = util.fxdparser.FXD(fxd_file)
         parser.parse()
         for a in parser.tree.tree.children:
-            for b in a.children:
-                if b.name == 'cover-img':
-                    cover = str(b.attrs.values()[0])
+            cover = parser.childcontent(a, "cover-img")
+            if cover != "":
+                break
         return cover

     def resize_image(self, image, size):
@@ -556,6 +572,18 @@
             new_size[1] -= (new_size[1] * 10)/100
         return new_size

+    def resize_image_to_square(self, image, size):
+        ### if aspect ratio > 1 then scale width to 200
+        new_size = [200, 200]
+        if size[0] > size[1]:
+            new_size[0] = 200
+            new_size[1] = new_size[0] * size[1] / size[0]
+        ### else scale height to 200
+        else:
+            new_size[1] = 200
+            new_size[0] = new_size[1] * size[0] / size[1]
+        return new_size

+
 resource = LibraryResource()

-------------------------------------------------------------------------
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-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to