def PreProcessFolderList(self, data): """ Accepts an data from the ProcessFolderList Methode, BEFORE the items are processed. Allows setting of parameters (like title etc). No return value! """ logFile.info("Performing Pre-Processing") _items = [] # extract the category name from the pagedata results = common.DoRegexFindAll( "in de categorie\W+<span class='[^']+'>[^;]+;([^<]+)"", data) if len(results) > 0: self.categoryName = common.ConvertHTMLEntities(results[0]) logFile.debug("Pre-Processing finished") return (data, _items)
def LoadChannels(self): data = uriHandler.Open( "http://code.google.com/p/xot-uzg/downloads/list?q=label:AutoUpdate", pb=False) channels = common.DoRegexFindAll( 'href="detail\?name=([^&]+)[^"]+">([^<]+)</a>[^!]+[^>]+>[^>]+>([^<]+)</a>', data) guiController = guicontroller.GuiController(self) for channel in channels: item = common.clistItem( channel[0], "http://xot-uzg.googlecode.com/files/%s" % channel[0]) item.description = common.ConvertHTMLEntities(channel[1]) item.icon = guiController.GetImageLocation("xot_updateicon.png") item.date = channel[2] self.updateItems.append(item) item = xbmcgui.ListItem(channel[0], channel[2], item.icon, item.icon) self.addItem(item)
def CreateVideoItem(self, resultSet): """ Accepts an arraylist of results. It returns an item. """ logFile.debug('starting FormatVideoItem for %s', self.channelName) #<img id='([^']+)' src='([^']+)' class='vThumb' alt='[^']*'/></a></div></div><div class='sCenter vTitle'><span class='title'><a[^>]+title='([^']+)'> # 0 1 2 name = common.ConvertHTMLEntities(resultSet[2]) item = common.clistItem( name, common.StripAmp("%s%s" % (self.baseUrl, resultSet[0]))) item.description = "%s\n%s" % (self.categoryName, resultSet[2]) item.icon = self.icon item.thumb = self.noImage item.thumbUrl = resultSet[1] # now create the video url using the # http://myvideo-550.vo.llnwd.net/nl/d3/movie7/4a/thumbs/3384551_1.jpg # http://myvideo-550.vo.llnwd.net/nl/d3/movie7/4a/3384551.flv # het script: http://myvideo-906.vo.llnwd.net/nl/d2/movie4/d93548906.flv # de pagina: http://myvideo-906.vo.llnwd.net/nl/d2/movie4/d9/3548906.flv urlResult = common.DoRegexFindAll( "(http://myvideo[^_]+)/thumbs(/\d+)_\d+.jpg", item.thumbUrl) item.mediaurl = "" if len(urlResult) > 0: for part in urlResult[0]: item.mediaurl = "%s%s" % (item.mediaurl, part) item.mediaurl = "%s.flv" % (item.mediaurl) logFile.debug("Updated mediaurl for %s to: %s", item.name, item.mediaurl) item.type = 'video' item.complete = False return item
def CreateVideoItem(self, resultSet): """ Accepts an arraylist of results. It returns an item. """ logFile.debug('starting FormatVideoItem for %s', self.channelName) #(<td class="image"><img src="([^"]+)" [^>]+>\W*</td>\W*<td [^>]+>)*<div class="video"><a [^>]+ href="([^"]+)" [^>]+>([^<]+)</a> # 0 1 2 3 name = common.ConvertHTMLEntities(resultSet[3]) item = common.clistItem(name, common.StripAmp(urlparse.urljoin(self.baseUrl, resultSet[2]))) item.description = "%s%s" % (self.categoryName, item.name) item.icon = self.icon if resultSet[1] != "": item.thumbUrl = common.StripAmp(urlparse.urljoin(self.baseUrl, resultSet[1])) logFile.debug("Setting thumburl=%s", item.thumbUrl) item.thumb = self.noImage item.type = 'video' item.complete = False return item
def UpdateVideoItem(self, item): """ Accepts an arraylist of results. It returns an item. """ if not item.type == 'video': return item # we need a new cookie for the episode: that is retrieved from: http://player.omroep.nl/?aflID=6746029 data = uriHandler.Open("http://player.omroep.nl/%s" % (item.url), pb=False) #uriHandler.CookiePrint() # then we need to get the securitycode to obtain the info XML (var securityCode = '83f9ce0d14af55b2ce48f1fb3af26462';) url = "http://player.omroep.nl/js/initialization.js.php%s" % item.url data = uriHandler.Open(url, pb=False) code = common.DoRegexFindAll("var securityCode = '([0-9a-f]+)';", data) if len(code) == 1: code = code[0] # now we construct the url: http://player.omroep.nl/xml/metaplayer.xml.php?aflID=6954225&md5=e82938c934f962003ec7c9181ca0439e&md5=6fa9fb656ab15d8fa2a086d1c1ba9e47 url = "%s%s&md5=%s" % (self.playerUrl, item.url, code) #=============================================================================== # should be made more compact in 1 single regex #=============================================================================== #url = item.url logFile.info('starting UpdateVideoItem for ' + item.url) data = uriHandler.Open(url, pb=False) #get title title = common.DoRegexFindAll('<tite>(.*)</tite>', data) title = common.ConvertHTMLEntities(title[0]) #get episode ID #aflevering = common.DoRegexFindAll('<aflevering id=\'([^\']*)', data) # now update item: item.name = title item.url = url item.type = "video" # get rating rating = common.DoRegexFindAll( "<waardering teller='\d+' [^>]+>(\d[.]*\d*)</waardering>", data) if len(rating) > 0: item.rating = int(float(rating[0])) # get data datum = common.DoRegexFindAll('<begi>(\d\d-\d\d-\d\d\d\d) ', data) if datum == []: datum.append('Geen Datum') item.date = datum[0] #description description = common.DoRegexFindAll('<gids_tekst>(.*)</gids_tekst>', data) if description == []: info = "Geen Omschrijving" else: info = description[0] item.description = common.ConvertHTMLEntities(info) # get image image = common.DoRegexFindAll( '<radio_afbeelding>(http://.*/)([^/]*)</radio_afbeelding>', data) if image == []: #no image item.thumb = self.noImage else: #save image item.thumb = self.CacheThumb( common.ConvertHTMLEntities( str(image[0][0]) + str(image[0][1]))) # get the mediaurl item.mediaurl = common.DoRegexFindAll( '<stream[^>]+compressie_kwaliteit=.bb.[^>]+compressie_formaat=.wmv.[^>]*>([^<]*)</stream>', data)[0] # parse the asx data = uriHandler.Open(item.mediaurl, pb=False) newMediaUrl = common.DoRegexFindAll('<Ref href[^"]+"([^"]+)"', data) if len(newMediaUrl) > 0: item.mediaurl = newMediaUrl[0] # finish and return logFile.info('finishing UpdateVideoItem for ' + item.url + '. Media URL =' + item.mediaurl) item.complete = True return item