# announcing jukebox - an mp3 player for pyhme



## jbernardis

I have just put up on GIT a python MP3 player that runs under wmcbrine's pyhme framework. Several of the design features for this were "borrowed" from harmonium, and I would like to acknowledge that product and its authors. I just needed something that wasn't java-based.

I've mentioned that I have been working on this for some time now, and since I just recently solved the problem I had with it not working under pyhme 0.19, I decided it was time to release it. Even though I am calling it 1.0, it's somewhat early in its testing phase. Get it from the link in my signature and give it a try.

One note - I wrote it to support HD resolution only. If there is sufficient outcry for SD support, I'll consider it


----------



## lrhorer

Hmm...



Code:


RAID-Server:/usr/share/pyhme/jukebox# python BuildCache.py 
Tue Dec 27 00:28:53 2011 starting cache build from MP3 files
Traceback (most recent call last):
  File "BuildCache.py", line 80, in <module>
    config = Config.Config(None)
  File "/usr/share/pyhme/jukebox/Config.py", line 60, in __init__
    if not self.cfg.read(self.fn):
  File "/usr/lib/python2.6/ConfigParser.py", line 286, in read
    self._read(fp, filename)
  File "/usr/lib/python2.6/ConfigParser.py", line 482, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)
ConfigParser.MissingSectionHeaderError: File contains no section headers.
file: /usr/share/pyhme/jukebox/jukebox.ini, line: 24
'pytivo = /usr/share/pyTivo/pyTivo.conf\n'

It looks to me like your parser is confused by a newline. Line 24 is the first un-commented line in the .ini file. If I un-comment an earlier line, it complains of that line.


----------



## Allanon

The jukebox.ini file is missing the section header. Just put [jukebox] at the top of the jukebox.ini file. The included example is missing it also.

I tried the program and it works good but it's a lot more functionality than I need for my music needs.


----------



## jbernardis

Allanon was right. I was missing the [jukebox] section heading in the jukebox.ini.dist file. GIT has been updated with this change.


----------



## lrhorer

'Any chance we can convince you to look into features like those on Galleon?

Specifically:

1. A more sophisticated screen saver. A blank TV screen may be misinterpreted as being off.

2. Album art lookup / refresh.

3. Lyrics lookup.


----------



## jbernardis

lrhorer said:


> 1. A more sophisticated screen saver. A blank TV screen may be misinterpreted as being off.


I can look into this. I was earlier thinging of having the album artwork bouncing around. 


> 2. Album art lookup / refresh.


I'm not sure what you mean here. I simply show what's in the mp3 file. I don't think I want to get into updating the mp3 file.


> 3. Lyrics lookup.


I'd have to do some research here. I'm not currently aware of a web site that let's me retrieve lyrics. If I could find one (or if you know of one) and it has a reasonable interface I might be able to do something here


----------



## lrhorer

jbernardis said:


> I can look into this. I was earlier thinging of having the album artwork bouncing around.


That would work. Galleon does the same.



jbernardis said:


> I'm not sure what you mean here. I simply show what's in the mp3 file. I don't think I want to get into updating the mp3 file.


That's not what I was suggesting. Galleon simply looks up likely album covers on the web based upon the artist and displays them. Of course, most of them do not have anything to do with the current song, but it does present a montage of the artist's work.



jbernardis said:


> I'd have to do some research here. I'm not currently aware of a web site that let's me retrieve lyrics. If I could find one (or if you know of one) and it has a reasonable interface I might be able to do something here


lyrics.com, or maybe azlyrics.com?


----------



## rjmitche

Got a chance to try this out the other day. Nice work. I like what you've done (having been a Harmonium user, I can see the resemblance).

Looks like I've got some work to do to clean up/restructure the metadata of my music to make it more "Jukebox-friendly"... especially in the area of "Album Artist vs. Track Artist" and Album Art (image size consistency). A couple of questions/comments...

1) I've got a lot of compilations that have many different artists. Right now, most of these have "Various Artists" in the Album Artist field - is it expected that Album Artist would be blank for this type of Album so that it falls to/dsiplays Track Artist? Any chance of a configuration option to change the order in which the artist fields are used?

2) What is the optimal image size for Album Art display in Jukebox? While I'm pretty good about making sure all of my audio files have image art, I'm all over the board in terms of the size of the image... which becomes painfully obvious when the player doesn't re-size them to a standard size.

3) I like the fact that the "Next Track" is displayed however I feel like it should be set apart more from the currently playing information. Perhaps it could be moved to someplace away from the main info section or displayed in a smaller font (or both). 

4) Any chance for more built-in support for pre-existing (m3u) playlists? I found that I could play my pre-existing playlists by copying them into the jukebox\playlist directory and renaming them to .jpl files. I'm wondering if there is an easier way.

Thanks again for another great app!


----------



## jbernardis

rjmitche said:


> Got a chance to try this out the other day. Nice work. I like what you've done (having been a Harmonium user, I can see the resemblance).
> 
> Looks like I've got some work to do to clean up/restructure the metadata of my music to make it more "Jukebox-friendly"... especially in the area of "Album Artist vs. Track Artist" and Album Art (image size consistency). A couple of questions/comments...


Glad you like it. I tried to answer your questions below.


> 1) I've got a lot of compilations that have many different artists. Right now, most of these have "Various Artists" in the Album Artist field - is it expected that Album Artist would be blank for this type of Album so that it falls to/dsiplays Track Artist? Any chance of a configuration option to change the order in which the artist fields are used?


I tried various ways of dealing with this and what I ended up with the following: if both the track and album artist are specified, then those values are used. If one or the other is missing, then the value that is present is used for both. If both are missing, a value of "<unknown>" is used. Thus if you don't have the album artist as in your example, it should use the track artist instead.


> 2) What is the optimal image size for Album Art display in Jukebox? While I'm pretty good about making sure all of my audio files have image art, I'm all over the board in terms of the size of the image... which becomes painfully obvious when the player doesn't re-size them to a standard size.


Art larger that 320 x 320 is reduced to 320 x 320 when the cache is built - it is one reason why the cache building takes so long. Art smaller that 320 x 320 is left unchanged. When I was developing, I noticed that a few of my songs weren't displaying art. When I looked, I discovered that these songs had bitmap artwork. I replaced it with jpg and it worked fine. I never looked any more into this, so for now at least I would recommend jpg artwork.


> 3) I like the fact that the "Next Track" is displayed however I feel like it should be set apart more from the currently playing information. Perhaps it could be moved to someplace away from the main info section or displayed in a smaller font (or both).


Not commiting to it, but I'll consider it.


> 4) Any chance for more built-in support for pre-existing (m3u) playlists? I found that I could play my pre-existing playlists by copying them into the jukebox\playlist directory and renaming them to .jpl files. I'm wondering if there is an easier way.


All I really need in a playlist file is a list of fully qualified path names. These are used to index into a dictionary I built that gives me back object references. Perhaps I can read in alternate playlist formats, but if they are changed in any way through the playlist editor screen, they will be written out as jpl files. Alternatively (and this might be simpler) I could write a conversion tool. Let me think about this one too.


> Thanks again for another great app!


An update on what I have been doing

1) I have implemented the screen saver ar lrhorer has requested - instead of a blank screen, the artwork for the current song moves around on the screen (if no song is presently playing, the application icon is used instead)

2) I have implemented a safeguard - if you try to exit by pressing left form the main menu while music is playing, you will be asked to confirm with a thumbsup. This prevents you from quickly hitting left-left-left rising up throught the menus and hitting it once too often and exiting the app.

3) I am working on lyrics retrieval. Not sure how it's going to mesh in with the main application yet. I am also having some difficulty because you don't always get well-formed HTML back from some of these web sites and I don't like the work-arounds.

GIT hasn't been updated with these yet - I am going to wait a few days to see how the lyrics retrieval progresses. If it looks like it will be a while before that will be done, I'll update with what I have done so far rather than wait for that work to be completed.


----------



## jbernardis

I have updated github with version 1.0a of jukebox. I haven't incorporated lyrics yet and am not sure if I will. The algorithm for retrieving lyrics is too non-deterministic for my liking. 

What I HAVE implemented are the better screen saver and exit safeguard as described in the above post. I also now allow for the direct reading of m3u playlist files in addition to my own jpl files. A few caveats with using m3u files: 1) if they are modified within jukebox and then saved, they will be written as jpl files, not m3u files. 2) jukebox is looking for a fully-qualified file name within the playlist file. Depending on the way you have file systems mounted, the same file can have different paths on different systems. If you run jukebox on a system different from where you run your normal media player, the m3u file will possibly not work.


----------



## lrhorer

jbernardis said:


> I haven't incorporated lyrics yet and am not sure if I will. The algorithm for retrieving lyrics is too non-deterministic for my liking.


Well, there is no way the lyrics will always be available, and Galleon certainly was not always able to obtain the lyrics to any given song, but sporadic retrieval is better than none at all. IMO, of course.



jbernardis said:


> What I HAVE implemented are the better screen saver and exit safeguard as described in the above post.


Excellent, as always. I'll have to give the new build a try this weekend.


----------



## jcthorne

Finally got time to try installing this and got as far as running buildcache.py

I get the following error:


Code:


C:\python HME\jukebox>BuildCache.py
Sat Jan 14 08:23:32 2012 starting cache build from MP3 files
Beginning container: Thornolis Music (Z:\Music)
.
Traceback (most recent call last):
  File "C:\python HME\jukebox\BuildCache.py", line 116, in <module>
    (title, albumName, trackArtistName, albumArtistName, fn, art, length, genre,
 track) = parseMP3(fn)
  File "C:\python HME\jukebox\BuildCache.py", line 31, in parseMP3
    md = MP3(fn)
  File "C:\python HME\jukebox\mutagen\__init__.py", line 75, in __init__
    self.load(filename, *args, **kwargs)
  File "C:\python HME\jukebox\mutagen\id3.py", line 1957, in load
    self.info = self._Info(fileobj, offset)
  File "C:\python HME\jukebox\mutagen\mp3.py", line 101, in __init__
    self.__try(fileobj, offset, size - offset, False)
  File "C:\python HME\jukebox\mutagen\mp3.py", line 138, in __try
    raise HeaderNotFoundError("can't sync to an MPEG frame")
mutagen.mp3.HeaderNotFoundError: can't sync to an MPEG frame

Suggestions?


----------



## jbernardis

jcthorne:

This error is coming out of mutagen - most likely it is an ill-formed MP3 file. I have updated github with a new BuildCache.py - I added a try block around the mutagen call. The file still cannot be parsed, but now it will be identified, and even better - it will be skipped and the cache will continue to build without the offending file(s).


