[mythtv] mythmusic w/o id3 and setting to limit how often rereads dir

Benjamin Binford mythtv-dev@snowman.net
Sat, 7 Dec 2002 18:47:51 -0500


Here's the patch that implements the algorithm below. It works pretty well on my medium-small size mp3 collection (600-700 mp3's), but I'm interested to see how it works for other people. I don't have a gcc 2.x compiler to try it on either so your mileage may vary. All the changes are confined to mythmusic's main.cpp, but if you want to use some of the stuff for your mythvideo maybe we should refactor some of it into libmyth. Feel free to mail me directly if you want to use it- I have some ideas on how to rip it out and make it more general.

On Sat, Dec 07, 2002 at 02:23:13PM -0500, Benjamin Binford wrote:
> 1) Grab the full path to each file under the music directory and stuff it into a map - full path is the key, the value is boolean indicating whether or not it's in the database.
> 
> 2) Build several really large sql queries of the form 
> 
> SELECT filename FROM musicmetadata WHERE filename in ("path1", "path2")
> 
> Where pathX etc.. is the full path to each of the files underneath the music directory. I have to build a bunch because there is a max size for a mysql query.
> 
> 3) Loop over each query, updating the map created in 1) to true for each file found in the database.
> 
> 4) Loop over everything in the map, for anything not found in the database add it in. 
> 
> I just hacked it together this morning because I woke up at like 6AM and couldn't sleep, so I just need to do a little testing. I'll be sending a patch out to the list either tonight or tomorrow morning (assuming I don't run into any major problems)
> 
> 
> On Sat, Dec 07, 2002 at 11:50:05AM -0500, Mark Musone wrote:
> > Can you give a quick summary of what you did?
> > 
> > i'm just finishing up "mythvideo" for video files, and used the mythmusic
> > as a skeleton, and therefore am using that same slow
> > method. i'm going to change it to make it cache things and do things
> > quicker..but if you already have it, i'd rather take it from you.
> > 
> > 
> > -Mark
> > 
> > 
> > On Sat, Dec 07, 2002 at 11:35:36AM -0500, Benjamin Binford wrote:
> > > On Sat, Dec 07, 2002 at 02:06:27AM -0500, Chris Pinkham wrote:
> > > <snip>
> > > > My second idea concerns mythmusic scanning the directory every X times
> > > > that it starts up.  I'd prefer that it never did the scan unless I wanted
> > > > it to (ie, picking a menu item), but will probably take the easy road
> > > > out right now and make the just make it a setting in the config file
> > > > to scan every X startups.  I think someone said it does it every other
> > > > time right now which can get to be really slow.  I have all my mp3 files
> > > > stored on an nfs/samba server so mythmusic reading them can be slow.
> > > 
> > > I just finished up some work on this that I'll be testing today and tomorrow. It still does the scan every time it starts up, but I think I've managed to optimize the access a bit. I've gone from mythmusic taking about 4.5s to start (as reported by time), to just over half a second. A patch will be sent along shortly.
> > > _______________________________________________
> > > mythtv-dev mailing list
> > > mythtv-dev@snowman.net
> > > http://www.snowman.net/mailman/listinfo/mythtv-dev
> > _______________________________________________
> > mythtv-dev mailing list
> > mythtv-dev@snowman.net
> > http://www.snowman.net/mailman/listinfo/mythtv-dev
> 
> -- 
> GRAMMAR IS NOT A TIME OF WASTE
> GRAMMAR IS NOT A TIME OF WASTE
> GRAMMAR IS NOT A TIME OF WASTE
> GRAMMAR IS NOT A TIME OF WASTE
> 
> 	Bart Simpson on chalkboard in episode AABF10
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev@snowman.net
> http://www.snowman.net/mailman/listinfo/mythtv-dev

-- 
Must destroy mankind!  (His watch alarm goes off)  Ooh, lunchtime!

		-- Homer Simpson
		   Homer Goes To College