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. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    Thanks windracer - and yes I changed my perspective. I'm a software developer by profession, and there's nothing worse that the pressure I feel when there is a field issue and the customer is waiting (sometimes impatiently) for a fix. I just didn't want that feeling to permeate a hobby.

    Instead, what I find is that everyone has been tremendously supportive and it has actually turned somewhat gratifying to accommodate their wants.

    With that said, version 0.3 of vidmgr is available at git (follow the link in my signature).

    With this fix:
    1) I think I fully fixed the problem reported by reneg,
    2) I added sort option to the config.ini file
    sort=file will sort on the file name only
    sort=episodenumber will sort on the episode number
    if omitted or set to 'normal' it will use today's sort method of 'title:episodetitle'
    3) I added the display option to config.ini:
    display=file will show the file name only
    display=eptitle will show the episode title only
    display=epnumtitle will show the combination of ep number and title
    if omitted or set to 'normal' it will use today's method of 'title:episdoetitle'

    Note that for the last two new options, if the indicated meta data is missing, the program will move on to the title, and ultimately the filename, in order to have something to display/sort.

    I have to put in a caveat here - I DID do some testing, but I don't have all of the testing rigs that you guys have so I am relying on you to help me identify any bugs.
     
  2. windracer

    windracer joined the 10k club

    11,580
    3
    Jan 3, 2003
    St. Pete, FL
    We're here for ya! :up:
     
  3. jcthorne

    jcthorne Active Member

    2,721
    3
    Jan 28, 2002
    Houston
    Too Cool. Installed and had the wife try it. (if there is a bug, she will fall right into it)

    Works for me as discribed. GREAT. Thanks.

    One minor I ran into from your post above. The setting is:
    display=episodenumtitle
    as stated in your readme not
    display=epnumtitle
    as posted above.

    Once I fixed that, it worked as intended.

    I'll drive it a bit further when I get home tonight but looks great from here. (installed remotely during my lunch hour and tried it out via sling...)
     
  4. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    Thanks for the input - I'm glad it's holding up for you and hope it continues to do so.
     
  5. reneg

    reneg Member

    699
    0
    Jun 19, 2002
    Works great, thanks for the update.

    At first I thought there was a bug in the display sorting, but I discovered some metadata issues with some of my older files. Title keyword had been set to the same as EpisodeTitle. Changing Title to SeriesTitle fixed the display sorting.
     
  6. windracer

    windracer joined the 10k club

    11,580
    3
    Jan 3, 2003
    St. Pete, FL
    The sorting is definitely cool. Since episodenumtitle is a character sort, it's not that useful to me (episode 6 appears after 11) but since all of my episodic filenames are in SxxEyy format, using the file sort with just episodetitle for the display works great.

    One thing I noticed is that vidmgr doesn't show the metadata for .TiVo files like pyTivo does (using tdcat). I guess I just need to generate separate metadata files for those I keep in .TiVo format.
     
  7. txporter

    txporter One sec, almost done

    666
    0
    Sep 17, 2006
    Austin, TX
    The changes sound excellent! I will give them a whirl this weekend. Thanks for your speedy updates!
     
  8. reneg

    reneg Member

    699
    0
    Jun 19, 2002
    My episode numbers are formatted by season & episode <s><ee>. I did have to zero pad a series than ran for more than 10 seasons in order to get it to show up the way I wanted.

    1) I did run across a minor bug. Vidmgr crashed when it encountered the following filename and metadata file for House.S03E06-Que Será Será.avi. I worked around it by renaming to House.S03E06-Que Sera Sera.avi. What's interesting is that both pyTivo & Streambaby handle the filename and metadata ok. Here is the traceback from the crash:
    Code:
    ----------------------------------------
    Exception happened during processing of request from ('192.168.1.92', 56379)
    Traceback (most recent call last):
      File "c:\python26\lib\SocketServer.py", line 558, in process_request_thread
        self.finish_request(request, client_address)
      File "c:\python26\lib\SocketServer.py", line 320, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "start.py", line 141, in __init__
        client_address, server)
      File "c:\python26\lib\SocketServer.py", line 615, in __init__
        self.handle()
      File "c:\python26\lib\BaseHTTPServer.py", line 329, in handle
        self.handle_one_request()
      File "c:\python26\lib\BaseHTTPServer.py", line 323, in handle_one_request
        method()
      File "start.py", line 232, in do_GET
        self._page(True)
      File "start.py", line 186, in _page
        appinst.mainloop()
      File "C:\pyhme\hme.py", line 1139, in mainloop
        while self.active and self.get_event():
      File "C:\pyhme\hme.py", line 1192, in get_event
        handle(keynum, rawcode)
      File "C:\pyhme\vidmgr\__init__.py", line 223, in handle_key_press
        self.handle_key_pressShares(keynum, rawcode)
      File "C:\pyhme\vidmgr\__init__.py", line 387, in handle_key_pressShares
        self.createListing()
      File "C:\pyhme\vidmgr\__init__.py", line 1069, in createListing
        meta = metadata.from_text(fullpath)
      File "C:\pyhme\metadata.py", line 60, in from_text
        path, name = os.path.split(unicode(full_path, 'utf-8'))
    UnicodeDecodeError: 'utf8' codec can't decode bytes in position 49-51: invalid d
    ata
    ----------------------------------------
    2) Out of habit, I use the clear key when I want to delete something. Hitting the clear key under vidmgr exits vidmgr. I wouldn't mind if it initiated a delete, but could it at least just boink instead of exit?

    3) Please consider making the 2nd part of the advance key work like it does on tivo. The first part works great, it takes you to the end of the list. The second part of the advance key is that when you are at the bottom of a list and hit the advance key, it takes you to the top of the list.

    Really liking this program.
     
  9. txporter

    txporter One sec, almost done

    666
    0
    Sep 17, 2006
    Austin, TX
    Showed it to my wife last night. She was impressed. Thanks for the nice code! I really like the sorting and display title options. Just what I was looking for.
     
  10. dcrowell77

    dcrowell77 New Member

    50
    0
    Dec 27, 2007
    Cool program! One minor feature request - it would be nice if there was some sort of visual acknowledgement that you sent a push successfully. I was playing around with it muted (someone was taking a nap) and I couldn't tell that the program actually accepted my button press.

    Thanks for the work!
     
  11. txporter

    txporter One sec, almost done

    666
    0
    Sep 17, 2006
    Austin, TX
    It does. It says something along the lines of 'Queued for Push to (Tivoname)'.
     
  12. dcrowell77

    dcrowell77 New Member

    50
    0
    Dec 27, 2007
    Odd... I didn't see any such message. Though I did see something when it got an error.

    And speaking of errors... I got an error message (it said error from pytivo) trying to push files to my TiVoHD box. The same files worked fine on my Series 2. Interestingly, the pushes actually worked just fine. I couldn't see any errors on the pyTiVo console. I'm wondering if there might be a timing issue or something throwing things off (or maybe I just have an old version of pytivo). The files in question happened to be mp4 files that were transferable without transcoding to my TiVoHD.
     
  13. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    It does say 'queued for push to tivoname', but basically all I'm doing here is some simple parsing of the returne message I get back from pytivo, There might be some set of circumstances I didn't anticipate. If you DO get an error message, please get me the exact wording and I can see if I can reproduce it.

    I will look at the two issues reneg reported when I get back home on Tuesday - the file naming issue and the clear key. Regarding the second hitting of the advance key, I didn't realize that it did that on the tivo (and I've been using them for 11 years). I programmed the instant replay button to do just that, but I ought to be able to add the logic you're looking for for the advance key too.
     
  14. orangeboy

    orangeboy yes, I AM orangeboy!

    4,083
    0
    Apr 19, 2004
    East Moline, IL
    I have installed a user defined Service for HME for Python (hosting the pyTivo Video Manager app) using Windows Resource Kit tools: "Instsrv.exe" and "Srvany.exe", and Window's native command: Regedit.exe. Be sure to read the footnotes!

    Install a basic Service using Instsrv.exe and Srvany.exe, using the syntax "Instsrv.exe <Service Name> "<Full path to Srvany.exe>"¹:
    Code:
    Start > Run > Instsrv.exe  HME-Python  "C:\path\exes\srvany.exe"
    
    Use Regedit.exe to define Srvany.exe application parameters:
    Code:
    Start > Run > Regedit
    
    Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HME-Python
    
    Right-click in the right window pane > New > Key
    
    Name the new Key²: Parameters
    
    Select the Parameters Key in the left window pane
    
    Right-click in the right window pane > New > String Value
    
    Name the new REG_SZ string²: Application
    
    Right-click the new Application string > Modify
    
    Enter the path to Python.exe, followed by the path to Start.py³: 
    "C:\Python26\python.exe" "D:\Program Files\HME Python\start.py"
    
    Close Regedit
    
    All the parts should be in place for the new Service. Now just need to start it:
    Code:
    Start > Run > Services.msc
    
    Find "HME-Python" in the list of Services
    
    Right-click HME-Python > Start
    
    There may be third party apps that make this process a whole lot easier, but I had the Resource Kit Tools already installed, so I used what I had available. You can get both Instsrv.exe and Srvany.exe by themselves in a .zip file here if you didn't want to get the full-blown ResKit Tools. SC.exe is another tool that can configure Windows Services, adding dependencies, changing Display Name, and adding Account information (if needed).

    Footnotes:
    ¹Both Instsrv.exe and Srvany.exe are found in my %path%, but Instsrv.exe requires the full path to the executable in it's options. You will have to specify the path to Instsrv.exe if it is not found in the %path% search order.

    ²Both "Parameters" and "Application" are required registry entries for Srvany.exe, and may be case sensitive.

    ³Your path to Python.exe and Start.py will have to be adjusted accordingly.
     
  15. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    Um, OK. I'm writing the /etc/init.d startup script for pyhme and updating the one for pyTiVo to better meet the standards established for System V scripts. Is there a need (considering vidmgr or any other utility) to restart pyhme if pyTiVo is hard restarted?
     
  16. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    It depends on the reason for the restart. The only actual interface between vidmgr and pytivo is the pytivo http interface - I post requests there to push a video. My program doesn't know the status of the pytivo daemon - it just sends a message there and hope it gets a response.

    So the bottom line is that if nothing has changed in the pytivo config, then no vidmgr restart is necessary. If, on the other hand, pytivo is suddenly listening to a different port or if additional shares are created (for example), then vidmgr will need to reread its configuration, and perhaps the best/easiest way to do that will be to restart the process.
     
  17. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    Reneg:

    I'm not quite sure why this works for you in pytivo. I don't know about streambaby, but the metadata.py file you include in your trace above borrows heavily from the metadata.py file that is part of pytivo, and in fact the line in question is verbatim from pytivo (or at least the version I'm using - perhaps it's old).

    The problem is that it is trying to convert the filename to a unicode string with utf-8 encoding and the filename contains characters that do not conform to that spec. I'm not sure why I'd want to do this because the filenames I am using are, in fact, file names I have read off of the disk itself. It seems to me I should be using the filenames verbatim (as I said - I did not write the metadata file - it was "derived" from pytivo).

    I'm going to try just removing the unicode calls on this (and one other) line of code to see what happens.
     
  18. ajayabb

    ajayabb Member

    429
    0
    Jan 11, 2007
    Moorestown NJ
    I got the same error message "Pytivo Push error" with an h.264 mp4 file. The file still transferred but I also wonder if it was a timing issue.
     
  19. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    When you use the pytivo web interface and push a video, what does the resultant web page look like? Mine looks like this:

    Code:
    Queued for Push to Master Bedroom
     
    /Movies/Family/Disney/Shorts/Day and Night.mp4
    
    The page will reload in 5 seconds.
    
    vidmgr basically uses the same HTTP interface to make its push request, and then literally looks for the string 'queue' in a case insensitive manner in the response. If it finds 1 or more occurrences, it assumes that the push went OK. Otherwise it gives the above generic error message.

    Perhaps you are using an different version of pytivo where the wording is different? Try it with a browser and let me know what you get. I can perhaps make the code accept additional text to indicate a success.
     
  20. wmcbrine

    wmcbrine Ziphead

    10,368
    22
    Aug 2, 2003
    The HME protocol only speaks UTF-8 (or ASCII, which is a proper subset of UTF-8). It's not meaningful to say "using the filenames verbatim" -- verbatim in what character set? In Windows, that's usually Windows-1252 (a minor variant of Latin-1), if you're using the 8-bit APIs. Throw that at the TiVo, and it will barf.

    pyTivo mostly uses Unicode APIs -- except, for certain things, in Windows -- but uses UTF-8 internally to save memory.
     

Share This Page