----------



## jcthorne

Thanks. BuildCache got much further and died again. This time the error is:



Code:


+ . . . . | . . . . + . . . . | .
Traceback (most recent call last):
  File "C:\python HME\jukebox\BuildCache.py", line 134, in <module>
    artRsz = resizeArt(art, artWidth, artHeight)
  File "C:\python HME\jukebox\AlbumArt.py", line 34, in resizeArt
    pic.save(out, 'JPEG')
  File "C:\Python27\lib\site-packages\PIL\Image.py", line 1406, in save
    self.load()
  File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 201, in load
    raise IOError("image file is truncated (%d bytes not processed)" % len(b))
IOError: image file is truncated (138 bytes not processed)


----------



## jbernardis

Again - this is probably an ill-formed MP3 file. IN this case, it looks like it has bad image data.

I have posted a new version on github. This adds a try block around all of the PIL/resizing logic. If the PIL logic fails, the file is not skipped, but it will be assigned default album artwork.

I have no good way of testing this fix. I DID make sure it still generates the same cache file (checksums equal) as the old version did when the files do not have any bad data. I don't know, however, the exact issue with your file that caused PIL to fail. Give it a try and let me know how it goes.


----------



## windracer

Finally got around to trying this ... pretty nice. Although I hate apps that show me how messed up my metadata is. 

I currently use Galleon's music player primarily for the iTunes app, which automatically pulls my playlists out of my iTunes library so I don't have to maintain a separate set of files (I just copy the XML file from my PC to the Linux box every now and then and do a global search/replace to switch the path).

Nice looking app, though! It took about 20 minutes for BuildCache.py to process my 5,673 files ... only two errors on album art resizing.


----------



## jbernardis

windracer said:


> Finally got around to trying this ... pretty nice. Although I hate apps that show me how messed up my metadata is.


Glad you like it


windracer said:


> I currently use Galleon's music player primarily for the iTunes app, which automatically pulls my playlists out of my iTunes library so I don't have to maintain a separate set of files (I just copy the XML file from my PC to the Linux box every now and then and do a global search/replace to switch the path).


No reason I can't do that for this app. Let me look into it.


windracer said:


> Nice looking app, though! It took about 20 minutes for BuildCache.py to process my 5,673 files ... only two errors on album art resizing.


That seems a little slow. My cache builds in about 5 or 6 minutes - ~3200 songs - and that is on my netgear ReadyNAS which, I believe, is a single core Atom processor.


----------



## jcthorne

Well, making progress. Buildcache finished. Approx 2.5hrs to finish 141,000 files.

jukebox shows up on the tivo. Selecting it gets me a please wait.

On the machine running jukebox it says "Starting cache file load"

The tivo times out and goes back to the menu.

Approx 1 minute and 40 seconds later juke box says "Starting sort" Then 7 seconds "Finished - 141767 music files, 9328 albums, 635 album artists, 3559 track artists"

It then reports an exception, "An established connection was aborted by the software in your host machine"

It appears, jukebox is taking too long to respond and tivo is giving up and going back to the menu. Let me know if you need the full output of jukebox and I can paste it.

Really do appreciate your work on this, I look forward to getting it running.

James


----------



## jbernardis

141,000 Files!!!!!

That might be a bit too much to handle. Send me your output and I'll look at it, but it might just be too much to handle. With 141000+ files, your cache file is probably just under a gig. I think most people have <10,000 files and that was the scale I had in mind when I wrote the program


----------



## lrhorer

jbernardis said:


> 141,000 Files!!!!!


That was my response, too. If we assume 2 minutes per song (which may be too conservative if he has a lot of classical music), that's 195 days worth of music running 24 hours a day. The way that I listen to music, it's more like 195 years!



jbernardis said:


> I think most people have <10,000 files and that was the scale I had in mind when I wrote the program


I think that's a pretty good assumption. Of course I don't have all that much in the way of music, but I only have 1368 songs from 623 albums.


----------



## windracer

jbernardis said:


> That seems a little slow. My cache builds in about 5 or 6 minutes - ~3200 songs - and that is on my netgear ReadyNAS which, I believe, is a single core Atom processor.


My Linux box is also an Atom processor (although a dual-core one) but the music library is on a different NAS, not local, so maybe that's why.


----------



## jcthorne

jbernardis said:


> 141,000 Files!!!!!
> 
> That might be a bit too much to handle. Send me your output and I'll look at it, but it might just be too much to handle. With 141000+ files, your cache file is probably just under a gig. I think most people have <10,000 files and that was the scale I had in mind when I wrote the program


It appears that jukebox in not having trouble with it, just that the tivo does not wait for the cache to load. Could the cache be preloaded when jukebox starts rather than waiting for tivo to ask for the app?

The cache file is 121MB.

Thanks.



Code:


HME Server for Python 0.19
Sun Jan 15 17:43:44 2012 Thornolis Video Archive version 2.0c module initializin
g
Loading thumbnail cache
100 thumbnails loaded from cache
Sun Jan 15 17:43:44 2012 JukeBox version 1.0c module initializing
Sun Jan 15 17:43:44 2012 Server Starts
Registering: jukebox
Registering: vidmgr
192.168.1.109:40386 - - [15/Jan/2012 17:43:51] "GET /jukebox/ HTTP/1.1" 200 -
192.168.1.109:40386 - - [15/Jan/2012 17:43:51] Starting HME: jukebox
Jukebox thread entering startup
Sun Jan 15 17:43:52 2012 Starting cache file load
Sun Jan 15 17:45:06 2012 Starting sort
Sun Jan 15 17:45:11 2012 Finished - 141767 music files, 9328 albums, 665 album a
rtists, 3559 track artists
Jukebox thread activating
Server address = 192.168.1.128:9032
192.168.1.109:40386 - - [15/Jan/2012 17:45:11] Ending HME: jukebox
----------------------------------------
Exception happened during processing of request from ('192.168.1.109', 40386)
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 582, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\python HME\start.py", line 139, in __init__
    client_address, server)
  File "C:\Python27\lib\SocketServer.py", line 641, in __init__
    self.finish()
  File "C:\Python27\lib\SocketServer.py", line 694, in finish
    self.wfile.flush()
  File "C:\Python27\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in yo
ur host machine
----------------------------------------


----------



## jcthorne

lrhorer said:


> That was my response, too. If we assume 2 minutes per song (which may be too conservative if he has a lot of classical music), that's 195 days worth of music running 24 hours a day. The way that I listen to music, it's more like 195 years!
> 
> I think that's a pretty good assumption. Of course I don't have all that much in the way of music, but I only have 1368 songs from 623 albums.


lrhorer,

I admired your video collection and your organization of it. Never made fun of someone wanting to store more video than they will ever watch.

I have been buying and collecting music for many years and yes, the collection is large and growing. I use it every day.

This forum, of all places I did not feel I would have to justify the desire to catalog and present a large music collection. It occupies less than 2TB of storage so not that much by today's storage capacities.


----------



## lrhorer

jcthorne said:


> I admired your video collection and your organization of it. Never made fun of someone wanting to store more video than they will ever watch.


I wasn't making fun of it or you. I'm just astounded at the size. I'm not sure how you took any of what I said as derision, but it certainly wasn't my intent.



jcthorne said:


> I have been buying and collecting music for many years and yes, the collection is large and growing.


'To say the least. Of course I, too, have been collecting music for the better part of 4 decades, but obviously not nearly the volume you have, even if I were to rip every song on every album I own. As you can see from my stats, I only have an average of about 2 songs from each album in the library, since I rarely like more than 1 or 2 songs on any given album. I don't bother to rip any songs I don't like. Even applying a factor of 10 (most albums have somewhere around 15 - 20 songs on them), it still would only be about 10,000 files or so.



jcthorne said:


> I use it every day.


I should certainly hope so.



jcthorne said:


> This forum, of all places I did not feel I would have to justify the desire to catalog and present a large music collection.


I did not ask or expect you to do so. It's entirely your business how much music you collect, or why. I never suggested otherwise.



jcthorne said:


> It occupies less than 2TB of storage so not that much by today's storage capacities.


Well, 2T is quite a bit, especially for audio, but it's certainly not the unimaginable amount of space it was when I first got into computing.


----------



## lrhorer

windracer said:


> Nice looking app, though! It took about 20 minutes for BuildCache.py to process my 5,673 files ... only two errors on album art resizing.





jbernardis said:


> That seems a little slow. My cache builds in about 5 or 6 minutes - ~3200 songs - and that is on my netgear ReadyNAS which, I believe, is a single core Atom processor.


Both sound a little slow, to me. Admittedly, I have much fewer files, by a factor of almost 3 or 5, but still it only takes 9 seconds on my server, and it's no Ferrari.


----------



## jbernardis

jcthorne - I sent you a private message with my email address. I want to send you a version of jukebox for you to try before general consumption.

This version pre-loads the cache as you requested. Just so you know, the issue goes beyond when the cache is loaded. By preloading the cache, I've raised the problem of what happens when the cache changes. With the original design, all you had to do was exit the app and then re-enter it. By preloading, however, exiting the app has no effect - you'd instead need to exit the process (pyhme).

I have solved this by starting a thread that looks for a changed timestamp on the cache file every 10 minutes (actually a config parameter) and reloading when it detects this. The app still needs to be exited to "bring in" the new cache, but that is the same as today.

Overall I think it's a better design, but I'd like you to put it through its paces before I post it to github.


----------



## jbernardis

lrhorer said:


> Both sound a little slow, to me. Admittedly, I have much fewer files, by a factor of almost 3 or 5, but still it only takes 9 seconds on my server, and it's no Ferrari.


The time for building the cache depends largely on the artwork. This is when resizing is done. While I was developing the app, and before I put in the logic to resize the artwork, it took my rig about 25 seconds to build the cache. Adding the artwork logic took it up by a factor of 6 or 7.


----------



## jbernardis

lrhorer said:


> Well, there is no way the lyrics will always be available, and Galleon certainly was not always able to obtain the lyrics to any given song, but sporadic retrieval is better than none at all. IMO, of course.


lrhorer - I'm thinking of attacking this in two steps.

First, the lyrics would be retrieved during cache building (or perhaps through a separate utility). I'm thinking that the lyrics themselves would be stored in a "parallel" file to the mp3 file (much like vidmgr uses parallel thumbnail and metadata files).

Step 2, jukebox would allow you to display the contents of this file by pressing, say, the info button.

