mmmmmtasty / SportScanner

Scanner and Metadata Agent for Plex that uses sportdb
115 stars 31 forks source link

League matching #16

Closed hjone72 closed 8 years ago

hjone72 commented 8 years ago

Here are a few changes I made to the way leagues are matched.

I wasn't sure why each league was loaded on the first attempt, I've changed this to attempt to match the sport against the already loaded 'potential leagues' which already has the 'standard name'. If there is a match get the league details. If the above fails then call each league and try to match against the alternate names.

I made use of a dict when loading each leagues details from TSDB so that if that step failed, we wouldn't need to load them all again from TSDB.

I also changed the continue to break. I couldn't see a reason to continue to search through the 'potential' leagues?

mmmmmtasty commented 8 years ago

I think cached_leagues needs to be declared in a higher scope to be reusable further down the script. I don't think it is actually declared at the point you try and use it as a cache.

Secondly, if we immediately find a perfect match we make the same GetLeagueDetails() call. Shall we also save that into the cache to be used later?

hjone72 commented 8 years ago

That is a way better idea than what I've done! I was only thinking about caching the results while making each call to search.

mmmmmtasty commented 8 years ago

Nice. You shouldn't be setting cached_leagues[i]['idLeague'] though right? Just cached_leagues['idLeague']?

hjone72 commented 8 years ago

Where is set cached_leagues[i]['idLeague'] set? You're correct we should be using idLeague as the key for the dict.

mmmmmtasty commented 8 years ago

Sorry I wrote it wrong. Line 136 should use the league id not i as the key