View Full Version : Playlist shuffle in pyTivo 2008.04.14
jhowell
05-02-2008, 08:18 PM
I have been trying the TiVo Desktop software to access music and photos on my Series 3 TiVos. I have music library of about 10,000 songs and I have about 50 playlists (.m3u files) containing anywhere from a few songs to a few thousand. I use shuffle with the large playlists for variety.
The TiVo Desktop seems to work pretty well, except for large playlists. Those often produce an error "A problem has occurred while accessing the server...". It seems that some resource or time limit is being exceeded.
I read good things about pyTivo in this forum so I thought that I would try it instead. I installed KRKeegan's Windows Installer version 2008.04.14, which was quick and easy. I am able to use this to play even very large playlists without the server error, but I have noticed a different problem.
Playing a playlist with pyTivo always plays the songs in order, even when shuffle is set. I did some testing and it does shuffle directories of songs, just not playlists.
I don't know Python (yet) and haven't been able to debug this and was wondering if anyone else had run into this and had a solution.
wmcbrine
05-02-2008, 10:03 PM
Well, I wouldn't call it a bug... I'd just thought that playlists were always supposed to be in playlist order, and I didn't check what TiVo Desktop did. Sorry. I'll look into changing it.
windracer
05-02-2008, 10:35 PM
I mentioned this to you back in March (http://pytivo.krkeegan.com/post1228.html#1228). ;)
jhowell
05-02-2008, 11:07 PM
Thanks for the quick response, wmcbrine. TiVo Desktop definitely shuffles playlists in shuffle mode and this can be useful as I said in my original post.
Knowing that the non-shuffling of playlist was intentional on your part, I took a look at music.py and I could see that sorting is only implemented in get_files, and not in get_playlist. It would probably be a good learning experience for me to hack up a change to allow sorting in playlists, but I won’t bother if you intend to implement this yourself.
Also, somewhat hijacking my own thread I have a question about photos. I was thinking about making a variation on the photo plugin to allow the display of captions extracted from EXIF or IPTC metadata. I was thinking along the lines of using the graphics library to produce on-the-fly for each photo a new jpeg that has the text of the caption overlaid on it. I figured that making the caption part of the graphic sent to the TiVo would probably be the only way to add it. Do you have any thoughts or suggestions on this idea?
wmcbrine
05-03-2008, 01:27 AM
I agree, that would be the only way to do it -- there's reference to a "Caption" tag in the HMO spec, but it's not implemented on the TiVo.
I don't have any captioned pictures myself, so this isn't something I've looked into.
jhowell
05-04-2008, 10:39 PM
I took some time today to learn the basics of python enough to modify music.py to shuffle playlists. But in the course of testing my change I came across a problem in pyTivo. One of my playlists is composed of songs that are not on the same path as the rest of my music. TiVo Desktop handles it properly, but pyTivo is unable to allow scrolling through the playlist, printing "anchor not found" messages. It is also unable to play the songs. It seems that the code assumes in a number of places that all of the files referenced by a plugin will have the same base path, but this is not always the case with files selected by a playlist. I'm not sure if this was a known problem/restriction.
Now I’m ready to take a look at doing photo captions.
wmcbrine
05-05-2008, 06:36 AM
Yes, it's known.
bacevedo
05-09-2008, 12:54 PM
Well, I wouldn't call it a bug... I'd just thought that playlists were always supposed to be in playlist order, and I didn't check what TiVo Desktop did. Sorry. I'll look into changing it.
Thanks - I just installed pyTivo and that is probably the one thing that I wish it did. Everything else works great! Thank you for your time and commitment giving us this free product. Being a software engineer myself (actually now in Info Security), I know the time commitments it takes to do stuff on the side.
Bryan
bacevedo
05-10-2008, 09:26 PM
I took some time today to learn the basics of python enough to modify music.py to shuffle playlists.
Could you paste in your changes here that you made to shuffle playlists? I am looking at the music.py file and could probably figure it out, but if you already did it and it works, I can just as easily cut and paste.
Thanks!
Bryan
jhowell
05-10-2008, 10:04 PM
Could you paste in your changes here that you made to shuffle playlists? I am looking at the music.py file and could probably figure it out, but if you already did it and it works, I can just as easily cut and paste.
Bryan
Sure. I modified get_playlist in music.py to add code to randomize the list, based on how it was already done in get_files. See below:
def get_playlist(self, handler, query):
subcname = query['Container'][0]
cname = subcname.split('/')[0]
try:
url = subcname.index('http://')
list_name = subcname[url:]
except:
list_name = self.get_local_path(handler, query)
recurse = query.get('Recurse',['No'])[0] == 'Yes'
playlist = self.parse_playlist(list_name, recurse)
# JRH 05/04/2008
sortby = query.get('SortOrder', ['Normal'])[0]
if 'Random' in sortby:
self.random_lock.acquire()
if 'RandomSeed' in query:
random.seed(query['RandomSeed'][0])
random.shuffle(playlist)
self.random_lock.release()
if 'RandomStart' in query:
start = unquote(query['RandomStart'][0])
local_base_path = self.get_local_base_path(handler, query)
start = start.replace(os.path.sep + cname, local_base_path, 1)
filenames = [x.name for x in playlist]
try:
index = filenames.index(start)
i = playlist.pop(index)
playlist.insert(0, i)
except ValueError:
print 'Playlist RandomStart not found:', start
# Trim the list
return self.item_count(handler, query, cname, playlist)
bacevedo
05-12-2008, 12:25 PM
Thank you! I updated and it works very nicely!
Question for you jhowell - are you running on Windows or Linux? I am wondering if you see the behavior where you have the ffmpeg exe stick around in Task Manager if you use the Ch+ or Ch- keys to skip to the next or previous track? If others see it, then I know it's not my setup, but if it works fine for others, then I'll need to figure out why mine doesn't.
Thanks,
Bryan
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.