This solution would allow you to create/edit your own file for those songs that prove troublesome for web downloading algorithms. It also allows you to put in any arbitrary information that you might want to have displayed.


----------



## jbernardis

A new version of jukebox - 1.0d - is up on github.

jcthorne and I have been working together today to get jukebox working with his rather large collection. Basically what I did was add the ability to pre-load the cache at process start time rather that at app activation time. 

To control this, I have added 2 configuration options:

preloadcache = True or False
default is false and results in today's behavior. 

If preloading is done, there is a problem with how I know when to reload the cache if it happens to change. I didn't want to force people to restart the entire pyhme process, but that is what it would have taken if I didn't do anything else. 

What I did to solve this to to create a thread (only if preloadcache is True) that sleeps in an infinite loop, and when it wake up, it checks the timestamp on the cache file to see if it has changed. If it has, it reloads it. Note that if the GUI is active, reloading will have no effect on it - you MUST exit the app and re-enter to get the new cache. The frequency with which the thread wakes up is controlled by the second config.ini parameter:

cachewatchinterval = 600

This is the number of seconds between checking the file for changes. 10 minutes (600 seconds) is the default.

Thanks again to jcthorne for helping with this effort.


----------



## windracer

jbernardis said:


> The time for building the cache depends largely on the artwork. This is when resizing is done. While I was developing the app, and before I put in the logic to resize the artwork, it took my rig about 25 seconds to build the cache. Adding the artwork logic took it up by a factor of 6 or 7.


I guess that explains my 20 minute cache time, then ... all of my MP3 files have artwork and they're not local to jukebox.



Code:


Tue Jan 17 02:08:43 2012 starting cache build from MP3 files
Beginning container: Music Library (/mnt/media/Music)
. . . . | . . . . + . . . . | . . . . + . . . . | . . . . + . . . . | . . . . + . . . . | . . . . + . . . . | . .
5763 music files in container
5763 total files in ALL containers

Tue Jan 17 02:27:10 2012 Starting sort
Tue Jan 17 02:27:11 2012 Saving cache to disk
Tue Jan 17 02:27:11 2012 Finished - 5763 music files, 2029 albums, 1247 album artists, 1244 track artists


----------



## jcthorne

Still should not take that long.

My 141k files took about 2 hrs to build the cache. They are all stored on the NAS. jukebox is running on a windows pc at the moment with pytivo.

Great that it works though and only needs to build the cache when things change.


----------



## jbernardis

An update on Jukebox. I guess inactivity here means that the app has been working for everyone. I've been makeing a few changes however, and should shortly have an update.

lrhorer has requested a lyrics retrieval feature, and although I was a bit reluctant, I have been working on it. I actually was just about completed with it when it stopped working altogether. I looked into why it was failing and discovered that the site I was using - azlyrics.com - was not responding. Thinking the site had crashed or was having other problems, I just stopped for the night. Over the next day or two, I noticed that I could access the site from work, but not from home. When I queried them about it, they stated that my IP address had been blocked because of what their bot determined was malicious behavior. I think something along the line of 10 requests in a minute or 100 in 15 minutes (which is probably what I exceeded) is considered malicious and the ip address is blocked for a week. If repeated, the block could be permanent.

Well I was finally unblocked just today and was able to work through the last couple of issues. I just want to run with it myself for a few days to make sure it holds together. And of course since I don't want to be blocked again, I am pacing my testing


----------



## jbernardis

I just put version 1.0e of Jukebox up on git. This has the lyrics retrieval feature requested by lrhorer. I also fixed a little bug. In the past, I have been constantly concerned about jukebox being a memory hog. So much so that when the app deactivated, I went so far as to actually destroy my cache, thinking that I could somehow hasten garbage collection. Well that was all well and good until I was requested to pre-load the cache. When the cache is pre-loaded, I obviously don't want to destroy it, so I made this fix.

A Note about lyrics retrieval - be aware of the restrictions of azlyrics.com that I discuss in the previous post. When I first saw it in operation, I thought it was cool, so I went crazy requesting lyrics for song after song. If you do this too, you will likely end up with your IP address blocked.


----------



## lrhorer

Hey Jeff, I have run across an issue.

The player won't play a file by .38 Special. I suspect it is because it takes the leading period in the file name to mean the file is hidden. Of course, there aren't a lot of files with leading periods in the name, but renaming the file breaks the convention of <artist> - <Song>.mp3.


----------



## jbernardis

lrhorer said:


> Hey Jeff, I have run across an issue.
> 
> The player won't play a file by .38 Special. I suspect it is because it takes the leading period in the file name to mean the file is hidden. Of course, there aren't a lot of files with leading periods in the name, but renaming the file breaks the convention of <artist> - <Song>.mp3.


I assume the filename is something like ".38 Special - Hold on Loosely.mp3"?

I'll look at how the logic breaks down on this one - sound's like it might be pretty simple.

BTW in my collection, .38 Special is listed as 38 Special - without the leading period. I did this a while ago - not sure why, but that's why I didn't hit this issue.


----------



## jbernardis

lrhorer said:


> Hey Jeff, I have run across an issue.
> 
> The player won't play a file by .38 Special. I suspect it is because it takes the leading period in the file name to mean the file is hidden. Of course, there aren't a lot of files with leading periods in the name, but renaming the file breaks the convention of <artist> - <Song>.mp3.


Fixed.

Version 1.0f is now up on git - see my signature.

This was a simple change - one line had to be removed. The issue wasn't that files wouldn't play - they never even made it into the cache. Therefore, you will still be unable to play these songs until you rebuild the cache.


----------



## windracer

jbernardis said:


> BTW in my collection, .38 Special is listed as 38 Special - without the leading period.


Heh, same here. At least we all have good taste in 80s music. 

The new lyrics function is neat, BTW.


----------



## lrhorer

jbernardis said:


> I assume the filename is something like ".38 Special - Hold on Loosely.mp3"?


You assume correctly.


----------



## lrhorer

windracer said:


> Heh, same here. At least we all have good taste in 80s music.


Of course we do! We're smart enough to be using vidmgr, aren't we? 



windracer said:


> The new lyrics function is neat, BTW.


That's why I requested it.


----------



## cassiusdrow

I love this! Between this and Pytivo, I can finally get rid of Galleon!

Is there any way to prevent the sudden return to Live TV that sometimes happens when the music is done playing?


----------



## jbernardis

cassiusdrow said:


> ...
> Is there any way to prevent the sudden return to Live TV that sometimes happens when the music is done playing?


pyhme delivers an "idle" event to the app periodically when there is no remote control activity - I'm not sure what the timer period is. While music is playing, I dismiss this event in a way that keep the app active. If no music is playing, it allows the idle timer to kill the app and return to live TV.

I guess it's possible, based on the specific timing, that an "idle" event may arrive shortly after music finishes playing. If this happens, then yes the screen will be quickly dismissed.

I can, if you want, add an option to keep the app active when the idle event arrives, but this will mean that the app will never time out. Alternatively I can add logic that requires the receipt of two (or more) "idle" events before it times out.


----------



## cassiusdrow

jbernardis said:


> I can, if you want, add an option to keep the app active when the idle event arrives, but this will mean that the app will never time out. Alternatively I can add logic that requires the receipt of two (or more) "idle" events before it times out.


I'd prefer an option to always ignore the idle events - Galleon had a similar setting. Thanks!


----------



## jbernardis

Version 1.0g is now on git. A new option has been added: ignoreidle, default value of False. If set to true, jukebox will not time out; you will need to explicitly exit from the app. I also changed the normal timeout logic to not react to the FIRST idle event, but to wait until the second such event before it times out. As always, the application will NEVER timeout if music is being played.


----------



## davidblackledge

jbernardis said:


> pyhme delivers an "idle" event to the app periodically when there is no remote control activity - I'm not sure what the timer period is.


Just as a point of information... it's the TiVo that delivers the event over HME. pyhme is just passing it along and doesn't handle the timing. If I remember correctly, you get one every 5 minutes of idle time.


----------



## species8472jj

I am probably making this more complicated than it is or I should be reading this with more than 2 hours of sleep, but I'll ask my question anyway.

When you say to install jukebox in my pyhme directory, I am not sure to what you're referring? My PyTivo directory? Python directory?

I have pytivo installed and working (actually have for quite some time). My pytivo is running on a Windows 7 PC, so if you could answer my question, I appreciate it.

Thank you.


----------



## jbernardis

You need to run wmcbrine's HME for python. Jukebox is an application that runs under that framework. Check out this thread: http://www.tivocommunity.com/tivo-vb/showthread.php?t=382883


----------



## ricosuave

Does anybody else have an issue with Beyoncé showing up as Beyon?? anytime the artist name is displayed?


----------



## jbernardis

ricosuave said:


> Does anybody else have an issue with Beyoncé showing up as Beyon?? anytime the artist name is displayed?


That's going to happen with non-ascii characters. To be honest, I found it easier to change the metadata and file names so that it simply shows up as, for example, Beyonce.


----------



## wmcbrine

jbernardis said:


> That's going to happen with non-ascii characters. To be honest, I found it easier to change the metadata and file names so that it simply shows up as, for example, Beyonce.


There is no reason it need happen.



Code:


# -*- coding: utf-8 -*-

from hme import *

TITLE = 'Hello World'

class Hello(Application):
    def startup(self):
        Font(self, size=36, style=FONT_BOLD)
        #self.root.set_text('Hello, world!')
        self.root.set_text(u'Beyoncé')


----------



## Soapm

lrhorer said:


> Of course we do! We're smart enough to be using vidmgr, aren't we?
> 
> *That's why I requested it. *


I didn't picture you as a karaoke type but if you have the vocal cords you might as well use them. I joined the choir at Church and they changed practice night to one when I worked then made a rule that you can't sing on Sunday if you didn't make rehearsal.

I guess envy gets the best of even the Church folks


----------



## jbernardis

wmcbrine said:


> There is no reason it need happen.


Don't change your metadata yet.

I knew the issue was that I was forcing ASCII when I didn't really need to. I started working on a fix, and it should be rather simple - just give me a few days to work it in and test it out.

Wednesday or Thursday I should have a fix up.


----------



## ricosuave

Great news! Thanks for keeping jukebox up to date.



jbernardis said:


> Don't change your metadata yet.
> 
> I knew the issue was that I was forcing ASCII when I didn't really need to. I started working on a fix, and it should be rather simple - just give me a few days to work it in and test it out.
> 
> Wednesday or Thursday I should have a fix up.


----------



## jbernardis

