# [ANN] The TivoHMO and TivoHME ruby libraries



## wr0ngway

Hi all,

I officially had too much time on my hands, and being a ruby fan decided to reimplement hmo/hme in ruby:

https://github.com/wr0ngway/tivohmo
https://github.com/wr0ngway/tivohme

I'm a fan of plex for managing my library, and pytivo/hmeforpython for making my library available to my tivos, but was finding it too difficult to use plex as the metadata source for pytivo/hme. Thus I wrote these with a little more separation between components to make it easier to plug/play the bits extenders may care about. The original goal when I started was to have a single media library through plex, and have it exposed to the tivo with hmo, maybe hme, and possibly an opera app. Given the recent work by ntlord ( https://github.com/ntlord/PlexTivo ), I'm not sure if I'll do much with the hme implementation so it remains lacking a test suite, but thought I'd share in case others were interested.

The tivohmo project is mostly complete and tested, but the transcoder is pretty basic. If anyone is more of an expert in all the ffmpeg magic involved in getting video to a form the tivo is looking for, and is looking to contribute, I'd be happy to accept  A way to serve streams to tivo mini's would also be very cool, but have no idea where to start.

This project wouldn't be possible without all the other groundbreaking work done in the other tivo projects (pyTivo, hmeforpython, videomanager, etc), so would like to thank everyone thats contributed to those projects for figuring out all the hard stuff to make my life easier


----------



## davidblackledge

Hah! fun! Thanks for sharing this!


----------



## wr0ngway

Just letting everyone know that I've been continuing to work on my tivohmo app, and its now my daily driver for getting video from my plex server to my tivo

Some Noteworthy features:

Full control of runtime from command line or config file
Application for changing runtime settings of the server from the Tivo UI
Application to serve video to the Tivo from the Filesystem
Application to serve video to the Tivo from a Plex Media Server
Can serve video with on-the-fly hardcoded subtitles from srt files (embedded subs, e.g. mkv, are also supported in plex app)


----------



## Fofer

Sweet! I'm gonna have to give this a try. Thank you!


----------



## wr0ngway

Fofer said:


> Sweet! I'm gonna have to give this a try. Thank you!


Did you get a chance to try it yet? Any problems?


----------



## joeblow8579

I'm getting a strange error when I try to install tivohmo via the instructions on the github site. Here's the error:



Code:


Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: json-1.8.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing tivohmo:
	ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.2/ext/json/ext/generator/gem_make.out

Any ideas why it won't install?


----------



## wr0ngway

Looks like its using the ruby that comes preinstalled with OS X. I've never had much luck with that as its usually woefully out of date. In this case it just looks like the ruby development headers are missing, and thus some binary extensions that tivohmo depends on cannot be compiled. I'm not sure how to get headers for the system ruby, maybe by installing the xcode CLI tools - http://railsapps.github.io/xcode-command-line-tools.html ?

It'll probably end up easier to use rvm to setup a more complete ruby instead:

https://rvm.io/rvm/install

This may help as well:
https://www.ruby-lang.org/en/documentation/installation/


----------



## joeblow8579

Thanks for getting back to me quickly. I installed the Xcode CLI tools and it got through the installation successfully.

