1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PyTivo Video Manager HME App for pyhme

Discussion in 'Developers Corner' started by jbernardis, Apr 20, 2011.

  1. lrhorer

    lrhorer New Member

    6,922
    0
    Aug 31, 2003
    San...
    Almost all of my thumbnails are taken from cover art, and so approximate a portrait layout. There are a number of exceptions. In addition to the photos above, which are thumbnails taken from some slideshows I produced using my own photographs, there are the following, none of which are portrait aspects:

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    My preference would be not to scale the images at all.
     
  2. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    That's all fine, but I'm not really talking about scaling. In the HME model, I have to define rectangular areas of the screen (called views) into which I place resources (such as text or images). Now these views CAN overlap, but I have certain aspets of the screen that need to be visible. The bottom line is that I need to devote a retangular area of the screen to these images and I don't want it to overlap with any of the other "controls". The question is do you want that to be landscape or portrait.

    As far as scaling, I can change the scaling so that it only scales DOWN if images are too big. Aspect ratio will always be maintained.
     
  3. lrhorer

    lrhorer New Member

    6,922
    0
    Aug 31, 2003
    San...
    That's a very reasonable argument. I counter, however, by pointing out that the user generally spends very little time with the sub-menu up. Most of the time is spent browsing the video list to decide which video(s) to transfer (or delete if the user has that funtion enabled - I don't). When the decision is made, the transfer is selected in a few moments and the user continues on browsing the list, or else exits vidmgr. As a test, I changed the view frame in your code to 600 pixels and selected a couple of shows to transfer. The small selection images dutifully popped up over the middle-ground photo for selection. It was not in the least objectionable, and the middle-ground photos were displayed in all their glory.

    Of course, it is entirely your call, but my definite preference would be to allow the user to set / create whatever size and aspect he wanted for each individual photo, and have the system simply crop the picture (the way your code did originally) and not worry about the aspect. Even with thumbnails that are more nearly portrait aspect, re-sizing them produces some unpleasant results. That, and 444 pixels is too large for the height, IMO. It causes the photos to protrude down below the title frame, which causes the screen to look lopsided.
     
  4. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    We're both responding at the same time and our responses are criss-crossing :)

    SO you're saying that when you made the view for the thumbnails the full width of the screen, that the submenus overlapping the image was not objectionable.

    Actually looking at the code, it's only because I defined the thumbnail view BEFORE the submenu views that the submenu was even visible. But that''s OK - we can take advantage of that fact, even though that's not why it was done like this.

    If I do this, It would remove the PIL dependency and quicken the response time a bit when navigating because there is less image processing going on. At the same time, it allows for more dramatic thumbnails as you showed.

    Ok - you convinced me - but I need to unplug for a while - maybe tomorrow :)

    Back when I had to be convinced that I should share this app, the argument was made that the community would help make it better. If it was just me using it, I would have been happy with the SD text-based version. Looking back over the past couple of weeks, I'd have to say this has been a great ride. I'd glad so many people are enjoying using this app. I just hope that it eventually settles down to where it changes a little less often.
     
  5. lrhorer

    lrhorer New Member

    6,922
    0
    Aug 31, 2003
    San...
    That's clear.

    That isn't. What's wrong with a control being on top of an image? Certainly all the controls are on top of the background image, so how is a middle-ground image so different? Fundamentally, what's wrong with this:

    [​IMG]

    That's how it wound up looking - more or less - in my test.

    I think that's better than stretching.
     
  6. reneg

    reneg Member

    699
    0
    Jun 19, 2002
    I prefer portrait as most of my files are tv series related and I've been pulling poster images from thetvdb.com which fits within your thumbnail boundaries.

    Just an idea if I might offer up a possible alternative, in each directory (or video file) check for a backgroundHD file in the directory or filename.backgroundHD. That could give up to 1280x720 pixels for whatever image the user want.
     
  7. lrhorer

    lrhorer New Member

    6,922
    0
    Aug 31, 2003
    San...
    Kind of like chat, isn't it.

    Yeah, see above. Another one of my criss-crossed mesages. :eek:

    Serendipity.

    Yeah the PIL issue doesn't really bother me - personally at least - since PIL is automatically included with my distro. I don't know about the Windows and Mac folks, or even other Linux distros. The image processing time is a little more of a philosophical concern, although on this system it's not objectionable. The last bit, obviously, pushes a button for me.

    Take all weekend, if you ask me. You deserve a break.

    Yeah, for a guy who said he didn't want to develop or support the app, you are sure doing a good imitation of both. :D

    We are. I hope it's been fun for you. On that note, are you accepting donations?

    I think it will, quickly. Realize, too, that there is nothing forcing you to meet any schedule. If you want to delay implementing a feature, or even refuse to implement it altogether, you should not feel any compulsion to second guess yourself just because we want it. I figure you've got to be experiencing the onset of burn-out.
     
  8. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    Actually - I had to see it for myself - it was really a trivial change - it's already on git as version 0.5f - is this a record yet?

    No donations please!! I do this for fun.

    But like I trid to say earlier - all of the suggestions - especially yours, have helped to turn what was a pretty mediocre app into one I am proud of. Yes it's approaching burn out. My wife has forgotten what I look like (and vice-versa) but when I get into something like this, I get consumed.
     
  9. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    Have no fear - with the changes made, your portrait images will be unchanged. Actually as I say this, I seem to think that they'll be centered in the larger window - and I was right - I just verified that by checking on my tivo. Actually though, the centered image was not upsetting.

    If people want, though, I can make a simple change to left justify the image so it looks like it did before.
     
  10. lrhorer

    lrhorer New Member

    6,922
    0
    Aug 31, 2003
    San...
    I wouldn't think so.

    I think I prefer the left-justified, but it's a mild preference. Centered is fine.
     
  11. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    Ok - this is it - at least for today. And to show a sense of finality, I'm bumping the version number, not the letter - version 0.6 is on git.

    This one corrects the left justification oversight from the last version. Images are now, by default, left justified. HOWEVER, I also added a config.ini option, thumbjustify, that can be set to center or right if you want that. If you omit this, it will default to left.

    Goot night everyone :)
     
  12. jcthorne

    jcthorne Active Member

    2,718
    2
    Jan 28, 2002
    Houston
    I am having some diffeculty in getting vidmgr (and PythonHME) to run properly on my Synology NAS. Its strange. If I execute the following at an SSH command line:

    python /usr/local/pythonHME/start.py

    It starts normally with the response text shown in the SSH session. Running through the menus on the tivo it works normally. However pythonHME stops when I exit the SSH session.

    If i use this command in a startup script executed at bootup:

    /opt/bin/python /usr/local/pythonHME/start.py > /dev/null 2>&1 &

    It starts pythonHME but ignores the config.ini file as if it cannot read it. Starts all apps, rather than just vidmgr listed in the apps section and vidmgr bombs if its called from the tivo, likely because its missing information from the config.ini file like path and pytivo location etc.

    Suggestions?
     
  13. orangeboy

    orangeboy yes, I AM orangeboy!

    4,083
    0
    Apr 19, 2004
    East Moline, IL
    Could you use image.size to determine the dimensions of the image, and choose orientation dynamically?

    Code:
    width=image.size[0] 
    height=image.size[1]
    
    if width > height:
        orientation=landscape
    else:
        orientation=portrait
    
     
  14. windracer

    windracer joined the 10k club

    11,580
    3
    Jan 3, 2003
    St. Pete, FL
    Maybe make sure in your script you 'cd' into your pyhme directory first? In my startup script, I do this:
    Code:
        cd /etc/tivo/pyhme
        /etc/tivo/pyhme/start.py > /var/log/pyhme.log 2>&1 &
     
  15. orangeboy

    orangeboy yes, I AM orangeboy!

    4,083
    0
    Apr 19, 2004
    East Moline, IL
    Yeah, I had issues with start.py and/or installed apps finding the config file when invoking start.py outside it's directory. Adding in a cd command clear things right up for me (on Windows).
     
  16. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    The final (for now) design that I ended up with just drops the image into the view whatever its orientation - no scaling. The view is no longer 320X444 - it is now 620x450 - basically the entire lower right. If you have portrait thumbs that fit into the old view - nothing will change - they will be top/left justified in the view and appear the same. If you have larger (and wider) images, then as much as possible will fit into the viewport - this will allow for landscape images also. The difference is that for these wide images, the push/delete/tivo buttons COULD overlay the actual image.
     
  17. jcthorne

    jcthorne Active Member

    2,718
    2
    Jan 28, 2002
    Houston
    tried your suggestion. No Go. Here is my startup script called startHME.sh:

    Code:
    `sleep 60`
    cd /usr/local/pythonHME
    /opt/bin/python /usr/local/pythonHME/start.py > /dev/null 2>&1 &
    Is the name of the folder start.py is located in significant? I notice yours is /pyhme

    I ran the script from a command line and get this feedback:

    Code:
    : not foundtc/rc.d/startHME.sh: line 1: 
    /usr/syno/etc/rc.d/startHME.sh: cd: line 2: can't cd to /usr/local/pythonHME
    : not foundtc/rc.d/startHME.sh: line 3:
    after this start.py is running but again did not ready the config.ini file
     
  18. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    The name of the pyhme folder is not significant, but all of the apps, including vidmgr, should be off of that directory and must be named the same as the application class in the __init__.py file (vidmgr) in my case.

    Try running it without throwing away your output - or redirect it to a real file - to see what is says.
     
  19. lrhorer

    lrhorer New Member

    6,922
    0
    Aug 31, 2003
    San...
    I do this:

    Code:
    #! /bin/bash
    PIDFILE=/var/run/pyHME.pid
    RUNDIR=/usr/share/pyhme
    LOGFILE=/var/log/pyhme.log
    cd $RUNDIR
    /usr/bin/nohup $RUNDIR/start.py > $LOGFILE 2>&1 &
    echo $! > $PIDFILE
    exit 0
    This in turn is called from the startup script:

    Code:
    RAID-Server:/usr/share/pyhme# cat /etc/init.d/pyHME 
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          pyHME
    # Required-Start:    $remote_fs $syslog $network $pyTivo
    # Required-Stop:     $remote_fs $syslog $network $pyTivo
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: HME Services
    # Description:       Provides HME services for TiVo
    #
    ### END INIT INFO
    
    # Author: Leslie Rhorer
    
    # Do NOT "set -e"
    
    # PATH should only include /usr/* if it runs after the mountnfs.sh script
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    DESC="HME Services"
    NAME=pyHME
    DAEMON=/usr/share/pyhme/$NAME
    DAEMON_ARGS=""
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    
    # Exit if the package is not installed
    [ -x "$DAEMON" ] || exit 0
    
    # Read configuration variable file if it is present
    [ -r /etc/default/$NAME ] && . /etc/default/$NAME
    
    # Load the VERBOSE setting and other rcS variables
    . /lib/init/vars.sh
    
    # Define LSB log_* functions.
    # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
    # and status_of_proc is working.
    . /lib/lsb/init-functions
    
    #
    # Function that starts the daemon/service
    #
    do_start()
    {
            # Return
            #   0 if daemon has been started
            #   1 if daemon was already running
            #   2 if daemon could not be started
            if [ -e "$PIDFILE" ];
            then
                    PIDVAL=$( cat $PIDFILE )
                    ps -ef | grep $PIDVAL | grep -qv grep && return 1
                    rm $PIDFILE
            fi
            start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON || return 2
    }
    
    #
    # Function that stops the daemon/service
    #
    do_stop()
    {
            # Return
            #   0 if daemon has been stopped
            #   1 if daemon was already stopped
            #   2 if daemon could not be stopped
            #   other if a failure occurred
            if [ -e $PIDFILE ];
            then
                    PIDVAL=$( cat $PIDFILE )
                    rm -f $PIDFILE
                    kill -15 $PIDVAL 2> /dev/null
                    return "$?"
            else
                    return 1
            fi
    }
    
    case "$1" in
      start)
            [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
            do_start
            case "$?" in
                    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
            esac
            ;;
      stop)
            [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
            do_stop
            case "$?" in
                    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
            esac
            ;;
      restart)
            #
            # If the "reload" option is implemented then remove the
            # 'force-reload' alias
            #
            log_daemon_msg "Restarting $DESC" "$NAME"
            do_stop
            case "$?" in
              0|1)
                    do_start
                    case "$?" in
                            0) log_end_msg 0 ;;
                            1) log_end_msg 1 ;; # Old process is still running
                            *) log_end_msg 1 ;; # Failed to start
                    esac
                    ;;
              *)
                    # Failed to stop
                    log_end_msg 1
                    ;;
            esac
            ;;
      *)
            #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
            echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
            exit 3
            ;;
    esac
     
  20. lrhorer

    lrhorer New Member

    6,922
    0
    Aug 31, 2003
    San...
    Use nohup to prevent the process from terminating when the shell quits. Normally, a spawned process is assigned the calling shell as the parent. Nohup causes the process to be assigned init ( PID 1) as the parent.
     

Share This Page