I just put version 1.0h up on git. This adds support for unicode-encoded metadata.

ricosuave - I don't have a lot of metadata that isn't ASCII, so I couldn't easily test this without using contrived data. I'm hoping you'll let me know if you have any issues with this version.


----------



## ricosuave

Thanks for getting this out so quick. All the non ASCII characters look great and sort properly. Now I have a new problem though, it's not playing any tracks. The progress indicator just stays at 0:00 and it doesn't move. Any suggestions? Is there a log somewhere I can look at?



jbernardis said:


> I just put version 1.0h up on git. This adds support for unicode-encoded metadata.
> 
> ricosuave - I don't have a lot of metadata that isn't ASCII, so I couldn't easily test this without using contrived data. I'm hoping you'll let me know if you have any issues with this version.


----------



## wmcbrine

Try rebooting the TiVo? This happens pretty regularly with the HMO version of the MP3 player; I'm not sure if the HME streamer is similarly affected, but I wouldn't be surprised. It's a TiVo-side bug (at least the HMO version is).


----------



## jbernardis

There is a new version of Jukebox on git - I introduced a bug in the lyrics retrieval code when I added the support for unicode. Version 1.0i.

ricosuave - I hope wmcbrine's suggestion got you going again. This sounds likely. Jukebox plays no real active part in actually playing the file. It creates the stream, and thereafter just reacts to status messages that the TiVo delivers. It sounds like your TiVo was, for whatever reason, not sending these messages, so hopefully a reboot solves it.


----------



## species8472jj

I am in the process of setting this up. I have one question.

I got everything installed except, I cannot find where to change the directory where my music is stored. It defaults to my music directory on my PC, but that not where my music is stored.

Could you please let me know how to change that?

Thank you.


----------



## jbernardis

Pytivo actually serves the mp3 files. You need to set up pytivoand define a music share there. Then you tell jukebox where the pytivo configuration can be found


----------



## species8472jj

Thanks for the direction - makes total sense.

One final question. I got the whole thing up and running. The only thing is when I choose a track to play, it does not play. It shows the proper screen, but it just hangs at time index 0:00.

If you could help, that would be great.


----------



## jbernardis

Do you have the proper ip address and/or port specified for the pytivo server. Somewhere in the output from jukebox there should be a line like "Server address = %s:%s". Make sure this points to pytivo. You can specify both of these in your jukebox.ini file (serverip= and serverport=). If you do not specify serverport in your ini file, it gets it from your pytivo config file. But make sure it points to pytivo, and NOT to jukebox/pyhme.


----------



## species8472jj

That was one problem - thank you. I just removed those server/port lines, so it just defaults to the pytivo. But I still have a problem. The original problem is when I would play a track, the time index would hang at 0:00. Now, the progress bar does tick away, however I am not getting any sound. I tried multiple tracks, and I keep getting the same result. Thanks in advance for the help.


----------



## jbernardis

Now that's an interesting problem. Jukebox does not actually play the song. It just sends the stream url to the tivo, and then updates its display based on status messages that the tivo sends. The fact that the progress bar ticks away indicates that the tivo THINKS it is playing the file. If you are not getting any sound, the problem is probably with the tivo. There was a suggestion earlier to reboot the tivo - perhaps that would help here.


----------



## species8472jj

First of all, your response time is lightning fast. I really appreciate all the help you've given me.

Second, rebooting the TiVo worked. Big Thank you. I love
Harmonium, and this is a new and improved version of it. 

Third, where do I find the lyrics feature? I don't see an option when I'm playing tracks.

And fourth, a couple minor suggestions. One minor feature Harmonium had is when you have large list of songs and hit the "1" key it would take you 10% through the list, "2" key to about 20% through the list and so on. 

Another thing in Harmonium is when an artist had a "the" before their name such as The B-52's, Harmonium would alphabetize that as "B" for B-52's as opposed to "T" for the. 

These are a couple nice perks Harmonium has. 


And finally - very nice application. Great work and thank you.


----------



## jbernardis

The lyrics feature is via the info button - just press it while a song is playing and its lyrics will show up. You can also press it while browsing the catalog, and the lyrics for the currently viewed song will be retrieved.

It isn't perfect, there will/may be songs it cannot find lyrics for, and for those, you can create your own local lyrics file. The details are in the README file starting about line 156.

Your suggestions are noted. I already do those things for vidmgr, my other pyhme app, so porting the logic shouldn't be too bad.

Glad you like it, and glad we got it working.


----------



## jbernardis

species8472jj:

A question about the removal of articles (a, an, the) from band names. Is this juat about alphabetization? Or is this also about recognizing that a song with artist "Clash" should be combined with a song by artist "The Clash"?

If it's just sorting, then it should be relatively easy to do. Using the above esample, you'd have two groups in the list - "Clash" and "The Clash". 

If it's a request to combine the two, then that's a little tougher, and it raises questions about which name should rule. Should I choose "Clash" or "The Clash".

Right now I'm leaning towards just the sorting. This approach has the added advantage that it will show you where your metadata is inconsistent. The second approach will hide the inconsistencies.

P.S. Using the number keys to step through the list in a percentage fashion has already been implemented by "borrowing" about 10 lines of code from vidmgr. It is still to be tested, though, so don't go looking for it yet.


----------



## species8472jj

To answer your question, I am thinking about the removal of articles just for alphabetizing.

I have a lot of artists with "the", so if you can remove the articles as you said, I think that would work great.

Thanks!


----------



## jbernardis

I have just uploaded version 1.oj with the recently requested features. Here is the extract from the changelog file:

Version 1.0j - 4/21/2012
- Added support for using number keys to navigate through long menus (1=10%, 2=20%, etc)
- Added the ability to ignore leading articles (a, an, the) in artist names so that "The Beatles" sorts with the B's
- added ignorearticles ini file option to control above stripping of articles


----------



## lrhorer

jbernardis said:


> - Added the ability to ignore leading articles (a, an, the) in artist names so that "The Beatles" sorts with the B's


The Beatles? Oh, come on, Jeff. At least use the names of real bands when citing an example. No band would ever call themselves "The Beatles". I mean really...


----------



## jbernardis

lrhorer said:


> The Beatles? Oh, come on, Jeff. At least use the names of real bands when citing an example. No band would ever call themselves "The Beatles". I mean really...


I guess it shows my age. If it makes it look any better, I also have music in my collection from Green Day and (gulp) Avril Lavigne.


----------



## species8472jj

I finally got to try the lyrics via pressing the info button. Unfortunately, what happened was it would literally just exit out of Jukebox.

Looking at the DOS window, I do seen an error...

"Error: character mapping must return integer, None, or unicode"

If you have any suggestions, that would be great.


----------



## jbernardis

species8472jj said:


> I finally got to try the lyrics via pressing the info button. Unfortunately, what happened was it would literally just exit out of Jukebox.
> 
> Looking at the DOS window, I do seen an error...
> 
> "Error: character mapping must return integer, None, or unicode"
> 
> If you have any suggestions, that would be great.


Can you give me the whole traceback that appears in the DOS window. The error message is great, but the traceback will help to pinpoint the code location. Also, since it was in the lyrics section, if you can give me the EXACT song title and artist name it would be helpful.


----------



## lrhorer

jbernardis said:


> I guess it shows my age. If it makes it look any better, I also have music in my collection from Green Day and (gulp) Avril Lavigne.


I keep having these moments of geriatric depression when I see something come from a "new kid". The first one was over 30 years ago. I heard a 9 year old turn to her mother and say, "Mommy, did you know Paul McCartney was with another band before he was with Wings?"

Now I really feel old.


----------



## species8472jj

Right now, I am having two problems, and I don't know why I am having such a hard time.

1) This was my original problem. The progress bar would tick away, and there would be no sound. The response was to reboot my Tivo and that worked. It happened again, and it seem to be very random, so I would try Harmonium every time it happened, and that has played successfully every time. One other thing I noticed. When I would go into Jukebox, and go through the menus, I noticed if I heard the TiVo chirp as I moved down, it would play fine. If I did not hear the TiVo chirp as I moved from item to item, it would tick away and play no music. Since may TiVo HD screens don't have that chirp, I didn't think anything of it. It may be nothing, but it may help diagnose the problem.

2) As mentioned before, if I hit the "info" button for lyrics, Jukebox just exits.
Please see the entire traceback below leading to the error. The song I tried was 10,000 Maniacs - What's the matter here? 
I've tried others with the same result.

C:\PYHME>call start.py
HME Server for Python 0.19
Sat Apr 28 14:39:06 2012 JukeBox version 1.0h module initializing
Sat Apr 28 14:39:06 2012 Server Starts
Registering: jukebox
192.168.1.150:35922 - - [28/Apr/2012 14:39:24] "GET /jukebox/ HTTP/1.1" 200 -
192.168.1.150:35922 - - [28/Apr/2012 14:39:24] Starting HME: jukebox
Jukebox thread entering startup
Sat Apr 28 14:39:24 2012 Starting cache file load
Sat Apr 28 14:39:25 2012 Starting sort
Sat Apr 28 14:39:25 2012 Finished - 4855 music files, 669 albums, 364 album arti
sts, 672 track artists
Jukebox thread activating
Server address = 192.168.1.100:9032
----------------------------------------
Exception happened during processing of request from ('192.168.1.150', 35922)
Traceback (most recent call last):
File "C:\Python27\lib\SocketServer.py", line 582, in process_request_thread
self.finish_request(request, client_address)
File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\PYHME\start.py", line 141, in __init__
client_address, server)
File "C:\Python27\lib\SocketServer.py", line 639, in __init__
self.handle()
File "C:\Python27\lib\BaseHTTPServer.py", line 337, in handle
self.handle_one_request()
File "C:\Python27\lib\BaseHTTPServer.py", line 325, in handle_one_request
method()
File "C:\PYHME\start.py", line 232, in do_GET
self._page(True)
File "C:\PYHME\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\jukebox\__init__.py", line 383, in handle_key_press
self.nowPlaying.handle_key_press(keynum, rawcode)
File "C:\PYHME\jukebox\NowPlaying.py", line 421, in handle_key_press
self.app.showLyrics(self.playingSong)
File "C:\PYHME\jukebox\__init__.py", line 342, in showLyrics
self.lyricView.loadLyrics(song)
File "C:\PYHME\jukebox\LyricView.py", line 76, in loadLyrics
self.lyrString = GetLyrics(song.getArtistName(), song.getTitle())
File "C:\PYHME\jukebox\GetLyrics.py", line 121, in GetLyrics
lArtist = makeASCII(artist).lower().translate(transTable).split()
TypeError: character mapping must return integer, None or unicode
----------------------------------------


