def _dateduration(self, ad): #Search a tag for aired date and video duration
  if ad:
   info = dict()
   aired = re.search("([0-9]{2}/[0-9]{2}/[0-9]{2})", ad.contents[1])
   if aired:
    info["Premiered"] = tools.xbmcdate(aired.group(1))
    info["Date"] = info["Premiered"]
   duration = re.search("\(([0-9]+:[0-9]{2})\)", ad.contents[1])
   if duration:
    info["Duration"] = time.strftime("%M", time.strptime(duration.group(1), "%M:%S"))
   return info
示例#2
0
 def page(self, filter, page):
  url = "%s%s?page=%s" % (self.urls['base'], filter, page)
  page = webpage(url, 'chrome', 'nzos_html5=true')
  if page.doc:
   div_tag = SoupStrainer('div')
   html_divtag = BeautifulSoup(page.doc, parseOnlyThese = div_tag)
   results = html_divtag.find(attrs={'id' : 'filter_result_set'})
   if results:
    rows = results.findAll('tr')
    if len(rows) > 0:
     for row in rows:
      cells = row.findAll('td')
      count = len(cells)
      if count > 0:
       item = tools.xbmcItem()
       for cell in cells:
        if cell['class'] == 'image':
         item.info['Thumb'] = "%s%s" % (self.urls['base'], cell.div.div.a.img['src'])
         title = re.search("/title/(.*)", cell.a['href'])
         if not title:
          title = re.search("/interviews/(.*)", cell.a['href'])
        #elif cell['class'] == 'title_link title':
        elif cell['class'].startswith('title_link'):
         item.info['Title'] = item.unescape(cell.a.contents[0])
        #elif cell['class'] == 'year':
        # pass
        #elif cell['class'] == 'category':
        # pass
        #elif cell['class'] == 'director':
        # pass
        elif cell['class'] == 'added':
         item.info["Date"] = tools.xbmcdate(cell.contents[0], ".")
       if title:
        if self.prefetch:
         item.urls = self._videourls(title.group(1))
         item.units = "MB"
        else:
         item.info["FileName"] = "%s?ch=%s&title=%s&info=%s" % (self.base, self.channel, title.group(1), item.infoencode())
         item.playable = True
        self.xbmcitems.items.append(item)
        if self.prefetch:
         self.xbmcitems.add(count)
     if self.prefetch:
      self.xbmcitems.sort()
     else:
      self.xbmcitems.addall()
    else:
     sys.stderr.write("page: No rows")
   else:
    sys.stderr.write("page: No results")
  else:
   sys.stderr.write("page: No page.doc")
示例#3
0
 def _dateduration(self,
                   ad):  #Search a tag for aired date and video duration
     if ad:
         info = dict()
         aired = re.search("([0-9]{2}/[0-9]{2}/[0-9]{2})", ad.contents[1])
         if aired:
             info["Premiered"] = tools.xbmcdate(aired.group(1))
             info["Date"] = info["Premiered"]
         duration = re.search("\(([0-9]+:[0-9]{2})\)", ad.contents[1])
         if duration:
             info["Duration"] = time.strftime(
                 "%M", time.strptime(duration.group(1), "%M:%S"))
         return info
 def page(self, filter, page):
  url = "%s%s?page=%s" % (self.urls['base'], filter, page)
  pg = webpage(url, agent='chrome', cookie='nzos_html5=true')
  if pg.doc:
   div_tag = SoupStrainer('div')
   html_divtag = BeautifulSoup(pg.doc, parseOnlyThese = div_tag)
   results = html_divtag.find(attrs={'id' : 'filter_result_set'})
   if results:
    rows = results.findAll('tr')
    if len(rows) > 0:
     for row in rows:
      cells = row.findAll('td')
      count = len(cells)
      if count > 0:
       item = tools.xbmcItem(self.channel)
       for cell in cells:
        if cell['class'] == 'image':
         src = cell.div.div.a.img['src']
         if not src.startswith("http://"):
          src = self.urls['base'] + src
         item['videoInfo']['Thumb'] = src
         title = re.search("/title/(.*)", cell.a['href'])
         if not title:
          title = re.search("/interviews/(.*)", cell.a['href'])
        elif cell['class'].startswith('title_link'):
         item['videoInfo']['Title'] = item.unescape(cell.a.contents[0])
        elif cell['class'] == 'added':
         item['videoInfo']["Date"] = tools.xbmcdate(cell.contents[0], ".")
       if title:
        item['videoInfo']["FileName"] = "%s?ch=%s&title=%s&info=%s" % (self.base, self.channel, title.group(1), item.infoencode())
        item['playable'] = True
        if not title.group(1).endswith("/series"):
         self.xbmcitems.items.append(item)
     return self.xbmcitems.addall()
    else:
     sys.stderr.write("page: No rows")
   else:
    sys.stderr.write("page: No results")
  else:
   sys.stderr.write("page: No page.doc")
示例#5
0
 def page(self, filter, page):
     url = "%s%s?page=%s" % (self.urls['base'], filter, page)
     page = webpage(url, 'chrome', 'nzos_html5=true')
     if page.doc:
         div_tag = SoupStrainer('div')
         html_divtag = BeautifulSoup(page.doc, parseOnlyThese=div_tag)
         results = html_divtag.find(attrs={'id': 'filter_result_set'})
         if results:
             rows = results.findAll('tr')
             if len(rows) > 0:
                 for row in rows:
                     cells = row.findAll('td')
                     count = len(cells)
                     if count > 0:
                         item = tools.xbmcItem()
                         for cell in cells:
                             if cell['class'] == 'image':
                                 item.info['Thumb'] = "%s%s" % (
                                     self.urls['base'],
                                     cell.div.div.a.img['src'])
                                 title = re.search("/title/(.*)",
                                                   cell.a['href'])
                                 if not title:
                                     title = re.search(
                                         "/interviews/(.*)", cell.a['href'])
                             #elif cell['class'] == 'title_link title':
                             elif cell['class'].startswith('title_link'):
                                 item.info['Title'] = item.unescape(
                                     cell.a.contents[0])
                             #elif cell['class'] == 'year':
                             # pass
                             #elif cell['class'] == 'category':
                             # pass
                             #elif cell['class'] == 'director':
                             # pass
                             elif cell['class'] == 'added':
                                 item.info["Date"] = tools.xbmcdate(
                                     cell.contents[0], ".")
                         if title:
                             if self.prefetch:
                                 item.urls = self._videourls(title.group(1))
                                 item.units = "MB"
                             else:
                                 item.info[
                                     "FileName"] = "%s?ch=%s&title=%s&info=%s" % (
                                         self.base, self.channel,
                                         title.group(1), item.infoencode())
                                 item.playable = True
                             self.xbmcitems.items.append(item)
                             if self.prefetch:
                                 self.xbmcitems.add(count)
                 if self.prefetch:
                     self.xbmcitems.sort()
                 else:
                     self.xbmcitems.addall()
             else:
                 sys.stderr.write("page: No rows")
         else:
             sys.stderr.write("page: No results")
     else:
         sys.stderr.write("page: No page.doc")