Hello all, I've spent some time working on a movie poster plugin that can search for and retrieve movie posters. I'm doing this to support a movie library plugin that I'm creating. I've ran into a snag and I'm looking for some feedback.
Let me start by telling how I wanted to implement the plugin. I've created a PosterProvider base class that the resource provider will use. Each web site will have an instance of PosterProvider created that extends the base functionality and implements the logic to scrape the pages and return the urls for the posters. These poster providers are created in the resource provider and stored in a list which is queried in order, so that the first provider in the list is the preferred provider and the last in the list would be used only if all others failed or the user wanted results from all providers. The resource provider would support three types of URIs. movie-poster://title/.* : : query to return urls for movie posters for the title specified. This will return the results from the first poster provider to return a list of poster urls that is not empty. This call is designed to be the default case when the user just wants a poster to display for the movie. The list holding the providers would be used to determine which results are preferred over the others. movie-poster://title/all/.* : query to return urls for movie posters for the title specified. This command will return the results from all poster providers. The purpose of this method is to return all posters so that the user can select the poster that they wish to use. In this case we want all of the choices and efficiency is not a factor. .* : during initialization this provider will ask each PosterProvider instance which urls it supports. These urls will be used to return the poster images. To determine the actual urls, one would have to see each of the MoviePosterProviders that are in use. The problem that I've encountered deals with defers. Lets say we are in the get method of the resource provider. It looks at the url and determines that the user wants to search for a poster. The user wants the first poster we can find. For the code to do this it must loop through the providers and fire off a search. I believe that the searches can each return a defer which will be put in a deferredlist. The deferredlist will be returned from the get() method. I think I would have to extend the deferredlist and add custom logic to look at the results of the defers that return data to determine when to return the results (fire the callback for the deferredlist). The list of defers can fire in any order and since we want to use the prefered provider, we will need to wait for it before checking the results of the second or third provider. This seems to be cumbersome. The same logic could apply to the resource provider searching for all posters we can find without the need for a custom deferredlist. At this point I'm wondering if you guys have a better idea. When I step back and look at the problem as a consumer of the plugin, I don't care where the poster comes from, I just want the best poster available. This leads me to want a single movie poster plugin instead of one for each web site. That way the logic of knowing which site returns the best posters can be contained in one place instead of with each consumer. The other issue I'm wondering about is whether I should just support two urls. One to get all posters we can find and one to retrieve the poster image itself. My thinking is that if I'm going to have to search all web sites even when I only want the first poster we find, the it may make more sense to keep it simple. I feel like I'm rambling a bit, so you guys read this over and let me know if it makes sense. I'm open to suggestions. I've got the code to do the scraping ready so this shouldn't take long once I figure out how is best to architect the plugin. Thanks, -- Trey ____________________________________________________________ Click to become an artist and quit your boring job. http://thirdpartyoffers.juno.com/TGL2131/fc/Ioyw6iifPHnD63KcbgjgFqcM8GA5f9H8vri3I6Aj3exga8LdvAMihx/
