imdb/ofdb: allow to select different event than the current one in eventinfo hook
[enigma2-plugins.git] / imdb / src / plugin.py
1 # -*- coding: utf8 -*-
2 from Plugins.Plugin import PluginDescriptor
3 from twisted.web.client import downloadPage
4 from enigma import ePicLoad
5 from Screens.Screen import Screen
6 from Screens.EpgSelection import EPGSelection
7 from Components.ActionMap import ActionMap
8 from Components.Pixmap import Pixmap
9 from Components.Label import Label
10 from Components.ScrollLabel import ScrollLabel
11 from Components.Button import Button
12 from Components.AVSwitch import AVSwitch
13 from Components.MenuList import MenuList
14 from Components.Language import language
15 from Components.ProgressBar import ProgressBar
16 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
17 import re
18 import htmlentitydefs
19 import urllib
20
21 class IMDBEPGSelection(EPGSelection):
22         def __init__(self, *args):
23                 EPGSelection.__init__(self, *args)
24                 self.skinName = "EPGSelection"
25                 self["key_green"].setText(_("Lookup"))
26
27         def infoKeyPressed(self):
28                 self.timerAdd()
29
30         def timerAdd(self):
31                 cur = self["list"].getCurrent()
32                 evt = cur[0]
33                 sref = cur[1]
34                 if not evt: 
35                         return
36
37                 self.session.open(
38                         IMDB,
39                         evt.getEventName()
40                 )
41
42         def onSelectionChanged(self):
43                 pass
44
45 class IMDB(Screen):
46         skin = """
47                 <screen name="IMDB" position="90,95" size="560,420" title="Internet Movie Database Details Plugin" >
48                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
49                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
50                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
51                         <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
52                         <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#9f1313" transparent="1" />
53                         <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
54                         <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#a08500" transparent="1" />
55                         <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1" />
56                         <widget name="titellabel" position="10,40" size="330,45" valign="center" font="Regular;22"/>
57                         <widget name="detailslabel" position="105,90" size="445,140" font="Regular;18" />
58                         <widget name="castlabel" position="10,235" size="540,155" font="Regular;18" />
59                         <widget name="extralabel" position="10,40" size="540,350" font="Regular;18" />
60                         <widget name="ratinglabel" position="340,62" size="210,20" halign="center" font="Regular;18" foregroundColor="#f0b400"/>
61                         <widget name="statusbar" position="10,404" size="540,16" font="Regular;16" foregroundColor="#cccccc" />
62                         <widget name="poster" position="4,90" size="96,140" alphatest="on" />
63                         <widget name="menu" position="10,115" size="540,275" zPosition="3" scrollbarMode="showOnDemand" />
64                         <widget name="starsbg" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/IMDb/starsbar_empty.png" position="340,40" zPosition="0" size="210,21" transparent="1" alphatest="on" />
65                         <widget name="stars" position="340,40" size="210,21" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/IMDb/starsbar_filled.png" transparent="1" />
66                 </screen>"""
67
68         def __init__(self, session, eventName, args = None):
69                 self.skin = IMDB.skin
70                 Screen.__init__(self, session)
71
72                 self.eventName = eventName
73
74                 self.dictionary_init()
75
76                 self["poster"] = Pixmap()
77                 self.picload = ePicLoad()
78                 self.picload.PictureData.get().append(self.paintPosterPixmapCB)
79
80                 self["stars"] = ProgressBar()
81                 self["starsbg"] = Pixmap()
82                 self["stars"].hide()
83                 self["starsbg"].hide()
84                 self.ratingstars = -1
85
86                 self["titellabel"] = Label("The Internet Movie Database")
87                 self["detailslabel"] = ScrollLabel("")
88                 self["castlabel"] = ScrollLabel("")
89                 self["extralabel"] = ScrollLabel("")
90                 self["statusbar"] = Label("")
91                 self["ratinglabel"] = Label("")
92                 self.resultlist = []
93                 self["menu"] = MenuList(self.resultlist)
94                 self["menu"].hide()
95
96                 self["key_red"] = Button(self._("Exit"))
97                 self["key_green"] = Button("")
98                 self["key_yellow"] = Button("")
99                 self["key_blue"] = Button("")
100
101                 # 0 = multiple query selection menu page
102                 # 1 = movie info page
103                 # 2 = extra infos page
104                 self.Page = 0
105
106                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "MovieSelectionActions", "DirectionActions"],
107                 {
108                         "ok": self.showDetails,
109                         "cancel": self.close,
110                         "down": self.pageDown,
111                         "up": self.pageUp,
112                         "red": self.close,
113                         "green": self.showMenu,
114                         "yellow": self.showDetails,
115                         "blue": self.showExtras,
116                         "showEventInfo": self.showDetails
117                 }, -1)
118
119                 self.getIMDB()
120
121         def dictionary_init(self):
122                 syslang = language.getLanguage()
123                 if syslang.find("de") is -1:
124                         self.IMDBlanguage = ""  # set to empty ("") for english version
125                 else:
126                         self.IMDBlanguage = "german." # it's a subdomain, so add a '.' at the end
127
128                 self.dict = {}
129                 self.dict["of"]="von"
130                 self.dict[" as "]=" als "
131                 self.dict["Ambiguous results"]="Kein eindeutiger Treffer"
132                 self.dict["Please select the matching entry"]="Bitte passenden Eintrag auswählen"
133                 self.dict["No IMDb match."]="Keine passenden Einträge gefunden."
134                 self.dict["IMDb query failed!"]="IMDb-Query fehlgeschlagen!"
135                 self.dict["No details found."]="Keine Details gefunden."
136                 self.dict["no user rating yet"]="noch keine Nutzerwertung"
137                 self.dict["Cast: "]="Darsteller: "
138                 self.dict["No cast list found in the database."]="Keine Darstellerliste in der Datenbank gefunden."
139                 self.dict["Exit"]="Beenden"
140                 self.dict["Extra Info"]="Zusatzinfos"
141                 self.dict["Title Menu"]="Titelauswahl"
142
143                 self.htmltags = re.compile('<.*?>')
144
145                 self.generalinfomask = re.compile(
146                 '<h1>(?P<title>.*?) <.*?</h1>.*?'
147                 '(?:.*?<h5>(?P<g_director>Regisseur|Directors?):</h5>.*?>(?P<director>.*?)</a>)*'
148                 '(?:.*?<h5>(?P<g_creator>Sch\S*?pfer|Creators?):</h5>.*?>(?P<creator>.*?)</a>)*'
149                 '(?:.*?<h5>(?P<g_seasons>Seasons):</h5>(?:.*?)<a href=\".*?\">(?P<seasons>\d+?)</a>\s+?(?:<a class|\|\s+?<a href="episodes#season-unknown))*'
150                 '(?:.*?<h5>(?P<g_writer>Drehbuch|Writer).*?</h5>.*?>(?P<writer>.*?)</a>)*'
151                 '(?:.*?<h5>(?P<g_premiere>Premiere|Release Date).*?</h5>\s.*?\n?(?P<premiere>.*?)\n\s.*?<)*'
152                 '(?:.*?<h5>(?P<g_alternativ>Alternativ|Also Known As):</h5>(?P<alternativ>.*?)<br>\s{0,8}<a.*?>(?:mehr|more))*'
153                 '(?:.*?<h5>(?P<g_country>Produktionsland|Country):</h5>.*?<a.*?>(?P<country>.*?)</a>(?:.*?mehr|\n</div>))*'
154                 , re.DOTALL)
155
156                 self.extrainfomask = re.compile(
157                 '(?:.*?<h5>(?P<g_tagline>Werbezeile|Tagline?):</h5>\n(?P<tagline>.+?)<)*'
158                 '(?:.*?<h5>(?P<g_outline>Kurzbeschreibung|Plot Outline):</h5>(?P<outline>.+?)<)*'
159                 '(?:.*?<h5>(?P<g_synopsis>Plot Synopsis):</h5>(?:.*?)(?:<a href=\".*?\">)*?(?P<synopsis>.+?)(?:</a>|</div>))*'
160                 '(?:.*?<h5>(?P<g_keywords>Plot Keywords):</h5>(?P<keywords>.+?)(?:mehr|more</a>|</div>))*'
161                 '(?:.*?<h5>(?P<g_awards>Filmpreise|Awards):</h5>(?P<awards>.+?)(?:mehr|more</a>|</div>))*'
162                 '(?:.*?<h5>(?P<g_runtime>L\S*?nge|Runtime):</h5>(?P<runtime>.+?)<)*'
163                 '(?:.*?<h5>(?P<g_language>Sprache|Language):</h5>(?P<language>.+?)</div>)*'
164                 '(?:.*?<h5>(?P<g_color>Farbe|Color):</h5>(?P<color>.+?)</div>)*'
165                 '(?:.*?<h5>(?P<g_aspect>Seitenverh\S*?ltnis|Aspect Ratio):</h5>(?P<aspect>.+?)(?:mehr|more</a>|</div>))*'
166                 '(?:.*?<h5>(?P<g_sound>Tonverfahren|Sound Mix):</h5>(?P<sound>.+?)</div>)*'
167                 '(?:.*?<h5>(?P<g_cert>Altersfreigabe|Certification):</h5>(?P<cert>.+?)</div>)*'
168                 '(?:.*?<h5>(?P<g_locations>Drehorte|Filming Locations):</h5>(?P<locations>.+?)(?:mehr|more</a>|</div>))*'
169                 '(?:.*?<h5>(?P<g_company>Firma|Company):</h5>(?P<company>.+?)(?:mehr|more</a>|</div>))*'
170                 '(?:.*?<h5>(?P<g_trivia>Dies und das|Trivia):</h5>(?P<trivia>.+?)(?:mehr|more</a>|</div>))*'
171                 '(?:.*?<h5>(?P<g_goofs>Pannen|Goofs):</h5>(?P<goofs>.+?)(?:mehr|more</a>|</div>))*'
172                 '(?:.*?<h5>(?P<g_quotes>Dialogzitate|Quotes):</h5>(?P<quotes>.+?)(?:mehr|more</a>|</div>))*'
173                 '(?:.*?<h5>(?P<g_connections>Bez\S*?ge zu anderen Titeln|Movie Connections):</h5>(?P<connections>.+?)(?:mehr|more</a>|</div>))*'
174                 '(?:.*?<h3>(?P<g_comments>Nutzerkommentare|User Comments)</h3>.*?<a href="/user/ur\d{7,7}/comments">(?P<commenter>.+?)\n</div>.*?<p>(?P<comment>.+?)</p>)*'
175                 , re.DOTALL)
176
177         def _(self, in_string):
178                 out_string = in_string
179                 if ((self.IMDBlanguage).find("german")) != -1:
180                         out_string = self.dict.get(in_string, in_string)
181                 return out_string
182
183         def resetLabels(self):
184                 self["detailslabel"].setText("")
185                 self["ratinglabel"].setText("")
186                 self["titellabel"].setText("")
187                 self["castlabel"].setText("")
188                 self["titellabel"].setText("")
189                 self["extralabel"].setText("")
190                 self.ratingstars = -1
191
192         def pageUp(self):
193                 if self.Page == 0:
194                         self["menu"].instance.moveSelection(self["menu"].instance.moveUp)
195                 if self.Page == 1:
196                         self["castlabel"].pageUp()
197                         self["detailslabel"].pageUp()
198                 if self.Page == 2:
199                         self["extralabel"].pageUp()
200
201         def pageDown(self):
202                 if self.Page == 0:
203                         self["menu"].instance.moveSelection(self["menu"].instance.moveDown)
204                 if self.Page == 1:
205                         self["castlabel"].pageDown()
206                         self["detailslabel"].pageDown()
207                 if self.Page == 2:
208                         self["extralabel"].pageDown()
209
210         def showMenu(self):
211                 if ( self.Page is 1 or self.Page is 2 ) and self.resultlist:
212                         self["menu"].show()
213                         self["stars"].hide()
214                         self["starsbg"].hide()
215                         self["ratinglabel"].hide()
216                         self["castlabel"].hide()
217                         self["poster"].hide()
218                         self["extralabel"].hide()
219                         self["titellabel"].setText(self._("Ambiguous results"))
220                         self["detailslabel"].setText(self._("Please select the matching entry"))
221                         self["detailslabel"].show()
222                         self["key_blue"].setText("")
223                         self["key_green"].setText(self._("Title Menu"))
224                         self["key_yellow"].setText(self._("Details"))
225                         self.Page = 0
226
227         def showDetails(self):
228                 self["ratinglabel"].show()
229                 self["castlabel"].show()
230                 self["detailslabel"].show()
231
232                 if self.resultlist and self.Page == 0:
233                         link = self["menu"].getCurrent()[1]
234                         title = self["menu"].getCurrent()[0]
235                         self["statusbar"].setText("Re-Query IMDb: "+title+"...")
236                         localfile = "/tmp/imdbquery2.html"
237                         fetchurl = "http://" + self.IMDBlanguage + "imdb.com/title/" + link
238                         print "[IMDB] downloading query " + fetchurl + " to " + localfile
239                         downloadPage(fetchurl,localfile).addCallback(self.IMDBquery2).addErrback(self.fetchFailed)
240                         self["menu"].hide()
241                         self.resetLabels()
242                         self.Page = 1
243
244                 if self.Page == 2:
245                         self["extralabel"].hide()
246                         self["poster"].show()
247                         if self.ratingstars > 0:
248                                 self["starsbg"].show()
249                                 self["stars"].show()
250                                 self["stars"].setValue(self.ratingstars)
251
252                         self.Page = 1
253
254         def showExtras(self):
255                 if self.Page == 1:
256                         self["extralabel"].show()
257                         self["detailslabel"].hide()
258                         self["castlabel"].hide()
259                         self["poster"].hide()
260                         self["stars"].hide()
261                         self["starsbg"].hide()
262                         self["ratinglabel"].hide()
263                         self.Page = 2
264
265         def getIMDB(self):
266                 self.resetLabels()
267                 if self.eventName is "":
268                         s = self.session.nav.getCurrentService()
269                         info = s.info()
270                         event = info.getEvent(0) # 0 = now, 1 = next
271                         if event:
272                                 self.eventName = event.getEventName()
273                 if self.eventName is not "":
274                         self["statusbar"].setText("Query IMDb: " + self.eventName + "...")
275                         event_quoted = urllib.quote(self.eventName.decode('utf8').encode('latin-1','ignore'))
276                         localfile = "/tmp/imdbquery.html"
277                         fetchurl = "http://" + self.IMDBlanguage + "imdb.com/find?q=" + event_quoted + "&s=tt&site=aka"
278                         print "[IMDB] Downloading Query " + fetchurl + " to " + localfile
279                         downloadPage(fetchurl,localfile).addCallback(self.IMDBquery).addErrback(self.fetchFailed)
280                 else:
281                         self["statusbar"].setText("Could't get Eventname -_-")
282
283         def fetchFailed(self,string):
284                 print "[IMDB] fetch failed " + string
285                 self["statusbar"].setText("IMDb Download failed -_-")
286
287         def html2utf8(self,in_html):
288                 htmlentitynumbermask = re.compile('(&#(\d{1,5}?);)')
289                 htmlentitynamemask = re.compile('(&(\D{1,5}?);)')
290
291                 entities = htmlentitynamemask.finditer(in_html)
292                 entitydict = {}
293
294                 for x in entities:
295                         entitydict[x.group(1)] = x.group(2)
296
297                 for key, name in entitydict.items():
298                         entitydict[key] = htmlentitydefs.name2codepoint[name]
299
300                 entities = htmlentitynumbermask.finditer(in_html)
301
302                 for x in entities:
303                         entitydict[x.group(1)] = x.group(2)
304
305                 for key, codepoint in entitydict.items():
306                         in_html = in_html.replace(key, (unichr(int(codepoint)).encode('latin-1')))
307
308                 self.inhtml = in_html.decode('latin-1').encode('utf8')
309
310         def IMDBquery(self,string):
311                 print "[IMDBquery]"
312                 self["statusbar"].setText("IMDb Download completed")
313
314                 self.html2utf8(open("/tmp/imdbquery.html", "r").read())
315
316                 self.generalinfos = self.generalinfomask.search(self.inhtml)
317
318                 if self.generalinfos:
319                         self.IMDBparse()
320                 else:
321                         if re.search("<title>(?:IMDb.{0,9}Search|IMDb Titelsuche)</title>", self.inhtml):
322                                 searchresultmask = re.compile("href=\".*?/title/(tt\d{7,7})/\">(.*?)</td>", re.DOTALL)
323                                 searchresults = searchresultmask.finditer(self.inhtml)
324                                 self.resultlist = []
325                                 if searchresults:
326                                         for x in searchresults:
327                                                 self.resultlist.append((self.htmltags.sub('',x.group(2)), x.group(1)))
328                                         self["menu"].l.setList(self.resultlist)
329                                 if len(self.resultlist) > 1:
330                                         self.Page = 1
331                                         self.showMenu()
332                                 else:
333                                         self["detailslabel"].setText(self._("No IMDb match."))
334                                         self["statusbar"].setText("No IMDb match")
335                         else:
336                                 splitpos = self.eventName.find('(')
337                                 if splitpos > 0 and self.eventName.endswith(')'):
338                                         self.eventName = self.eventName[splitpos+1:-1]
339                                         self["statusbar"].setText("Re-Query IMDb: " + self.eventName + "...")
340                                         event_quoted = urllib.quote(self.eventName.decode('utf8').encode('latin-1','ignore'))
341                                         localfile = "/tmp/imdbquery.html"
342                                         fetchurl = "http://" + self.IMDBlanguage + "imdb.com/find?q=" + event_quoted + "&s=tt&site=aka"
343                                         print "[IMDB] Downloading Query " + fetchurl + " to " + localfile
344                                         downloadPage(fetchurl,localfile).addCallback(self.IMDBquery).addErrback(self.fetchFailed)
345                                 else:
346                                         self["detailslabel"].setText(self._("IMDb query failed!"))
347
348         def IMDBquery2(self,string):
349                 self["statusbar"].setText("IMDb Re-Download completed")
350                 self.html2utf8(open("/tmp/imdbquery2.html", "r").read())
351                 self.generalinfos = self.generalinfomask.search(self.inhtml)
352                 self.IMDBparse()
353
354         def IMDBparse(self):
355                 print "[IMDBparse]"
356                 self.Page = 1
357                 Detailstext = self._("No details found.")
358                 if self.generalinfos:
359                         self["key_yellow"].setText(self._("Details"))
360                         self["statusbar"].setText("IMDb Details parsed ^^")
361                         Titeltext = self.generalinfos.group("title")
362                         if len(Titeltext) > 57:
363                                 Titeltext = Titeltext[0:54] + "..."
364                         self["titellabel"].setText(Titeltext)
365
366                         Detailstext = ""
367
368                         genreblockmask = re.compile('<h5>Genre:</h5>(.*?)(?:mehr|more|</div>)', re.DOTALL)
369                         genreblock = genreblockmask.findall(self.inhtml)
370                         genremask = re.compile('\">(.*?)</a')
371                         if genreblock:
372                                 genres = genremask.finditer(genreblock[0])
373                                 if genres:
374                                         Detailstext += "Genre: "
375                                         for x in genres:
376                                                 Detailstext += x.group(1) + " "
377                         detailscategories = ["director", "creator", "writer", "premiere", "seasons", "country"]
378
379                         for category in detailscategories:
380                                 if self.generalinfos.group('g_'+category):
381                                         Detailstext += "\n" + self.generalinfos.group('g_'+category) + ": " + self.generalinfos.group(category)
382
383                         if self.generalinfos.group("alternativ"):
384                                 Detailstext += "\n" + self.generalinfos.group("g_alternativ") + ": " + self.htmltags.sub('',(self.generalinfos.group("alternativ").replace('\n','').replace("<br>",'\n').replace("  ",' ')))
385
386                         ratingmask = re.compile('(?P<g_rating>Nutzer-Bewertung|User Rating):</b>.{0,2}<b>(?P<rating>.*?)/10</b>', re.DOTALL)
387                         rating = ratingmask.search(self.inhtml)
388                         Ratingtext = self._("no user rating yet")
389                         if rating:
390                                 Ratingtext = rating.group("g_rating") + ": " + rating.group("rating") + " / 10"
391                                 self.ratingstars = int(10*round(float(rating.group("rating")),1))
392                                 self["stars"].show()
393                                 self["stars"].setValue(self.ratingstars)
394                                 self["starsbg"].show()
395                         self["ratinglabel"].setText(Ratingtext)
396                         castmask = re.compile('<td class="nm">.*?>(.*?)</a>.*?<td class="char">(?:<a.*?>)?(.*?)(?:</a>)?</td>', re.DOTALL)
397                         castresult = castmask.finditer(self.inhtml)
398                         if castresult:
399                                 Casttext = ""
400                                 for x in castresult:
401                                         Casttext += "\n" + self.htmltags.sub('', x.group(1))
402                                         if x.group(2):
403                                                 Casttext += self._(" als ") + self.htmltags.sub('', x.group(2).replace('/ ...',''))
404                                 if Casttext is not "":
405                                         Casttext = self._("Cast: ") + Casttext
406                                 else:
407                                         Casttext = self._("No cast list found in the database.")
408                                 self["castlabel"].setText(Casttext)
409                         postermask = re.compile('<div class="photo">.*?<img .*? src=\"(http.*?)\" .*?>', re.DOTALL)
410                         posterurl = postermask.search(self.inhtml)
411                         if posterurl and posterurl.group(1).find("jpg") > 0:
412                                 posterurl = posterurl.group(1)
413                                 self["statusbar"].setText("Downloading Movie Poster: "+posterurl+"...")
414                                 localfile = "/tmp/poster.jpg"
415                                 print "[IMDB] downloading poster " + posterurl + " to " + localfile
416                                 downloadPage(posterurl,localfile).addCallback(self.IMDBPoster).addErrback(self.fetchFailed)
417                         else:
418                                 self.IMDBPoster("kein Poster")
419                         extrainfos = self.extrainfomask.search(self.inhtml)
420
421                         if extrainfos:
422                                 Extratext = "Extra Info\n"
423                                 extracategories = ["tagline","outline","synopsis","keywords","awards","runtime","language","color","aspect","sound","cert","locations","company","trivia","goofs","quotes","connections"]
424
425                                 for category in extracategories:
426                                         if extrainfos.group('g_'+category):
427                                                 Extratext += extrainfos.group('g_'+category) + ": " + self.htmltags.sub('',extrainfos.group(category).replace("\n",'').replace("<br>",'\n')) + "\n"
428                                 if extrainfos.group("g_comments"):
429                                         Extratext += extrainfos.group("g_comments") + " [" + self.htmltags.sub('',extrainfos.group("commenter")) + "]: " + self.htmltags.sub('',extrainfos.group("comment").replace("\n",' ')) + "\n"
430
431                                 self["extralabel"].setText(Extratext)
432                                 self["extralabel"].hide()
433                                 self["key_blue"].setText(self._("Extra Info"))
434
435                 self["detailslabel"].setText(Detailstext)
436
437         def IMDBPoster(self,string):
438                 self["statusbar"].setText("IMDb Details parsed ^^")
439                 if not string:
440                         filename = "/tmp/poster.jpg"
441                 else:
442                         filename = resolveFilename(SCOPE_PLUGINS, "Extensions/IMDb/no_poster.png")
443                 sc = AVSwitch().getFramebufferScale()
444                 self.picload.setPara((self["poster"].instance.size().width(), self["poster"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000"))
445                 self.picload.startDecode(filename)
446
447         def paintPosterPixmapCB(self, picInfo=None):
448                 ptr = self.picload.getData()
449                 if ptr != None:
450                         self["poster"].instance.setPixmap(ptr.__deref__())
451                         self["poster"].show()
452
453         def createSummary(self):
454                 return IMDbLCDScreen
455
456 class IMDbLCDScreen(Screen):
457         skin = """
458         <screen position="0,0" size="132,64" title="IMDB Plugin">
459                 <widget name="headline" position="4,0" size="128,22" font="Regular;20"/>
460                 <widget source="session.Event_Now" render="Label" position="6,26" size="120,34" font="Regular;14" >
461                         <convert type="EventName">Name</convert>
462                 </widget>
463         </screen>"""
464
465         def __init__(self, session, parent):
466                 Screen.__init__(self, session)
467                 self["headline"] = Label("IMDB Plugin")
468
469 def eventinfo(session, servicelist, **kwargs):
470         ref = session.nav.getCurrentlyPlayingServiceReference()
471         session.open(IMDBEPGSelection, ref)
472
473 def main(session, eventName="", **kwargs):
474         session.open(IMDB, eventName)
475
476 def Plugins(**kwargs):
477         try:
478                 return [PluginDescriptor(name="IMDb Details",
479                                 description=_("Query details from the Internet Movie Database"),
480                                 icon="imdb.png",
481                                 where = PluginDescriptor.WHERE_PLUGINMENU,
482                                 fnc = main),
483                                 PluginDescriptor(name="IMDb Details",
484                                 description=_("Query details from the Internet Movie Database"),
485                                 where = PluginDescriptor.WHERE_EVENTINFO,
486                                 fnc = eventinfo)
487                                 ]
488         except AttributeError:
489                 wherelist = [PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU]
490                 return PluginDescriptor(name="IMDb Details",
491                                 description=_("Query details from the Internet Movie Database"),
492                                 icon="imdb.png",
493                                 where = wherelist,
494                                 fnc=main)