Add metadata to items after directory has loaded?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
anarchintosh Offline
Senior Member
Posts: 279
Joined: Jul 2010
Reputation: 4
Question  Add metadata to items after directory has loaded?
Post: #1
for my plugin, the site i am scraping for movies (MOVIEINDEX) provides imdb links, so i made a tiny imdb scraper to get poster (Get_Meta):

PHP Code:
def MOVIEINDEX(url):
        
link=GetURL(url)
        
match=re.compile('<a name=i id=(.+?)></a><img class=star><a href=/(.+?)>(.+?)<br>').findall(link)
        for 
imdb,url,name in match:
                
name=CLEANUP(name)
                
addDir(name,iceurl+url,100,'')
                
Get_Meta(name,imdb)

def Get_Meta(name,url):
     
url='http://www.imdb.com/title/tt'+url
     req 
urllib2.Request(url)
     
req.add_header('User-Agent''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
     
response urllib2.urlopen(req)
     
link=response.read()
     
response.close()
     
get_meta=re.compile('id="img_primary">.+?<img src="(.+?)\n.+?Poster"'re.DOTALL).findall(link)
     for 
imgurl in get_meta:
          
listitem xbmcgui.ListItem(name)
          
listitem.setThumbnailImage(imgurl

the problem is that this gives me a massive waiting time for directory to load as it scrapes all the relevant imdb pages....
is there a way to have the imdb scraping and icon adding going on as in the backgroung as i am browsing the movie directory?
(similiar to the Apple Trailers plugin)
find quote
Sranshaft Offline
Posting Freak
Posts: 1,434
Joined: Dec 2008
Reputation: 25
Location: Melbourne, Australia
Post: #2
My python isn't really up to snuff and someone with a little more knowledge might be able to correct me but I would think throwing the image fetching into a separate thread would help with this. Or if it's available an async image downloading function. At least that what I would do if this was C#.
find quote