----------



## jbernardis

species8472jj said:


> File "C:\PYHME\jukebox\GetLyrics.py", line 121, in GetLyrics
> lArtist = makeASCII(artist).lower().translate(transTable).split()
> TypeError: character mapping must return integer, None or unicode
> ----------------------------------------


I am really lost as to what is happening here. I am trying to form a URL from the Artist and Title, so I strip out non-ascii characters, translate to lowercase, remove punctuation characters, and finally split into a list of words that will later be joined with '+' characters. I've tried this interactively both with Ascii characters and non-ascii characters. The worst case I can think of is where makeASCII removes every character returning an empty string, but even that behaves as expected.

What version of python are you using? On Linux, or windows?

I have something I want to try, but I don't want to release it generally until we have had an opportunity to see if it solves your problem. If you want to help me out here, send me a PM with your email address, and I'll send you back one new source file to try. If it works for you, I'll update git.


----------



## species8472jj

I sent you a PM with my email - always glad to help.

I am using Python on 2.7, and I'm on Windows 7.


----------



## jbernardis

wmcbrine said:


> There is no reason it need happen.
> 
> 
> 
> Code:
> 
> 
> # -*- coding: utf-8 -*-
> 
> from hme import *
> 
> TITLE = 'Hello World'
> 
> class Hello(Application):
> def startup(self):
> Font(self, size=36, style=FONT_BOLD)
> #self.root.set_text('Hello, world!')
> self.root.set_text(u'Beyoncé')


Bill,

I am still having a bit of trouble with the code in this area. Most recently I got the following traceback out of your code when trying to set_text using a set of lyrics I received from azlyrics.com:



Code:
 

Adding lyric contect ( I really donât mind what happens now and then )
----------------------------------------
Exception happened during processing of request from ('192.168.1.103', 1052)
Traceback (most recent call last):

  File "/usr/local/pyhme/jukebox/LyricView.py", line 114, in paint
    flags=self.flags)
  File "/usr/local/pyhme/hme.py", line 1033, in set_text
    self.set_resource(Text(self.app, message, font, color, colornum), flags)
  File "/usr/local/pyhme/hme.py", line 713, in __init__
    self.put(_CMD_RSRC_ADD_TEXT, 'iis', font.id, color.id, text)
  File "/usr/local/pyhme/hme.py", line 553, in put
    _pack('ii' + format, cmd, self.id, *params))
  File "/usr/local/pyhme/hme.py", line 506, in _pack
    return ''.join([func[i](value) for i, value in zip(format, values)])
  File "/usr/local/pyhme/hme.py", line 466, in _pack_string
    return _pack_vdata(value.encode('utf-8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 12: ordinal not in range(128)
----------------------------------------

The offending character is the strange looking character in the word don't in the first line above - I assume it's some non-ascii character that looks like an apostrophy??

In any event, short of stripping non-ASCII characters out of the data I get from the web, what can I do to get past this issue?


----------



## wmcbrine

Um... figure out what character set it's actually in, and convert it from that to Unicode before you send it to the screen.

Here's what I do in several places in pyTivo:



Code:


# Try decoding it as UTF-8, fall back to system character set
if type(val) == str:
    try:
        val = val.decode('utf8')
    except:
        if sys.platform == 'darwin':
            val = val.decode('macroman')
        else:
            val = val.decode('iso8859-1')

For your purposes you'd probably want to leave out the 'darwin' (i.e. Mac OS X) part, since you're not dealing with local files.


----------



## jbernardis

Thanks - that did the trick. I try utf8 (which is what it was) and then iso8859-1, and if they both fail, I strip out anything that is non-ascii as an absolute last-ditch tactic.


----------



## wmcbrine

iso8859-1 won't fail... well, I guess technically you could run into characters in the 128-160 gap, and it might complain then. So, it might be better to use windows-1252. Anyway, the point is, these are 8-bit encodings -- so any byte value is a valid character. With UTF-8, on the other hand, a random sequence is more likely to be invalid than valid. That's why I test for UTF-8, and then fall through to (untested) iso8859-1.


----------



## species8472jj

I have a little more insight in a "problem" I have been having with Jukebox.

The problem basically is that when I played a song, the progress bar would tick away, however there was no sound. The resolution was to reboot my TiVo, and it worked.

However, I realized that sometimes when I went into Jukebox, it would work (i.e. the songs had sound). And sometimes it would not work (i.e. the songs had no sound at all). 

I also noticed that when I moved from item to item in Jukebox's menus, if I heard the TiVo "chirp", I would hear sound when music is playing. If I didn't hear the "chirp", I would not hear sound when music is playing. I didn't think much of it since the HD Tivo interface does not have the "chirp" (or whatever you call that TiVo sound).

I am using the TiVo Premier, so I went in and changed my menus from the HD menus to the SD menus. When I did that, I went in and out of Jukebox many, many times, and it worked each time.

I believe Harmonium's interface is SD, and I know that Jukebox's interface is HD, so I don't know if that has anything to do with it. And I have not had this issue with Harmonium on either the SD or HD menus on Tivo.

I'm not pretending to know something I don't - this is just what I've noticed, and I'm putting it out there to see if it makes any sense. 

Of course, this could be a load of bunk and my Tivo (or the Tivo interface in general) is just quirky.


----------



## wmcbrine

wmcbrine said:


> iso8859-1 won't fail... well, I guess technically you could run into characters in the 128-160 gap, and it might complain then. So, it might be better to use windows-1252.


I decided to test this, and actually iso8859-1 is better. I made a file with byte values 0-255, and tried it with various decodes. iso8859-1 gave no errors. (So, it's true, there's no need to check it; all byte values are accepted.) But windows-1252 threw an exception, since there still are a few "undefined" characters in that set.


----------



## wmcbrine

On third thought, I should probably go with "decode('cp1252', 'replace')".


----------



## species8472jj

I was incorrect above (partially)

When Dolby Digital is enabled, you will get the Tivo sound effects. If you have Dolby Digital to PCM enabed, you don't get the sound effects.

My guess is that TiVo cannot play music in Dolby Digital mode which is why I am getting silence. So, when TiVo needs to play music, it must temporarily disable the Dolby Digital. 

The only thing I can think of in reference to Harmonium is it does use SD menus, so I assume Tivo has some association of SD menus with Dolby Digital to PCM.

Again, I could be wrong, but I don't know if you can tell TiVo to switch to Dolby Digital to PCM in the code. I am thinking the SD menus default to this. Although, sometimes it works, and sometimes it doesn't, and that I am not sure about except perhaps a tivo quirk.


----------



## jbernardis

I have posted verion 1.0k of jukebox on git. I have hopefully made the lyrics retrieval code a little more robust. If nothing else, I have wrapped the problem areas with try blocks so that if errors DO occur, the app does not crash and you are told that lyrics retrieval couldn't be done. But I also put in some improvements. The logic now tries to retrieve the lyrics using the given artist and title as is. If this fails, it tries again after stripping out punctuation. I think this should increase the liklihood of successful lyrics retrieval.

Thanks to species8472jj for acting as a tester for me on this, and thanks to wmcbrine for giving me pointers for dealing with different character encodings. I think it's starting to sink in.


----------



## windracer

What controls the sort order of playlists in the list? I have two playlists that for some reason sort to the end of the list, after Z. No special characters or anything like that ...


----------



## jbernardis

windracer said:


> What controls the sort order of playlists in the list? I have two playlists that for some reason sort to the end of the list, after Z. No special characters or anything like that ...


Good question 

I just checked myself, and it seems that the playlists are in the order as returned by os.listdir which is probably based on the order in which files are created/deleted. I could very easily sort that alphabetically if people wanted that. I hadn't thought about it because I don't have many playlists, but I guess if the list grows, then some ordering discipline would make life easier.


----------



## jbernardis

For those interested, I just did a quick check of jukebox with the new HME for Python 0.20 and encountered no problems.


----------



## windracer

jbernardis said:


> I just checked myself, and it seems that the playlists are in the order as returned by os.listdir which is probably based on the order in which files are created/deleted. I could very easily sort that alphabetically if people wanted that. I hadn't thought about it because I don't have many playlists, but I guess if the list grows, then some ordering discipline would make life easier.


Yeah, that would be nice. Here's my list, for example (please don't judge me by my playlist names ):



Code:


-rwxrwxrwx 1 jeremy users   15807 May  9 22:44 Chex Party Mix.m3u
-rwxrwxrwx 1 jeremy users   10653 May 10 16:19 Classic Rockin.m3u
-rwxrwxrwx 1 jeremy users    2522 May  9 21:40 Disco Dancing.m3u
-rwxrwxrwx 1 jeremy users     577 May  9 21:40 Flyer Pep Band.m3u
-rwxrwxrwx 1 jeremy users   10667 May  9 22:49 Folk You.m3u
-rwxrwxrwx 1 jeremy users    6589 May 10 16:23 Head Bangers Ball.m3u
-rwxrwxrwx 1 jeremy users    9583 May  9 21:40 Jazz it Up.m3u
-rwxrwxrwx 1 jeremy users    4628 May  9 21:40 Nerdcore Rising.m3u
-rwxrwxrwx 1 jeremy users    1042 May  9 22:07 Polka Party.m3u
-rwxrwxrwx 1 jeremy users   26692 May 15 20:12 Pop Goes the Weasel.m3u
-rwxrwxrwx 1 jeremy users    3337 May  9 22:07 Road Trippin.m3u
-rwxrwxrwx 1 jeremy users    1638 May  9 21:40 Skydiving Mix.m3u
-rwxrwxrwx 1 jeremy users    3185 May  9 21:40 Spring Training.m3u
-rwxrwxrwx 1 jeremy users   63975 May 10 16:42 The BIG 80s.m3u
-rwxrwxrwx 1 jeremy users   17259 May 10 16:32 Under the Covers.m3u
-rwxrwxrwx 1 jeremy users    1906 May  9 21:40 Wedding Mix.m3u
-rwxrwxrwx 1 jeremy users   14439 May  9 21:40 zChristmas Mix.m3u
-rwxrwxrwx 1 jeremy users    5757 May  9 21:40 zChristmas Slow Mix.m3u
-rwxrwxrwx 1 jeremy users    4220 May  9 21:40 zHalloween.m3u

And here's how they appear in jukebox:










It's those last two that are bugging me.


----------



## jbernardis

As requested by windracer, I have just made version 1.0l of jukebox available. This version maintains the list of playlists in alphabetical order. Also, with this version, I have introduced a new icon. I like the new one better, but if you prefer the old one, just preserve the icon.png file that is in the vidmgr directory.


----------



## windracer

That worked, thanks! :up:


----------



## lrhorer

windracer said:


> Yeah, that would be nice. Here's my list, for example (please don't judge me by my playlist names ):