For future reference: it might be really helpful to put an example of the syntax of how to get apps running. I'm now trying to decipher the --help command and it's slow going (I've never done anything with plex on the command line, only set up pyTiVo that way, which was quite easy).

edit: I meant an example in the settings file, by the way. That wasn't clear in my initial comments. The examples are there in the --help thingy, but it isn't immediately clear to the novice (which I am) how exactly to properly format them in the .plist file.


----------



## davidblackledge

wr0ngway said:


> Looks like its using the ruby that comes preinstalled with OS X. I've never had much luck with that as its usually woefully out of date.


I think you meant to say "you installed it the wr0ng way."


----------



## wr0ngway

joeblow8579 said:


> For future reference: it might be really helpful to put an example of the syntax of how to get apps running. I'm now trying to decipher the --help command and it's slow going (I've never done anything with plex on the command line, only set up pyTiVo that way, which was quite easy).
> 
> edit: I meant an example in the settings file, by the way. That wasn't clear in my initial comments. The examples are there in the --help thingy, but it isn't immediately clear to the novice (which I am) how exactly to properly format them in the .plist file.


Understood - I work in this stuff all day so I lose perspective on what makes sense for people that don't  Were you able to get it working?

Would be great if you could add something to the wiki https://github.com/wr0ngway/tivohmo/wiki or add to the comments in the config file (via fork + pull request) https://github.com/wr0ngway/tivohmo/blob/master/contrib/tivohmo.yml


----------



## wr0ngway

davidblackledge said:


> I think you meant to say "you installed it the wr0ng way."


Heh, yeah, my nick usually applies more to what I'm doing than others


----------



## joeblow8579

wr0ngway said:


> Understood - I work in this stuff all day so I lose perspective on what makes sense for people that don't  Were you able to get it working?
> 
> Would be great if you could add something to the wiki https://github.com/wr0ngway/tivohmo/wiki or add to the comments in the config file (via fork + pull request) https://github.com/wr0ngway/tivohmo/blob/master/contrib/tivohmo.yml


Actually no. I tried adding what I thought was the right stuff to the .plist file but ended up with an error saying:



Code:


[2015-04-17T20:32:11] INFO  TivoHMO::Config No primary config at file: ''
[2015-04-17T20:32:11] INFO  TivoHMO::Config No secondary config at file: ''
[2015-04-17T20:32:11] INFO  TivoHMO::CLI TivoHMO 0.3.1 starting up
ERROR: at least one application is required

See: 'tivohmo --help'

In my settings file I added some commands like this: <string>-t "Movies"</string> with the names of my Plex channels. I'm still not entirely clear on what needs to be added to the .plist to tell it what to do.


----------



## wr0ngway

joeblow8579 said:


> Actually no. I tried adding what I thought was the right stuff to the .plist file but ended up with an error saying:


Ok, if you ran "tivohmo --install" it should have installed the plist for running tivohmo into "~/Library/LaunchAgents/tivohmo.plist" and the config file into "~/Library/Preferences/tivohmo.yml" If you run it again, it will overwrite any mods you have made.

You shouldn't need to edit the plist as all it does is run tivohmo with the config file. You shouldn't need to edit the config file either as it should have working defaults.

To run tivohmo using the plist:
launchctl load ~/Library/LaunchAgents/tivohmo.plist

To stop it:
launchctl unload ~/Library/LaunchAgents/tivohmo.plist

Note this tells OSX this program is a daemon, and it will keep it running after crashes/reboot/etc

You can verify its running with a command like (or use Activity Monitor):
ps ax | grep [t]ivohmo

Note if the number on the left (the pid) keeps changing, it means that tivohmo keeps dying and restarted, so something is probably wrong, and you can debug with the logfile at:
~/Library/Logs/tivohmo.log


----------



## joeblow8579

wr0ngway said:


> Ok, if you ran "tivohmo --install" it should have installed the plist for running tivohmo into "~/Library/LaunchAgents/tivohmo.plist" and the config file into "~/Library/Preferences/tivohmo.yml" If you run it again, it will overwrite any mods you have made.
> 
> You shouldn't need to edit the plist as all it does is run tivohmo with the config file. You shouldn't need to edit the config file either as it should have working defaults.
> 
> To run tivohmo using the plist:
> launchctl load ~/Library/LaunchAgents/tivohmo.plist
> 
> To stop it:
> launchctl unload ~/Library/LaunchAgents/tivohmo.plist
> 
> Note this tells OSX this program is a daemon, and it will keep it running after crashes/reboot/etc
> 
> You can verify its running with a command like (or use Activity Monitor):
> ps ax | grep [t]ivohmo
> 
> Note if the number on the left (the pid) keeps changing, it means that tivohmo keeps dying and restarted, so something is probably wrong, and you can debug with the logfile at:
> ~/Library/Logs/tivohmo.log


So I started over by installing again, and I didn't make any changes to either file. I loaded the launch agent and now it appears to be working. I am able to see the TiVoHMO shares in My Shows on the TiVo.

However, when I browse to a show or movie, the various folders that contain the media show up on the tivo as empty, with no content.

I briefly looked through the tivohmo.log file but didn't see any obvious errors kicked out by the program.


----------



## wr0ngway

joeblow8579 said:


> However, when I browse to a show or movie, the various folders that contain the media show up on the tivo as empty, with no content.


By empty, do you mean they have a (0) beside them? Or do you mean that when you browse into them they have no contents? The reason I ask is that I made an optimization for slower systems so that the counts don't get updated till you browse down into them, so try to browse into them if you didn't already


----------



## joeblow8579

wr0ngway said:


> By empty, do you mean they have a (0) beside them? Or do you mean that when you browse into them they have no contents? The reason I ask is that I made an optimization for slower systems so that the counts don't get updated till you browse down into them, so try to browse into them if you didn't already


They show a (0) but when I actually browse into them it gives me the "This Group is now empty. Press LEFT to return to the My Shows List." message.

I've tried browsing into Movies by "All" as well as by several of the other criteria listed there. They all appear empty.


----------



## wr0ngway

joeblow8579 said:


> They show a (0) but when I actually browse into them it gives me the "This Group is now empty. Press LEFT to return to the My Shows List." message.


Does it sit for a while before deciding its an empty group? How large a library do you have? It could just be timing out while loading the details for a really large library, but if you go back later it will be populated.

You do have content in the plex library running on the same host as tivohmo, correct?

Other than, I could take a look at the log and see if I see anything.


----------



## joeblow8579

wr0ngway said:


> Does it sit for a while before deciding its an empty group? How large a library do you have? It could just be timing out while loading the details for a really large library, but if you go back later it will be populated.
> 
> You do have content in the plex library running on the same host as tivohmo, correct?
> 
> Other than, I could take a look at the log and see if I see anything.


I have a fairly large library, but I've tried navigating to folders with just one or two things in them and seen no difference.

It doesn't seem to take very long to decide that folders are empty. Maybe a few seconds at the most. Should I email you the log file?


----------



## wr0ngway

joeblow8579 said:


> I have a fairly large library, but I've tried navigating to folders with just one or two things in them and seen no difference.
> 
> It doesn't seem to take very long to decide that folders are empty. Maybe a few seconds at the most. Should I email you the log file?


Email is fine, or a shard link to dropbox or create a github issue or gist to hold it


----------



## joeblow8579

wr0ngway said:


> Email is fine, or a shard link to dropbox or create a github issue or gist to hold it


Apparently I need 10 posts to send PM's. This is my tenth (pointless) post.


----------



## joeblow8579

PM sent with a link to the log file.


----------



## wr0ngway

Ok, got it.
The first error that jumps out at me is:

2015-04-20 12:56:30 - Errno::ENOENT - No such file or directory - the ffprobe binary could not be found in /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:

Which tells me that either ffmpeg/ffprobe isn't in your path or you are using an older version that doesn't have ffprobe

Can you run "ffmpeg -v" or "ffprobe -v" on the command line?


----------



## joeblow8579

wr0ngway said:


> Ok, got it.
> The first error that jumps out at me is:
> 
> 2015-04-20 12:56:30 - Errno::ENOENT - No such file or directory - the ffprobe binary could not be found in /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:
> 
> Which tells me that either ffmpeg/ffprobe isn't in your path or you are using an older version that doesn't have ffprobe
> 
> Can you run "ffmpeg -v" or "ffprobe -v" on the command line?


Good call. I forgot I had reinstalled OS X a few months ago when I put the SSD into this machine and had only had ffmpeg in my pytivo folder. I copied it into /usr/bin and now when I type ffmpeg -v from the command line it actually gives output other than "command not found".

I get this:


Code:


ffmpeg version 2.5.3-tessus Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 10 2015 01:19:50 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --cc=/usr/bin/clang --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-libsoxr --enable-libwavpack --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-libmodplug --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --disable-indev=qtkit --disable-indev=x11grab_xcb --enable-runtime-cpudetect
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Missing argument for option 'v'.
Error splitting the argument list: Invalid argument

Still empty folders in tivoHMO though.


----------



## joeblow8579

I get this when typing "ffprobe -v" at the command line:



Code:


-bash: ffprobe: command not found

I notice that the numbers next to the folders when browsing from the TiVo do in fact update after I tunnel into them, but I still can't see anything in the folders when I navigate there. Is this related to not having ffprobe as a part of my ffmpeg version?


----------



## wr0ngway

joeblow8579 said:


> Is this related to not having ffprobe as a part of my ffmpeg version?


Correct - I should probably handle that more gracefully, but basically it uses ffprobe to figure out duration of the video so that it can be transferred correctly - and it tries to do this for each video when you dig in, and fails/aborts on the first one. Once you have ffprobe available, it should show your videos.

I usually use homebrew to keep up to date with the latest ffmpeg on OSX:

http://brew.sh/

then:

brew install ffmpeg


----------



## joeblow8579

I was able to get it working with home-brew. I'd already installed it to get the latest version of Ruby, so all I had to do was load up the latest ffmpeg via the command line as you said.

Now all we need is a front end that looks pretty and my wife will be happy with my "one box to rule them all" strategy. My kingdom for a fast native Plex app from TiVo...

Does TiVo not let us use high definition menus for things? I notice that pytivo as well as the tivohmo you made use the old style menus.


----------



## wmcbrine

joeblow8579 said:


> Does TiVo not let us use high definition menus for things? I notice that pytivo as well as the tivohmo you made use the old style menus.


HMO menus are rendered _by the TiVo_, based on simple XML lists of items; and yeah, they've chosen not to update those menus, for whatever reason.

HME lets us use HD and do anything we want, but we have to do it all ourselves (and of course, it doesn't work as a front-end for pulling videos).


----------

