Add metadata to items after directory has loaded?

  Thread Rating:
  • 0 Vote(s) - 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):
match=re.compile('<a name=i id=(.+?)></a><img class=star><a href=/(.+?)>(.+?)<br>').findall(link)
imdb,url,name in match:

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

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,506
Joined: Dec 2008
Reputation: 28
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