Too late.


----------



## jbernardis

I know I've been preoccupied with other projects recently, but I have a couple of jukebox enhancements in the works:

1) a virtual DJ that would allow you to specify artists and/or genre to include and/or exclude in the selection of a random playlist. You will also have control over how many tracks to add.

2) a new feature that silences sound effects if music is playing

3) support for the slide remote when navigating menus - use the 'n' key, for example, to jump to the first artist that starts with 'n'

4) as an offshoot of this, I am thinking of adding an option to be case insensitive in sorting.

5) one last thing I am thinking of - a few months ago I added logic to ignore leading 'the', 'a', and 'an' at the beginning of artist names. I am thinking of extending that logic to include album and track names

Give me some feedback on the last two items. Does anybody have and argument for or against either of them?


----------



## lrhorer

jbernardis said:


> 1) a virtual DJ that would allow you to specify artists and/or genre to include and/or exclude in the selection of a random playlist. You will also have control over how many tracks to add.


'Sounds like a nice feature for the way some folks like to listen to music. I don't think I would be likely to make use of it myself, but I can see its value for others.



jbernardis said:


> 2) a new feature that silences sound effects if music is playing


Oh, definitely!



jbernardis said:


> 3) support for the slide remote when navigating menus - use the 'n' key, for example, to jump to the first artist that starts with 'n'


Well... I don't have a slide remote. It sounds like a nice feature for those who do.



jbernardis said:


> 4) as an offshoot of this, I am thinking of adding an option to be case insensitive in sorting.


Hmm. That one sounds a lot less important, to me.



jbernardis said:


> 5) one last thing I am thinking of - a few months ago I added logic to ignore leading 'the', 'a', and 'an' at the beginning of artist names. I am thinking of extending that logic to include album and track names


Um, what about "The"?



jbernardis said:


> Give me some feedback on the last two items. Does anybody have and argument for or against either of them?


Well, eliminating "The" seems a requirement for (5), and if so, I would say it is more important than (4). Being perfectly self-centered about it, I would say the order of importance is 2 - 5 - 1 - 3 - 4.


----------



## jcthorne

jbernardis said:


> I know I've been preoccupied with other projects recently, but I have a couple of jukebox enhancements in the works:
> 
> 1) a virtual DJ that would allow you to specify artists and/or genre to include and/or exclude in the selection of a random playlist. You will also have control over how many tracks to add.
> 
> 2) a new feature that silences sound effects if music is playing
> 
> 3) support for the slide remote when navigating menus - use the 'n' key, for example, to jump to the first artist that starts with 'n'
> 
> 4) as an offshoot of this, I am thinking of adding an option to be case insensitive in sorting.
> 
> 5) one last thing I am thinking of - a few months ago I added logic to ignore leading 'the', 'a', and 'an' at the beginning of artist names. I am thinking of extending that logic to include album and track names
> 
> Give me some feedback on the last two items. Does anybody have and argument for or against either of them?


The virtual DJ and slide remote functions would be very useful to me. As far as leading a an and THE, I agree they should be ignored in sorts for albums and track names as well.

A quick question, Is there any way to have Jukebox appear under the Music and Photos menu item rather than Showcases? Its very counter intuitive for the spousal unit.....

Thanks!


----------



## jbernardis

I will be posting these changes in the next few days - just a bit more testing.

Regarding the placement within the menu - I have no control over that (that I am aware of). I just present myself as an HME app and TiVo takes over from there. I guess you have a premiere though - because on my series 3, it shows up under "Music, Photos, & Showcases"


----------



## lrhorer

jcthorne said:


> Its very counter intuitive for the spousal unit.....


Ho boy. That's never a good thing. It is, of course, your fault, too. Right?


----------



## jbernardis

I finally posted the changes up on git - follow the link in my signature. This is for version 1.1. Here is a quick summary of the changes:

- logic to skip articles (a, an, the) has been extended to ALL titles - songs, albums, and artists
- added an option to ignore letter case when sorting and searching
- added virtual DJ to allow selection of random playlists based on artist an/or genre
- suppress sound effects during music playback
- added support for the slider remote control - letters can be used when searching through the menu structure


----------



## elenaran

Hi, I just installed jukebox and am having trouble - no audio plays.

pyHME and jukebox open up fine, and I can see all my music and the tags & album art show up fine, but it's completely silent (no sound effects, music, nothing). When I play a song, it looks like it's playing, but no audio comes out.

This is on a Tivo Premiere, with HME/jukebox/pytivo running on a Win7 machine & Python 2.7.

The audio works fine when I stream the music files to the Tivo directly from pyTivo, just not in jukebox.

Any thoughts?


----------



## jbernardis

Not offhand. The fact that the progress bar is moving indicates that the TiVo thinks it is playing. Jukebox only reports the status that the TiVo reports. Could it be some audio setting in either the TiVo or in your sound system?


----------



## elenaran

I doubt it's Tivo or the sound system, as streaming the same music files from pyTivo or TivoDesktop works fine. I even tried Harmonium and it worked fine too.


----------



## elenaran

It might be pyhme - none of the test apps that came installed with it make any sounds either


----------



## elenaran

nevermind - a Tivo restart fixed it


----------



## jbernardis

elenaran said:


> nevermind - a Tivo restart fixed it


I'm glad that solved it. I should have thought of it myself. It's always a good first thing to try.

I was baffled. All jukebox does is provide tivo the URL of the stream source (pytivo in this case). Thereafter, the tivo interacts directly with the stream server for playing the music, and it reports the status of that playback back to jukebox. The fact that jukebox was receiving "progress" reports indicated that the tivo thought it was playing music.

I was going to suggest looking at the pytivo log files, but you solved it first


----------



## Noircogi

I just started using pytivo/phme and jukebox. Thanks for the great work!

Background:
I have a dedicated Linux server for my content. That's where I'm running the tools.

I am using it with a Premiere XL4. I also have the "playing with no sound" problem. If I run the Premiere in SD mode it works perfectly.

If I use the HD interface on the tivo, I generally don't get audio from jukebox. I can play the songs directly from the pytivo share and that works every time. If I play a song in pytivo, then go over to jukebox it will sometimes work. If I restart the Tivo it may also sometimes work, but just changing the UI mode seems to be as likely to resolve the problem.

I'm using HDMI audio output FYI.

Now for my question:
My audio library is set up sorted by artist and album with a "Folder.jpg" file in each album's directory. This works fine with minidlna and directly sharing the library with Windows Media Player or Media Center.

My music is all stored as .mp3 files with full meta-data.

How do I get my "Folder.jpg" album artwork to show up in jukebox? I'd hate to have to duplicate it into the ID3 tags of every song.

Thanks!


----------



## jbernardis

It's not possible right now. I only use the ID3 tags. I will look at the code to see if it would be difficult to do. 

How should this work? Should I use the folder file only if there is no id3? Should it be based on an option?


----------



## Noircogi

Thanks for the quick response!

I would think using the folder image as the default for the directory with an imbedded ID3 image as an override would be perfect.

In minidlna, it's specified like this:


> # this should be a list of file names to check for when searching for album art
> # note: names should be delimited with a forward slash ("/")
> album_art_names=Cover.jpg/cover.jpg/Folder.jpg/folder.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Thumb.jpg/thumb.jpg


----------



## jbernardis

It actually was very simple - here is what I have:

a new ini file option: usefolderimage - set to True or False, default is False
if this is False, behavior as today (I have to protect my current users)
if this is True, then it looks for a file named folder.jpg in the same directory as the mp3 file. If it finds such a file, it uses it, otherwise it uses the ID3 value, if present.

I could allow a list of potential file names, but I don't want to get crazy here.

BTW all of this happens at cache building time. The run-time jukebox hasn't changed at all.

If this is acceptable, I will put the modifications up on git after I do a bit of testing - no later than tomorrow.


----------



## Noircogi

That would work great for me. Thanks again.


----------



## elenaran

Well, looks like I spoke too soon - seems to be a recurring problem. It'll work fine, but then sound will cut out and nothing will fix it until I restart it.


----------



## Noircogi

elenaran said:


> Well, looks like I spoke too soon - seems to be a recurring problem. It'll work fine, but then sound will cut out and nothing will fix it until I restart it.


Try switching your TIVO to use the old-style UI. That seems to fix it.


----------



## jbernardis

I posted version 1.1a up on git just now. I added support for album artwork in external files. It works a little differently than I mentioned above.

A new option - usefolderart - turns the feature on or off. The default value is False (off). Set to True if you want to enable it.

A second option - folderartfiles - is a comma separated list of files that jukebox will look for - in the same directory as the mp3 file - containing the artwork. This list defaults to a single entry: folder.jpg. If you have multiple file names, just put them in a comma separated list. spaces within file names are not a problem (as long as the OS supports it).


----------



## Noircogi

I think you left a debugging exit(0) in the latest BuildCache.py.

After removing that it worked great for me. Thanks a lot.


----------



## jbernardis

Noircogi said:


> I think you left a debugging exit(0) in the latest BuildCache.py.
> 
> After removing that it worked great for me. Thanks a lot.


Yes - thank you - git has been updated.


----------



## elenaran

Noircogi said:


> Try switching your TIVO to use the old-style UI. That seems to fix it.


Thanks - that seems to work, but it's really annoying to have to do this every time it breaks


----------



## jcthorne

I am wondering if my trouble with no sound via HDMI is the same trouble elenaran is experiencing.

Jukebox seems to play fine via audio outputs but no sound via HDMI. Have not tried the SD menus as going back to them for everything is a non-starter. I could eliminate the HDMI connections from the mix but sure seems odd...

Ideas on where to go to troubleshoot / fix this?


----------



## jbernardis

I really don't have any idea what to do about the sound issue. Jukebox has nothing to do with the actual song playback. All it does is give the TiVo a URL of where to get the file. The file itself is actually served by pytivo, so I'm not even involved in that.

I don't think there's anything to do in pytivo either. All it does is provide a stream. 

I believe that the problem lies in the TiVo itself. I'm still using series 3 OLED tivos, and they are working fine for me, but then again they only have the SD interface.


----------



## jcthorne

As part of my troubleshooting, figured I should upgrade to the latest version 1.1a. Added lines to the jukebox.ini file for new folder art options:

usefolderimage = True
folderartfiles = folder.jpg

Launching PythonHME now gives the following error:

Ignoring invalid option (%s) in ini file usefolderimage

Any idea what I did wrong?


----------



## jbernardis

You caught two mistakes. One - obviously the print statement is using a comma instead of a % operator - but that's minor - I'll fix that with the next build.

The other is a typo - despite the jukebox.ini.dist file stating 'usefolderimage' as the option name, the option name is really 'usefolderart'. Make that change in your ini file and you should be OK. I'll also update the dist file with the next release.

Thanks


----------



## jcthorne

jbernardis said:


> You caught two mistakes. One - obviously the print statement is using a comma instead of a % operator - but that's minor - I'll fix that with the next build.
> 
> The other is a typo - despite the jukebox.ini.dist file stating 'usefolderimage' as the option name, the option name is really 'usefolderart'. Make that change in your ini file and you should be OK. I'll also update the dist file with the next release.
> 
> Thanks


Thanks! See what I get for reading instructions?


----------



## jcthorne

I am back to trying to figure out the sound problem with jukebox. Pytivo plays music fine, jukebox does not, at least using HDMI. I have tinkered with it for months. I can get it to work once in a while with a fresh reboot of both the tivo and jukebox but any time both have been running for some time and I go to play music, no sound.

At wits end with this. Really like jukebox but if the HME app cannot play music do to some internal tivo problem, I guess its back to pytivo's text interface. Not as pretty but it does work. Really too bad tivo breaks things in the api and there is no real way to even ask that it be fixed as they really don't support the SDK any more.

Anyone have any ideas what else to try?


----------



## jbernardis

If anybody has any clues to what can be done to solve this issue, I'd appreciate some clues. My biggest difficulty is that I don't have a test platform since my TiVos are Series 3 OLED models, but I'd guess that jcthorne would be a willing tester if I had something I could try.


----------



## jcthorne

Absolutely. It has to be something around the HDMI connection. If I connect directly to the tivo using analog audio cables it works fine, not with the rest of the system but you get the stereo audio. Wish I could be more help.


----------



## wmcbrine

Try toggling the "Dolby Digital to PCM" setting. (Of course this has other problems.)


----------



## jcthorne

wmcbrine said:


> Try toggling the "Dolby Digital to PCM" setting. (Of course this has other problems.)


OK, data point I suppose. Changing the setting from Dolby Digital to PCM jukebox works normally. Change it back to dolby and Jukebox is silent. No reboot, I can toggle back and forth and its repeatable.

These are stereo mp3 files its playing. I noticed its not just the music that is silent. The menu bloops are gone when sound is set for dolby as well.


----------



## cassiusdrow

I am using the Jukebox with both a Series 3 OLED (using component/optical) and a Premiere XL (using HDMI). I have not had audio problems with the jukebox. Both are NOT set to convert "Dolby Digital to PCM".

I am seeing a different issue. When the TiVo button is used to exit the Jukebox while music is playing, the music file is not closed. I have to stop the HME for Python process to release the file.

Edit: Turns out I have to stop both the pyTiVo and HME for Python processes to release the music file. I also tried just using the pyTiVo music directly and had the same issue, so maybe this is really a pyTiVo issue.

Edit 2: Tried exiting with the left arrow and thumbs up while music is playing, same issue.


----------



## xekester

I've installed and configured python27, pyTivo, HME for Python, the Python Image Library and Jukebox. I copied the pyTivo mutagen directory to the jukebox directory, I ran the BuildCache for Jukebox successfully. I started pyTivo in a console window, and in a separate console window I run start.py but I only get to Server Starts. Can someone point me to what's wrong? Config files below.

C:\Python27\Lib\site-packages\HME-Python>start.py
HME Server for Python 0.20
Not using Zeroconf:
Fri Apr 12 14:23:07 2013 JukeBox version 1.1a module initializing
Fri Apr 12 14:23:07 2013 Starting cache file load
Fri Apr 12 14:23:10 2013 Starting sort
Fri Apr 12 14:23:10 2013 Finished - 8169 music files, 1160 albums, 702 album artists, 1066 track artists
Fri Apr 12 14:23:10 2013Cache watcher thread starting - watch interval = 600
Server Starts

No further output and the apps don't appear. Is the issue with HME or is it the app?

Thanks,
xekester

*HME-Python config.ini*
[hmeserver]
port=9032
address=192.168.1.128
zeroconf=False
basepath=C:\Python27\Lib\site-packages\HME-Python
datapath=C:\Python27\Lib\site-packages\HME-Python

apps=picture clock jukebox

[picture]
path=C:\Python27\Lib\site-packages\HME-Python\picture
delay=2
exts=.jpg .png

[jukebox]
path=C:\Python27\Lib\site-packages\HME-Python\jukebox

*pyTivo.conf*
[Server]
port = 9032
ts = on
ffmpeg = C:\pytivo\bin\ffmpeg.exe
tivo_mak = XXXXXXX
tivo_username = XXXXXXXXX
togo_path = \\DiskStation\video\Tivo
tivodecode = C:\pytivo\bin\tivodecode\tivodecode.exe
beacon = 192.168.1.153
tivo_mind = symind.tivo.com:8181
debug = True
tdcat = C:\pytivo\bin\tivodecode\tdcat.exe
tivo_password = XXXXXXX
zeroconf = False

[_tivo_SD]

[_tivo_HD]

[MyPhotos]
type = photo
path = E:\Data\Photos

[MyMusic]
type = music
path = \\Diskstation\Music\iTunes\Music

[MyVideos]
path = \\Diskstation\video\Movies
type = video
force_alpha = True

[MyTVSeries]
path = \\Diskstation\video\TVShows
type = video
force_alpha = True


----------



## wmcbrine

Why did you disable Zeroconf? start.py has no other way to announce (unless you configure old-style beacons, which you haven't, and that's only available in the git version anyway). The only other way you'll see it is if you run it on port 80 and use the TiVo's "Add an App" function.

Oh, you also have them both trying to run on port 9032. That won't work (and you should've seen an error about it from whichever one launched second). They need separate ports. (Which they would have, by default -- there's really no need to specify these.)


----------



## xekester

Ignorance on my part (still learning). I've changed Zeroconf in HME-Python config.ini and pyTivo.config to True. Or should I just remove Zeroconf from both (default to True?)

I've removed the port from the HME-Python config file. I kept the port=9032 in pyTivo.conf.

Now when I run start.py, jukebox runs, displays all menus, I am able to interact with the app, but when I go to play songs, they don't play. *Note to jbernardis: When this happens, the playing screen is displayed, but the progress indicator does not move.*

wmcbrine, Can I assume getting this far means I am past pyTivo and HME-Python issues at this point?

Now my issues are with how I set up my jukebox configuration.
The only odd things I see in the trace are references to Server address and port IDs (see bolded trace below).
My Tivo is at 192.168.1.153.

Thank you wmcbrine for your help (and patience ) in both threads today.

Xekester

C:\Python27\Lib\site-packages\HME-Python>start.py
HME Server for Python 0.20
Fri Apr 12 17:49:34 2013 JukeBox version 1.1a module initializing
Fri Apr 12 17:49:34 2013 Starting cache file load
Fri Apr 12 17:49:36 2013 Starting sort
Fri Apr 12 17:49:36 2013 Finished - 8169 music files, 1160 albums, 702 album artists, 1066 track artists
Fri Apr 12 17:49:36 2013Cache watcher thread starting - watch interval = 600
Server Starts
Registering: jukebox
*192.168.1.153:55297* - - [12/Apr/2013 17:51:15] "GET /jukebox/icon.png HTTP/1.0" 200 -
*192.168.1.153:55298* - - [12/Apr/2013 17:51:24] "GET /jukebox/ HTTP/1.1" 200 -
*192.168.1.153:55298* - - [12/Apr/2013 17:51:24] Starting HME: jukebox
Jukebox thread entering startup
Jukebox thread activating
*Server address = 128.96.11.243:9032*
*192.168.1.153:55298* - - [12/Apr/2013 17:52:48] Ending HME: jukebox
*192.168.1.153:55335* - - [12/Apr/2013 17:52:49] "GET /jukebox/icon.png HTTP/1.0" 200 -


----------



## jbernardis

xekester said:


> Now when I run start.py, jukebox runs, displays all menus, I am able to interact with the app, but when I go to play songs, they don't play. *Note to jbernardis: When this happens, the playing screen is displayed, but the progress indicator does not move.*


Does your pytivo log show anything unordinary? Jukebox passes the URL of your PyTIvo server to the Tivo, and the TiVo actually gets the file from PyTivo. Jukebox has no actual interaction with the playing file - it just reacts to status messages that the TiVo sends as IT (the TiVo) is playing the stream. The status messages are simply used to update the display. Make sure you specify the correct IP address and port of your PyTivo server.


----------



## wmcbrine

xekester said:


> Ignorance on my part (still learning).


When I ask "Why did you disable Zeroconf", it's not a rebuke. I'm trying to find out why you thought it was a good idea to do that, so that perhaps I can correct whatever bit of documentation gave you that impression, so the next person doesn't do that.



> _wmcbrine, Can I assume getting this far means I am past pyTivo and HME-Python issues at this point?_


Too early to say that. Can you play music through the TiVo's built-in MP3 player?



> _*Server address = 128.96.11.243:9032*_


This doesn't look like the right address.


----------



## lrhorer

wmcbrine said:


> This doesn't look like the right address.


Indeed, it does not. That is a routable address, and exceedingly few people would want their pyTivo server on a routable port. The other IP addresses he displays are all on 192.168.1/24, which is a very common nonroutable subnet. One would ordinarily expect all the hosts to be on the same (nonroutable) subnet.


----------



## xekester

jbernardis, I don't have logging enabled for pyTivo or HME-Python. I don't know how to enable logging yet.
However, I disabled the pyTivo service and then ran it on a console window. When I run start.py in another console window and go to play a song I got:
*on start.py console:*

Server Starts
Registering: jukebox
192.168.1.153:48025 - - [12/Apr/2013 23:06:23] "GET /jukebox/icon.png HTTP/1.0" 200 -
192.168.1.153:48026 - - [12/Apr/2013 23:06:39] "GET /jukebox/ HTTP/1.1" 200 -
192.168.1.153:48026 - - [12/Apr/2013 23:06:39] Starting HME: jukebox
Jukebox thread entering startup
Jukebox thread activating
*Server address = 128.96.11.243:9032*

*on pyTivo console*
no new output at this point.

wmcbrine, No, no offense taken or meant. I am just grateful that you guys
are taking the time to support these projects. For me, the hardest part has been to try and pull all of the
pieces together.

If by built-in MP3 player you mean just using pyTivo-->MyMusic share, then yes the same songs play correctly. Harmonium also works for the same songs.

I am still trying to figure out where that stray Server IP address came from, as well as the strange port IDs (e.g. 48025 or is that a thread ID?, or ????).

Thanks Guys,
Xekester


----------



## xekester

The problem was that I needed to specify in jukebox.ini:

serverip=192.168.1.128
serverport=9032

As specified in jbernadis's jukebox readme (DOH!)

Music is playing fine now. 

Thank you all for your support.

Onwards and upwards!

Xekester


----------



## fxsknr

I have a specific mp3 file that won't play in jukebox. The slider stays at 0:00 and doesn't move. No sound comes out and from that moment on and I'm unable to play any other song with any music player on the tivo (including Pandora) until I reboot the tivo. The same track plays just fine with pytivo by itself. Other mp3 tracks play ok, so jukebox seems to be configured right.

I'm running into this issue on a Tivo HD with the latest software available. I'm also using the latest versions of pytivo, pyhme, and jukebox.

*Here is my configuration for pytivo:*

[Server]
port = 9032
ffmpeg = C:\pytivo\bin\ffmpeg.exe
tivodecode = C:\pytivo\bin\tivodecode.exe

[_tivo_SD]

[_tivo_HD]

[MyMusic]
path = C:\Users\Corey\Music\iTunes\iTunes Music
type = music

*Here is my configuration for pyhme:*

[hmeserver]
apps=jukebox

*Here is my configuration for jukebox:*

[jukebox]
serverip = 192.168.1.6
serverport = 9032
pytivo = C:\pytivo\pyTivo.conf
preloadcache = False
cachewatchinterval = 600
autoswitchnp = 120
ignoreidle = False
ignorearticles = False
lyricindent = -1
usefolderimage = False
folderartfiles = ['folder.jpg']
screensaver = 600
ignorecase = True
skin = None
albumshuffle = False
albumloop = False
artistshuffle = False
artistloop = False
playlistshuffle = False
playlistloop = False
trackshuffle = True
trackloop = False


----------



## jbernardis

It's I possible to say. I sent you a pm with my email address. Could you send me the file?


----------



## wmcbrine

Given how easily the TiVo gets into that state (i.e., where it won't play any more MP3s), it might be coincidence rather than that specific file. But, try adding "force_ffmpeg = True" to the "MyMusic" section of your pyTivo.conf.


----------



## xekester

JBernardis,

It would be nice if Jukebox could use exported iTunes playlists (.m3u).
Here's a sample of two songs from an m3u playlist file (the first line in the sample is the first line from the file):

#EXTM3U
#EXTINF:335,The Crosswords & The Safety Pins - Battered Ornaments
\\DiskStation\Music\iTunes\Music\Battered Ornaments\Mantle-Piece\11-04 The Crosswords & The Safety Pins.mp3
#EXTINF:248,Staggered - Battered Ornaments
\\DiskStation\Music\iTunes\Music\Battered Ornaments\Mantle-Piece\1-05 Staggered.mp3

And, it would be nice to able to specify the Playlist's folder location (other than in the jukebox directory.
-Not have to maintain multiple playlist directories for different devices/apps.

I really like the improvements you've made over the Harmonium app.

Thanks for your consideration,
Xekester


----------



## jbernardis

So far as I know, jukebox DOES read m3u files directly. I've not done extensive testing on it, so if you have a specific issue let me know. The only caveat I would have is the following: If jukebox reads in an M3U playlist, and you edit it in any way, it will be saved as an equivalent JPL file - the M3U file will remain unchanged, but it will no longer be loaded on startup (actually at present, the M3U file will be deleted - more on this below)

Regarding the playlist directory, I have modified the code to support this. A new ini file option allows you to specify a location, and the default location will remain what it is today. While making this change, I also made the above mentioned modification whereby it will no longer delete an M3U file if it is edited - it will just ignore it in the future.

I have put this up on GIT as version 1.1b.


----------



## xekester

jbernardis,

Wow, that was quick! Thanks.

I will give it a try later today after my houseguest leaves.

Xekester


----------



## jbernardis

Regarding the bjork file that wouldn't play in Jukebox. The issue IS with the directory name. In the short term, the problem can be solved by changing the name of the directory to "bjork" and then rebuilding the cache.

Now the issue: The path of the file is formed into a URL that is passed to the TiVo. The URL is as follows:


Code:


http://192.168.1.201:9032/My%20Music/Bj%C3%B6rk/01%20Hunter.mp3

When pytivo gets this URL, the following appears in its log:



Code:


2013-04-23 19:24:34,589 ERROR pyTivo: Exception during request from ('192.168.1.103', 1561)
Traceback (most recent call last):
  File "SocketServer.py", line 463, in process_request_thread
    self.finish_request(request, client_address)
  File "SocketServer.py", line 254, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/pytivo/httpserver.py", line 64, in __init__
    client_address, server)
  File "SocketServer.py", line 521, in __init__
    self.handle()
  File "BaseHTTPServer.py", line 316, in handle
    self.handle_one_request()
  File "BaseHTTPServer.py", line 310, in handle_one_request
    method()
  File "/usr/local/pytivo/httpserver.py", line 95, in do_GET
    self.handle_file(query, splitpath)
  File "/usr/local/pytivo/httpserver.py", line 165, in handle_file
    plugin.send_file(self, path, query)
  File "/usr/local/pytivo/plugins/music/music.py", line 102, in send_file
    fsize = os.path.getsize(fname)
  File "posixpath.py", line 139, in getsize
    return os.stat(filename).st_size
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 15: ordinal not in range(128)

The line of code I use to form the URL is as follows:


Code:


url = "http://%s:%s/%s" % (self.server_host, self.server_port, quote(fn))

where quote is an alias for urllib.quote.


----------



## fxsknr

Thanks. I appreciate you finding a work around.


----------



## wmcbrine

jbernardis said:


> When pytivo gets this URL, the following appears in its log:


Makes no sense, especially since fxsknr said it works from the pyTivo share. Can you send me a more complete log?

Edit: Oh, before that -- can you confirm that it works for you from the pyTivo share? If not, then you have a different issue from fxsknr. (You're using different OSes, I note, that handle Unicode differently. He's got Windows; you've got some kind of Unix. Which kind would be good to know... I pass Unicode names to os.path.getsize(), and they work in OS X and Ubuntu.)


----------



## jbernardis

I'm not sure what happened, but it now plays fine for me both in pytivo and in jukebox. Here is what I did.

1) I had left the directory with an ascii name, so I renamed it back to the original name
2) just to clear out memory, I stopped and then restart pytivo, emptying the debug.log file in between.
3) I rebuilt the jukebox cache since the old cache pointed to a file with the ascii name
4) I played the file directly with pytivo, and it played fine.
5) I then moved into jukebox and selected the file for playing thinking that it would fail, but in fact it played.
6) I stopped everything, pytivo AND pyhme, and then restarted them, I went back into jukebox, and now it plays.

I have no idea why this happened!!


oh - BTW - I run both the HME app and pytivo on my netgear NAS which, I believe, is a debian-based linux.


----------



## fxsknr

jbernardis,

I tried your suggestion and it didn't work for me. I am indeed running Windows with Python 2.7 32 bit on Windows 8 64 bit. I am finding that jukebox quite frequently hangs up my tivo forcing me to reboot. It happens on many songs, not just the one I sent you. This problem doesn't seem to have with pytivo alone. Is there a way to log whats happening so I can send it to you for analysis?

fxsknr


----------



## jbernardis

jukebox standard output goes to the same place as the hme standard output - so however you started hme (start.py) wherever you redirect your output to - that's the logging information that would be available to you.

The pytivo log is also of interest. Jukebox is not involved in the playing of the song at all. It passes the URL of the song to the TiVo, and TiVo retrieves the song using that URL. The URL happens to point to pytivo, and pytivo serves up the file. As the song is being played, tivo sends update messages to jukebox which jukebox uses to update its display.

If your tivo is getting hung up, I doubt there's going to be anything of interest in the log, but it doesn't hurt to look. What model tivo do you use? There have been reported issues with the premier series. I don't own a premier - my tivos are both the original series 3, and I have not noticed any issues.


----------



## cassiusdrow

It looks like the lyrics feature is no longer working when it tries to retrieve lyrics from azlyrics (local files still work). Any ideas?


----------



## jbernardis

That's a feature whose code I haven't touched for months if not longer. Last time I used it it was working fine. It was never able to work 100% of the time. If there's a specific artist/song that it can't find lyrics for let me know the exact artist and song name and I'll see if I can improve the search algorithm.


----------



## cassiusdrow

I haven't been able to get it to retrieve anything in months. I have also verified that azlyrics actually has the lyrics for the songs I was trying and it did. I was thinking maybe either something changed on azlyrics or they are blocking it. Is it working for you?


----------



## jbernardis

It IS working for me - although I only verified for 4 or 5 songs. If you edit the file GetLyrics.py, on about line 119, there is an assignment "verbose=False". Change that to "verbose=True" restart everything, and try to retrieve lyrics. Check and see if the log gives you any important information. You might post it here or send it to me with PM


----------



## jbernardis

Actually I should apologize to CassiusDrow for not paying attention to this sooner, but apparently azlyrics.com changed the format of their search HTML so my screen scraping logic broke down. I "fixed" it and it seems to be retrieving lyrics again, but whenever something is reverse-engineered like this, there is always the real possibility that something was missed.

Try it out - git has been updated. If you are having trouble retrieving lyrics, it would help me to know the exact artist and song title you are looking for. And remember - I never represented that this would work 100% of the time. There are going to be songs, especially those with strange characters and/or punctuation, that my logic will fail on.


----------



## cassiusdrow

The lyrics retrieval is working again. Thanks for looking into it and fixing it. I understand the limitations regarding special characters and such.


----------



## cassiusdrow

I made some changes to how I store my music library and I noticed that the cache building process will not follow symlinked directories on linux. I changed line 106 of BuildCache.py from



Code:


	tree = os.walk(root)

to



Code:


	tree = os.walk(root, followlinks=True)

and it works now. Just thought you might like to include this change.


----------



## jbernardis

cassiusdrow said:


> ...Just thought you might like to include this change.


GIT has been updated - thanks.


----------

