def index(self, filter = "/explore/"):
  filterarray = filter.strip('/').split('/')
  filterlevel = len(filterarray)
  if filterlevel == 4 and filterarray[2] == 'az':
   filterlevel += 1
  url = self.urls['base'] + filter
  page = webpage(url, agent='chrome', cookie='nzos_html5=true')
  if page.doc:
   #resources.tools.gethtmlpage("http://www.nzonscreen.com/html5/opt_in", "chrome", 1) # Get a cookie for this session to enable the HTML5 video tag
   div_tag = SoupStrainer('div')
   html_divtag = BeautifulSoup(page.doc, parseOnlyThese = div_tag)
   sections = html_divtag.find(attrs={'id' : 'explore_filter_%s' % str(filterlevel)})
   if not sections:
    sections = html_divtag.find(attrs={'id' : 'explore_listview'})
   if sections:
    links = sections.findAll('a')
    if len(links) > 0:
     for link in links:
      item = tools.xbmcItem(self.channel)
      info = item['videoInfo']
      info["FileName"] = "%s?ch=%s&filter=%s" % (self.base, self.channel, urllib.quote(link["href"]))
      if link.string:
       info["Title"] = link.string.strip()
      else:
       filterarray = link["href"].split('/')
       info["Title"] = filterarray[len(filterarray) - 1].capitalize()
      self.xbmcitems.items.append(item)
     if filterlevel == 1:
      item = tools.xbmcItem(self.channel)
      info = item['videoInfo']
      info["FileName"] = "%s?ch=%s&filter=search" % (self.base, self.channel)
      info["Title"] = "Search"
      self.xbmcitems.items.append(item)
    else:
     nav = html_divtag.find(attrs={'class' : 'nav_pagination'})
     if nav:
      pages = nav.findAll('a')
      if pages:
       for page in pages:
        if page.string:
         lastpage = page.string.strip()
       for i in range(1, int(lastpage)):
        item = tools.xbmcItem(self.channel)
        info = item['videoInfo']
        info["FileName"] = "%s?ch=%s&filter=%s&page=%s" % (self.base, self.channel, urllib.quote(filter), str(i))
        info["Title"] = 'Page %s' % str(i)
        self.xbmcitems.items.append(item)
    return self.xbmcitems.addall()
   else:
    sys.stderr.write("index: No sections")
  else:
   sys.stderr.write("index: No page.doc")
 def index(self):
  item = tools.xbmcItem(self.channel)
  info = item['videoInfo']
  info["Title"] = "Channels"
  info["FileName"] = "%s?ch=Ziln&folder=channels" % sys.argv[0]
  self.xbmcitems.items.append(item)
  item = tools.xbmcItem(self.channel)
  info = item['videoInfo']
  info["Title"] = "Search"
  info["Thumb"] = "DefaultVideoPlaylists.png"
  info["FileName"] = "%s?ch=Ziln&folder=search" % sys.argv[0]
  self.xbmcitems.items.append(item)
  return self.xbmcitems.addall()
Beispiel #3
0
 def channelindex(self, channel): #Create second level folder for the hierarchy view, only showing items for the selected top level folder
  for category in self.urls['categories']:
   item = tools.xbmcItem(channel, self.channel)
   item['videoInfo']["Title"] = category
   item['videoInfo']["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (self.base, channel, category.replace(" ", ""))
   self.xbmcitems.items.append(item)
  item = tools.xbmcItem(channel, self.channel)
  item['videoInfo']["Title"] = 'Shows'
  item['videoInfo']["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (self.base, channel, "shows")
  self.xbmcitems.items.append(item)
  item = tools.xbmcItem(channel, self.channel)
  item['videoInfo']["Title"] = "Search"
  item['videoInfo']["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (self.base, channel, "search")
  self.xbmcitems.items.append(item)
  return self.xbmcitems.addall()
 def index(self):
     item = tools.xbmcItem()
     info = item.info
     info["Title"] = config.__language__(30053)
     info["Count"] = 1
     info["FileName"] = "%s?ch=Ziln&folder=channels" % sys.argv[0]
     self.xbmcitems.items.append(item)
     item = tools.xbmcItem()
     info = item.info
     info["Title"] = config.__language__(30065)
     info["Count"] = 2
     info["Thumb"] = "DefaultVideoPlaylists.png"
     info["FileName"] = "%s?ch=Ziln&folder=search" % sys.argv[0]
     self.xbmcitems.items.append(item)
     self.xbmcitems.addall()
 def channelindex(self, channel): #Create second level folder for the hierarchy view, only showing items for the selected top level folder
  for category in self.urls['categories']:
   item = tools.xbmcItem()
   item.info["Title"] = category
   item.info["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (self.base, channel, category.replace(" ", ""))
   self.xbmcitems.items.append(item)
  item = tools.xbmcItem()
  item.info["Title"] = language(30055)
  item.info["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (self.base, channel, "shows")
  self.xbmcitems.items.append(item)
  item = tools.xbmcItem()
  item.info["Title"] = language(30065)
  item.info["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (self.base, channel, "search")
  self.xbmcitems.items.append(item)
  self.xbmcitems.addall()
 def index(self):
  item = tools.xbmcItem()
  info = item.info
  info["Title"] = config.__language__(30053)
  info["Count"] = 1
  info["FileName"] = "%s?ch=Ziln&folder=channels" % sys.argv[0]
  self.xbmcitems.items.append(item)
  item = tools.xbmcItem()
  info = item.info
  info["Title"] = config.__language__(30065)
  info["Count"] = 2
  info["Thumb"] = "DefaultVideoPlaylists.png"
  info["FileName"] = "%s?ch=Ziln&folder=search" % sys.argv[0]
  self.xbmcitems.items.append(item)
  self.xbmcitems.addall()
Beispiel #7
0
 def play(self, id, channel, encodedinfo):
  item = tools.xbmcItem(channel, self.channel)
  item.infodecode(encodedinfo)
  item['fanart'] = self.xbmcitems.fanart
  item['urls'] = self._geturls(id, channel)
  if item['urls']:
   return self.xbmcitems.resolve(item, self.channel)
Beispiel #8
0
 def play(self, title, encodedinfo):
     item = tools.xbmcItem()
     item.infodecode(encodedinfo)
     item.units = "MB"
     item.fanart = self.xbmcitems.fanart
     item.urls = self._geturls(title)
     self.xbmcitems.resolve(item, self.channel)
Beispiel #9
0
 def folderindex(self, folder): #Create second level folder for the hierarchy view, only showing items for the selected top level folder
  infopages = list()
  infopages.append(("63", config.__language__(30052), "tv3", config.__language__(30056))) # Latest
  infopages.append(("61", config.__language__(30052), "tv3", config.__language__(30057))) # Most Watched
  infopages.append(("64", config.__language__(30052), "tv3", config.__language__(30058))) # Expiring soon
  #infopages.append(("70", config.__language__(30052), "atoz", "A - Z")) # Now empty
  infopages.append(("71", config.__language__(30053), "tv3", "TV3"))
  infopages.append(("72", config.__language__(30053), "four", "FOUR"))
  infopages.append(("65", config.__language__(30054), "tv3", config.__language__(30059))) # Comedy
  infopages.append(("66", config.__language__(30054), "tv3", config.__language__(30060))) # Drama
  infopages.append(("67", config.__language__(30054), "tv3", config.__language__(30061))) # News/Current affairs
  infopages.append(("68", config.__language__(30054), "tv3", config.__language__(30062))) # Reality
  infopages.append(("82", config.__language__(30054), "tv3", config.__language__(30063))) # Sports
  infopages.append(("80", config.__language__(30052), "tv3", config.__language__(30064))) # All
  #infopages.append(("74", "RSS", "tv3", "RSS Feeds"))
  #infopages.append(("81", "Categories", "tv3", "FOUR Highlights"))
  #infopages.append(("73", "Categories", "tv3", "All (Small)"))
  for page in infopages:
   if page[1] == folder:
    item = tools.xbmcItem()
    item.info["Title"] = page[3]
    item.info["FileName"] = "%s?ch=TV3&cat=%s&catid=%s" % (self.base, page[2], page[0])
    self.xbmcitems.items.append(item)
  if folder == "Shows":
   self.shows("tv3")
  elif folder == "Search":
   self.search()
  self.xbmcitems.addall()
Beispiel #10
0
 def showsindex(provider): #Create a second level list of TV Shows from a TV3 webpage
  #doc = resources.tools.gethtmlpage("%s/Shows/tabid/64/Default.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
  #doc = resources.tools.gethtmlpage("%s/Shows.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
  page = webpage("%s/Shows.aspx" % ("http://www.tv3.co.nz"))
  if page.doc:
   html_divtag = BeautifulSoup(page.doc)
   linksdiv = html_divtag.find('div', attrs = {"id": "pw_8171"})
   if linksdiv:
    links = linksdiv.findAll('a')
    if len(links) > 0:
     count = 0
     for link in links:
      item = tools.xbmcItem()
      item.info["Title"] = link.string.strip()
      catid = link['href']
      if item.info["Title"] == "60 Minutes": #The URL on the next line has more videos
       item.info["FileName"] = "%s?ch=TV3&cat=%s&title=%s&catid=%s" % (self.base, "shows", urllib.quote(item.info["Title"]), urllib.quote(catid)) #"http://ondemand.tv3.co.nz/Default.aspx?TabId=80&cat=22"
      else:
       item.info["FileName"] = "%s?ch=TV3&cat=%s&title=%s&catid=%s" % (self.base, "shows", urllib.quote(item.info["Title"]), urllib.quote(catid))
      self.xbmcitems.items.append(item)
     self.xbmcitems.addall()
    else:
     sys.stderr.write("showsindex: Couldn't find any videos in list")
   else:
    sys.stderr.write("showsindex: Couldn't find video list")
  else:
   sys.stderr.write("showsindex: Couldn't get index webpage")
Beispiel #11
0
 def index(self, fake = True):
  for folder in self.channels.keys():
   item = tools.xbmcItem(folder, self.channel)
   item['videoInfo']["Title"] = folder
   item['videoInfo']["FileName"] = "%s?ch=TV3&channel=%s" % (self.base, folder)
   self.xbmcitems.items.append(item)
  return self.xbmcitems.addall()
 def index(self, fake = True):
  for folder in self.channels.keys():
   item = tools.xbmcItem()
   item.info["Title"] = folder
   item.info["FileName"] = "%s?ch=TV3&channel=%s" % (self.base, folder)
   self.xbmcitems.items.append(item)
  self.xbmcitems.addall()
Beispiel #13
0
 def play(self, index, channelNum):
  channel = channelMap.get(int(channelNum), "Ziln")
  item = tools.xbmcItem(channel, self.channel)
  item['playable'] = True
  item['videoInfo'].update(self._getMetadata(index))
  item['urls'] = item['videoInfo'].pop('urls')
  return self.xbmcitems.resolve(item, self.channel)
 def sections(self, section):
  page = webpage('%s/%s/%s/' % (self.urls['base'], section, self.urls['videos']))
  if page.doc:
   div_tag = SoupStrainer('div')
   html_divtag = BeautifulSoup(page.doc, parseOnlyThese = div_tag)
   #landing = html_divtag.find(attrs = {'id' : 'landing_video'})
   gallery = html_divtag.find(attrs = {'class' : 'gallery_box'})
   if gallery:
    videos = gallery.findAll('div')
    if len(videos) > 0:
     for video in videos:
      link = video.find("a")
      if link:
       if link.string:
        item = tools.xbmcItem(self.channel)
        link = video.find("a")
        item['videoInfo']["Title"] = link.string.strip()
        image = video.find("img")
        if image:
         item['videoInfo']["Thumb"] = image['src']
        videoid = re.match('/%s/%s/([0-9]+)/' % (section, self.urls['videos']), link['href'])
        if videoid:
         if self.prefetch:
          item.urls = [self._geturl(section, videoid)]
         else:
          item.playable = True
          item['videoInfo']["FileName"] = "%s?ch=%s&section=%s&id=%s" % (self.base, self.channel, section, videoid.group(1))
         self.xbmcitems.items.append(item)
     return self.xbmcitems.addall()
    else:
     sys.stderr.write("sections: no videos")
   else:
    sys.stderr.write("sections: no gallery_box")
  else:
   sys.stderr.write("sections: no page.doc")
 def _itemtable(self, soup, provider, title): #Scrape items from a table-style HTML page
  item = tools.xbmcItem()
  link = soup.find('a')
  if link:
   if link.string:
    plot = link.string.strip()
    if plot != "":
     item.info["PlotOutline"] = plot
     item.info["TVShowTitle"] = title
     item.info.update(self._seasonepisode(link))
     item.titleplot()
     href = re.search("%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (self._base_url("tv3"), self.urls["video1"], self.urls["video2"], self.urls["video3"]), link['href'])
     if href:
      if self.prefetch:
       item.urls = self._geturls("%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), provider)
      else:
       item.playable = True
       item.info["FileName"] = "%s?ch=TV3&id=%s&provider=%s&info=%s" % (self.base, "%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), provider, item.infoencode())
     return item
    else:
     sys.stderr.write("_itemtable: No plot")
   else:
    sys.stderr.write("_itemtable: No link.string")
  else:
   sys.stderr.write("_itemtable: No link")
Beispiel #16
0
 def search(self, query):
  import urllib
  qid = urllib.quote_plus(query)
  qs = "&requiredfields=type:programme.site:tv&partialfields=programme-title:%s&fq=programme-title:%s&fq=type:programme&fq=site:tv&num=999" % (qid, qid)
  url = "%s/%s/%s?q=%s%s" % (self.urls['base'], self.urls['search'], self.urls['searchpage'], qid, qs)
  page = webpage(url)
  soup = BeautifulSoup(page.doc)
  if soup:
   for show in soup.findAll('ul', attrs={'class' : 'showDetailsMain'}):
    channel = show.find('li', attrs={'class' : "channel"}).contents[0].strip()
    item = tools.xbmcItem(channel, self.channel)
    info = item['videoInfo']
    urlIn = show.a['href']
    if not urlIn.startswith('http://'):
     urlIn = self.urls['base'] + urlIn
    info['urlIn'] = urlIn
    m = re.match(r'^.*?-(\d+)', urlIn)
    if not m:
     continue
    id = m.group(1)
    info["Title"] = show.a.contents[0].strip()
    info["Date"] = show.find('li', attrs={'class' : 'date'}).contents[0].strip()
    info["TVShowTitle"] = info["Title"]
    info["Plot"] = show.find('li', attrs={'class' : 'details'}).contents[0].strip()
    info["FileName"] = "%s?ch=%s&id=%s&type=shows" % (self.base, self.channel, id)
    self.xbmcitems.items.append(item)
  return self.xbmcitems.addall()
Beispiel #17
0
 def play(self, id, channel, encodedinfo):
  item = tools.xbmcItem()
  item.infodecode(encodedinfo)
  item.fanart = self.xbmcitems.fanart
  item.urls = self._geturls(id, channel)
  if item.urls:
   self.xbmcitems.resolve(item, self.channel)
Beispiel #18
0
 def play(self, title, encodedinfo):
  item = tools.xbmcItem()
  item.infodecode(encodedinfo)
  item.units = "MB"
  item.fanart = self.xbmcitems.fanart
  item.urls = self._geturls(title)
  self.xbmcitems.resolve(item, self.channel)
 def shows(self, channel): #Create a second level list of TV Shows from a TV3 webpage
  #doc = resources.tools.gethtmlpage("%s/Shows/tabid/64/Default.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
  #doc = resources.tools.gethtmlpage("%s/Shows.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
  page = webpage("%s/%s/%s" % (self.channels[channel]['base'], self.channels[channel]['ondemand'], "TitleAZ.aspx"))
  if page.doc:
   html_divtag = BeautifulSoup(page.doc)
   showsdiv = html_divtag.findAll('div', attrs = {"class": "grid_2"})
   if len(showsdiv) > 0:
    for show in showsdiv:
     item = tools.xbmcItem()
     title = show.find('p').find('a')
     if title:
      if title.string:
       if title['href'][len('http://www.'):len('http://www.') + 3] == channel[0:3].lower():
        item.info["Title"] = title.string.strip()
        image = show.find("img")
        if image:
         item.info["Thumb"] = image['src']
        item.info["FileName"] = "%s?ch=TV3&channel=%s&cat=%s&title=%s" % (self.base, channel, "show", urllib.quote(item.info["Title"].replace(" ", "")))
        self.xbmcitems.items.append(item)
    self.xbmcitems.addall()
   else:
    sys.stderr.write("showsindex: Couldn't find any videos in list")
  else:
   sys.stderr.write("showsindex: Couldn't get index webpage")
 def _itemdiv(self, soup, channel): #Scrape items from a div-style HTML page
  baseurl = self.channels[channel]['base']
  item = tools.xbmcItem()
  #item.info["Studio"] = provider
  link = soup.find("a")
  if link:
   href = re.match("%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (baseurl, self.urls["video1"], self.urls["video2"], self.urls["video3"]), link['href'])
   if href:
    showname = soup.find("div")
    if showname:
     title = showname.string.strip()
     if title != "":
      item.info["TVShowTitle"] = title
      image = soup.find("img")
      if image:
       item.info["Thumb"] = image['src']
      se = soup.find("p")
      if se:
       item.info.update(self._seasonepisode(se))
      item.titleplot()
      if self.prefetch:
       item.urls = self._geturls("%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), channel)
      else:
       item.playable = True
       item.info["FileName"] = "%s?ch=TV3&channel=%s&id=%s&info=%s" % (self.base, channel, "%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), item.infoencode())
      return item
     else:
      sys.stderr.write("_itemdiv: No title")
    else:
     sys.stderr.write("_itemdiv: No link.string")
   else:
    sys.stderr.write("_itemdiv: No href")
  else:
   sys.stderr.write("_itemdiv: No link")
Beispiel #21
0
 def play(self, id, channel, encodedinfo):
     item = tools.xbmcItem()
     item.infodecode(encodedinfo)
     item.fanart = self.xbmcitems.fanart
     item.urls = self._geturls(id, channel)
     if item.urls:
         self.xbmcitems.resolve(item, self.channel)
Beispiel #22
0
    def item(self):
        #self.channel = 'Parliament'
        item = tools.xbmcItem()
        item.channel = 'Parliament'
        item.fanart = os.path.join('extrafanart', item.channel + '.jpg')
        item.info["Title"] = 'Parliament TV - Live Stream'
        item.info["Thumb"] = os.path.join(
            settings.getAddonInfo('path'),
            "resources/images/%s.png" % item.channel)
        item.info[
            "Plot"] = "Parliament TV provides live broadcasts from the House of Representatives. Question time is replayed each day at 6pm and 10pm."
        item.info["Date"] = date.today().strftime("%d.%m.%Y")
        for quality in [56, 128, 384]:
            item.urls[quality] = "%s%s" % (
                "mms://wms-parliament.harmonycdn.net/parlserv-house",
                str(quality))
        for quality in [512]:
            item.urls[quality] = "%s%s%s" % (
                "rtsp://Qts1.ptv.parliament.nz/ptv-", quality, ".sdp")


#  quality = '384'
#  if settings.getSetting('%s_stream' % self.channel) == "Apple Quicktime":
#   quality = '512'
#  if settings.getSetting('%s_quality' % self.channel) == "Low":
#   quality = '56'
#  elif settings.getSetting('%s_quality' % self.channel) == "Medium":
#   quality = '128'
#  item.info["FileName"] = "%s%s" % ("mms://wms-parliament.harmonycdn.net/parlserv-house", quality)
#  if settings.getSetting('%s_stream' % self.channel) == "Apple Quicktime":
#   item.info["FileName"] = "%s%s%s" % ("rtsp://Qts1.ptv.parliament.nz/ptv-", quality, ".sdp")
        return item
 def programmes(self, type, urlext):
  if type == "channel":
   folder = 1
   url = self.urls['base']
  elif type == "video":
   folder = 0
   url = "%s/assets/php/slider.php?channel=%s" % (self.urls['base'], urlext)
  elif type == "search":
   folder = 0
   url = "%s/search?search_keyword=%s" % (self.urls['base'], urlext.replace(" ", "+"))
  page = webpage(url)
  if page.doc:
   if type == "channel" or type == "search":
    div_tag = SoupStrainer('div')
    html_divtag = BeautifulSoup(page.doc, parseOnlyThese = div_tag)
    programmes = html_divtag.findAll(attrs={'class' : 'programmes'})
   elif type == "video":
    div_tag = SoupStrainer('body')
    html_divtag = BeautifulSoup(page.doc, parseOnlyThese = div_tag)
    programmes = html_divtag.findAll(attrs={'class' : 'slider slider-small'})
   if type == "search":
    type = "video"
   if len(programmes) > 0:
    for program in programmes:
     list = program.find('ul')
     if list:
      listitems = list.findAll('li')
      count = len(listitems)
      if count > 0:
       for listitem in listitems:
        link = listitem.find('a', attrs={'href' : re.compile("^/%s/" % type)})
        if link.img:
         if re.search("assets/images/%ss/" % type, link.img["src"]):
          #item = tools.xbmcItem()
          item = tools.xbmcItem()
          if listitem.p.string:
           item.info["Title"] = listitem.p.string.strip()
          else:
           item.info["Title"] = link.img["alt"]
          item.info["Thumb"] = "%s/%s" % (self.urls['base'], link.img["src"])
          index = re.search("assets/images/%ss/([0-9]*?)-mini.jpg" % type, link.img["src"]).group(1)
          item.info["FileName"] = "%s?ch=%s&%s=%s" % (self.base, self.channel, type, urllib.quote(index))
          if type == "video":
           if self.prefetch:
            item.info["FileName"] = self._geturl(index)
           else:
            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("Search returned no results")
   else:
    sys.stderr.write("Couldn't find any programs")
  else:
   sys.stderr.write("Couldn't get page")
Beispiel #24
0
 def show(self, id, search = False):
  if search:
   import urllib
   url = "%s/%s/%s?q=%s" % (self.urls['base'], self.urls['search'], self.urls['page'], urllib.quote_plus(id))
  else:
   url = self.url(id)
  page = webpage(url)
  xml = self._xml(page.doc)
  if xml:
   for show in xml.getElementsByTagName('Show'):
    se = re.search('/content/(.*)_(episodes|extras)_group/ps3_xml_skin.xml', show.attributes["href"].value)
    if se:
     if se.group(2) == "episodes":
      #videos = int(show.attributes["videos"].value) # Number of Extras
	  #episodes = int(show.attributes["episodes"].value) # Number of Episodes
      #channel = show.attributes["channel"].value
      item = tools.xbmcItem()
      info = item.info
      info["FileName"] = "%s?ch=%s&type=singleshow&id=%s%s" % (self.base, self.channel, se.group(1), self.urls['episodes'])
      info["Title"] = show.attributes["title"].value
      info["TVShowTitle"] = info["Title"]
      #epinfo = self.firstepisode(se.group(1))
      #if epinfo:
      # info = dict(epinfo.items() + info.items())
      self.xbmcitems.items.append(item)
  #self.xbmcitems.type = "tvshows"
  self.xbmcitems.addall()
 def _itemsearch(self, soup, provider): # Scrape items from a table-style HTML page
  baseurl = self._base_url(provider)
  item = tools.xbmcItem()
  title = soup.find("div", attrs={"class": 'catTitle'})
  if title:
   item.info["TVShowTitle"] = title.a.string.strip()
   href = re.match("%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (baseurl, self.urls["video1"], self.urls["video2"], self.urls["video3"]), title.a['href'])
   if href:
    image = soup.find("img")
    if image:
     item.info["Thumb"] = image['src']
    ep = soup.find("div", attrs={"class": 'epTitle'})
    if ep:
     if ep.a:
      item.info.update(self._seasonepisode(ep.a))
    date = soup.find("div", attrs={"class": 'epDate'})
  #  if date:
  #   sys.stderr.write(date.span[1].string.strip())
    item.titleplot()
    if self.prefetch:
     item.urls = self._geturls("%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), provider)
    else:
     item.playable = True
     item.info["FileName"] = "%s?ch=TV3&id=%s&provider=%s&info=%s" % (self.base, "%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), provider, item.infoencode())
    return item
   else:
    sys.stderr.write("_itemsearch: No href")
  else:
   sys.stderr.write("_itemsearch: No title")
 def index(self, type = 'showall', id = ""):
  page = webpage('/'.join([self.urls['base'], self.urls['media'], type, id]))
  if page.doc:
   div_tag = SoupStrainer('div')
   html_divtag = BeautifulSoup(page.doc, parseOnlyThese = div_tag)
   programmes = html_divtag.findAll(attrs={'class' : 'col gu1 video'})
   if len(programmes) > 0:
    for program in programmes:
     item = tools.xbmcItem()
     link = re.search("/media/([a-z]+)/([0-9]+)", program.p.a['href'])
     if link:
      item.info["Title"] = program.p.span.string
      item.info["Thumb"] = "%s%s" % (self.urls['base'], program.p.a.img['src'])
      if link.group(1) == "view":
       item.info["Title"] += ' ' + program.p.span.next.next.next.next.next.string.strip()[6:].strip()
       if self.prefetch:
        item.info["FileName"] = self._geturl(link.group(2))
       else:
        item.playable = True
        item.info["FileName"] = "%s?ch=%s&view=%s&info=%s" % (self.base, self.channel, link.group(2), item.infoencode())
      else:
       item.info["FileName"] = "%s?ch=%s&type=%s&id=%s" % (self.base, self.channel, link.group(1), link.group(2))
      self.xbmcitems.items.append(item)
    return self.xbmcitems.addall()
   else:
    sys.stderr.write("index: no programmes")
  else:
   sys.stderr.write("index: no page.doc")
Beispiel #27
0
 def index(self, fake=True):
     for folder in self.channels.keys():
         item = tools.xbmcItem()
         item.info["Title"] = folder
         item.info["FileName"] = "%s?ch=TV3&channel=%s" % (self.base,
                                                           folder)
         self.xbmcitems.items.append(item)
     self.xbmcitems.addall()
 def play(self, title, encodedinfo):
  item = tools.xbmcItem(self.channel)
  item.infodecode(encodedinfo)
  item['units'] = "MB"
  item['fanart'] = self.xbmcitems.fanart
  item['urls'] = self._geturls(title)
  item['videoInfo'].update(self._getMetadata(title))
  return self.xbmcitems.resolve(item, self.channel)
 def play(self, section, id):
  item = tools.xbmcItem(self.channel)
  item['id'] = id
  item['playable'] = True
  item['videoInfo'].update(self._getMetadata(section, id))
  url = item['videoInfo'].pop('url')

  return self.xbmcitems.play(item, url)
Beispiel #30
0
 def play(self, id, encodedinfo):
  item = tools.xbmcItem(self.channel)
  item.infodecode(encodedinfo)
  item['fanart'] = self.xbmcitems.fanart
  item['urls'] = self._geturls(id, item['videoInfo']["Thumb"],
                               item['videoInfo'].get('urlIn', None))
  item['playable'] = True
  item['videoInfo']['id'] = id
  return self.xbmcitems.resolve(item, self.channel)
 def search(self, query, page=1):
  query = urllib.quote(query)
  url = '%s/search?utf8=✓&search_text=%s&search=search&page=%s' % (self.urls['base'], query, page)
  pg = webpage(url, agent='chrome', cookie='nzos_html5=true')
  if not pg.doc:
   return []

  div_tag = SoupStrainer('div')
  html_divtag = BeautifulSoup(pg.doc, parseOnlyThese = div_tag)
  results = html_divtag.find(attrs={'class' : 'hero_results'})
  if not results:
   return []

  rows = results.findAll("div", attrs={'class' : re.compile(r'^(title|interview)$')})
  for row in rows:
   item = tools.xbmcItem(self.channel)
   info = item['videoInfo']
   src = row.a.img['src']
   if not src.startswith("http://"):
    src = self.urls['base'] + src
   item['videoInfo']['Thumb'] = src
   title = re.search("/title/(.*)", row.a['href'])
   if not title:
    title = re.search("/interviews/(.*)", row.a['href'])
   item['videoInfo']['Title'] = item.unescape(row.p.a.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 or not title.group(1).endswith("/series"):
    self.xbmcitems.items.append(item)

  nav = html_divtag.find(attrs={'class' : 'nav_pagination'})
  if nav:
   nextPage = nav.find("a", attrs={'rel' : 'next'})
   if nextPage:
    item = tools.xbmcItem(self.channel)
    info = item['videoInfo']
    pagenum = nextPage.contents[0]
    info["Title"] = "Next Page"
    info["FileName"] = "%s?ch=%s&filter=search&q=%s&page=%s" % (self.base, self.channel, query, pagenum)
    self.xbmcitems.items.append(item)
  return self.xbmcitems.addall()
Beispiel #32
0
 def channelindex(
     self, channel
 ):  #Create second level folder for the hierarchy view, only showing items for the selected top level folder
     for category in self.urls['categories']:
         item = tools.xbmcItem()
         item.info["Title"] = category
         item.info["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (
             self.base, channel, category.replace(" ", ""))
         self.xbmcitems.items.append(item)
     item = tools.xbmcItem()
     item.info["Title"] = language(30055)
     item.info["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (
         self.base, channel, "shows")
     self.xbmcitems.items.append(item)
     item = tools.xbmcItem()
     item.info["Title"] = language(30065)
     item.info["FileName"] = "%s?ch=TV3&channel=%s&cat=%s" % (
         self.base, channel, "search")
     self.xbmcitems.items.append(item)
     self.xbmcitems.addall()
Beispiel #33
0
 def _itemshow(self, channel, title,
               soup):  #Scrape items from a show-style HTML page
     baseurl = self.channels[channel]['base']
     item = tools.xbmcItem()
     link = soup.find("a")
     if link:
         print link
         if link.has_key('href'):
             print link['href']
             print "%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (
                 baseurl, self.urls["video1"], self.urls["video2"],
                 self.urls["video3"])
             href = re.match(
                 "%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" %
                 (baseurl, self.urls["video1"], self.urls["video2"],
                  self.urls["video3"]), link['href'])
             if href:
                 title = showname.strip()
                 if title != "":
                     item.info["TVShowTitle"] = title
                     image = soup.find("img")
                     if image:
                         item.info["Thumb"] = image['src']
                     se = soup.find("h4")
                     if se:
                         sea = se.find('a')
                         if sea:
                             item.info.update(
                                 self._seasonepisode(sea).string.strip())
                     plot = soup.find("p")
                     if plot:
                         if plot.string:
                             item.info["PlotOutline"] = plot.string.strip()
                     item.titleplot()
                     if self.prefetch:
                         item.urls = self._geturls(
                             "%s,%s,%s,%s" % (href.group(1), href.group(2),
                                              href.group(3), href.group(4)),
                             channel)
                     else:
                         item.playable = True
                         item.info[
                             "FileName"] = "%s?ch=TV3&channel=%s&id=%s&info=%s" % (
                                 self.base, channel, "%s,%s,%s,%s" %
                                 (href.group(1), href.group(2),
                                  href.group(3), href.group(4)),
                                 item.infoencode())
                     return item
             else:
                 sys.stderr.write("_itemshow: No title")
         else:
             sys.stderr.write("_itemshow: No href")
     else:
         sys.stderr.write("_itemshow: No link")
 def item(self):
  #self.channel = 'Shine'
  item = tools.xbmcItem()
  item.channel = 'Shine'
  item.fanart = os.path.join('extrafanart', item.channel + '.jpg')
  item.info["Title"] = 'Shine TV - Live Stream'
  item.info["Thumb"] = os.path.join(settings.getAddonInfo('path'), "resources/images/%s.png" % item.channel)
  item.info["Plot"] = "Shine TV is a television network of the Rhema Broadcasting Group Inc - New Zealand's largest Christian media organisation. On-air since December 2002, Shine broadcasts 24 hours nationwide on the SKY digital and Freeview Satellite platforms, with regional channels in Canterbury, Nelson and Wellington."
  item.info["Date"] = date.today().strftime("%d.%m.%Y")
  for quality, name in {30: 'low', 250: 'med', 1200: 'high'}.iteritems():
   item.urls[quality] = "http://wms-rbg.harmonycdn.net/shinetv-%s?MSWMExt=.asf" % name
  return item
Beispiel #35
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")
Beispiel #36
0
 def _indexfake(self): #Create a list of top level folders for the hierarchy view
  folders = list()
  folders.append(config.__language__(30052)) # "Categories"
  folders.append(config.__language__(30053)) # "Channels"
  folders.append(config.__language__(30054)) # "Genres"
  #folders.append(config.__language__(30055)) # "Shows"
  folders.append(config.__language__(30065)) # "Search"
  count = len(folders)
  for folder in folders:
   item = tools.xbmcItem()
   item.info["Title"] = folder
   item.info["FileName"] = "%s?ch=TV3&folder=%s" % (self.base, folder)
   self.xbmcitems.items.append(item)
Beispiel #37
0
 def index(self):
  page = webpage(self.url("ps3_navigation")) # http://tvnz.co.nz/content/ps3_navigation/ps3_xml_skin.xml
  xml = self._xml(page.doc)
  if xml:
   for stat in xml.getElementsByTagName('MenuItem'):
    type = stat.attributes["type"].value
    if type in ('shows', 'alphabetical'): #, 'distributor'
     m = re.search('/([0-9]+)/',stat.attributes["href"].value)
     if m:
      item = tools.xbmcItem()
      info = item.info
      info["Title"] = stat.attributes["title"].value
      info["FileName"] = "%s?ch=%s&type=%s&id=%s" % (self.base, self.channel, type, m.group(1))
      self.xbmcitems.items.append(item)
   item = tools.xbmcItem() # Search
   info = item.info
   info["Title"] = "Search"
   info["FileName"] = "%s?ch=TVNZ&type=%s" % (self.base, "search")
   self.xbmcitems.items.append(item)
  else:
   sys.stderr.write("No XML Data")
  self.xbmcitems.addall()
Beispiel #38
0
 def item(self):
     #self.channel = 'Shine'
     item = tools.xbmcItem()
     item.channel = 'Shine'
     item.fanart = os.path.join('extrafanart', item.channel + '.jpg')
     item.info["Title"] = 'Shine TV - Live Stream'
     item.info["Thumb"] = os.path.join(
         settings.getAddonInfo('path'),
         "resources/images/%s.png" % item.channel)
     item.info[
         "Plot"] = "Shine TV is a television network of the Rhema Broadcasting Group Inc - New Zealand's largest Christian media organisation. On-air since December 2002, Shine broadcasts 24 hours nationwide on the SKY digital and Freeview Satellite platforms, with regional channels in Canterbury, Nelson and Wellington."
     item.info["Date"] = date.today().strftime("%d.%m.%Y")
     for quality, name in {30: 'low', 250: 'med', 1200: 'high'}.iteritems():
         item.urls[
             quality] = "http://wms-rbg.harmonycdn.net/shinetv-%s?MSWMExt=.asf" % name
     return item
Beispiel #39
0
 def _itemdiv(self, soup,
              channel):  #Scrape items from a div-style HTML page
     baseurl = self.channels[channel]['base']
     item = tools.xbmcItem()
     #item.info["Studio"] = provider
     link = soup.find("a")
     if link:
         href = re.match(
             "%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" %
             (baseurl, self.urls["video1"], self.urls["video2"],
              self.urls["video3"]), link['href'])
         if href:
             showname = soup.find("div")
             if showname:
                 title = showname.string.strip()
                 if title != "":
                     item.info["TVShowTitle"] = title
                     image = soup.find("img")
                     if image:
                         item.info["Thumb"] = image['src']
                     se = soup.find("p")
                     if se:
                         item.info.update(self._seasonepisode(se))
                     item.titleplot()
                     if self.prefetch:
                         item.urls = self._geturls(
                             "%s,%s,%s,%s" % (href.group(1), href.group(2),
                                              href.group(3), href.group(4)),
                             channel)
                     else:
                         item.playable = True
                         item.info[
                             "FileName"] = "%s?ch=TV3&channel=%s&id=%s&info=%s" % (
                                 self.base, channel, "%s,%s,%s,%s" %
                                 (href.group(1), href.group(2),
                                  href.group(3), href.group(4)),
                                 item.infoencode())
                     return item
                 else:
                     sys.stderr.write("_itemdiv: No title")
             else:
                 sys.stderr.write("_itemdiv: No link.string")
         else:
             sys.stderr.write("_itemdiv: No href")
     else:
         sys.stderr.write("_itemdiv: No link")
Beispiel #40
0
 def _episode(self, ep):
  #se = re.search('/([0-9]+)/', ep.attributes["href"].value)
  se = re.search('([0-9]+)', ep.attributes["href"].value)
  if se:
   item = tools.xbmcItem()
   link = se.group(1)
   if ep.firstChild:
    item.info["Plot"] = ep.firstChild.data.strip()
   title = ep.attributes["title"].value
   subtitle = ep.attributes["sub-title"].value
   if not subtitle:
    titleparts = title.split(': ', 1) # Some Extras have the Title and Subtitle put into the title attribute separated by ': '
    if len(titleparts) == 2:
     title = titleparts[0]
     subtitle = titleparts[1]
   sxe = ""
   episodeparts = ep.attributes["episode"].value.split('|')
   if len(episodeparts) == 3:
    #see = re.search('Series ([0-9]+), Episode ([0-9]+)', episodeparts[0].strip()) # Need to catch "Episodes 7-8" as well as "Epsiode 7". Also need to catch episode without series
    see = re.search('(?P<s>Se(ries|ason) ([0-9]+), )?Episodes? (?P<e>[0-9]+)(-(?P<e2>[0-9]+))?', episodeparts[0].strip())
    if see:
     try:
      item.info["Season"]  = int(see.group("s"))
     except:
      item.info["Season"] = 1
     item.info["Episode"] = int(see.group("e"))
    sxe = item.sxe()
    if not sxe:
      sxe = episodeparts[0].strip() # E.g. "Coming Up" or "Catch Up"
    date = self._date(episodeparts[1].strip())
    if date:
     item.info["Date"] = date
    item.info["Premiered"] = episodeparts[1].strip()
    item.info["Duration"] = self._duration(episodeparts[2].strip())
   item.info["TVShowTitle"] = title
   item.info["Title"] = " ".join((title, sxe, subtitle)) #subtitle
   item.info["Thumb"] = ep.attributes["src"].value
   if self.prefetch:
    item.urls = self._geturls(link, item.info["Thumb"])
   else:
    item.playable = True
    item.info["FileName"] = "%s?ch=%s&id=%s&info=%s" % (self.base, self.channel, link, item.infoencode())
   return item
  else:
   sys.stderr.write("_episode: No se")
 def sections(self, section):
     page = webpage('%s/%s/%s/' %
                    (self.urls['base'], section, self.urls['videos']))
     if page.doc:
         div_tag = SoupStrainer('div')
         html_divtag = BeautifulSoup(page.doc, parseOnlyThese=div_tag)
         #landing = html_divtag.find(attrs = {'id' : 'landing_video'})
         gallery = html_divtag.find(attrs={'class': 'gallery_box'})
         if gallery:
             videos = gallery.findAll('div')
             if len(videos) > 0:
                 for video in videos:
                     link = video.find("a")
                     if link:
                         if link.string:
                             item = tools.xbmcItem()
                             link = video.find("a")
                             item.info["Title"] = link.string.strip()
                             image = video.find("img")
                             if image:
                                 item.info["Thumb"] = image['src']
                             videoid = re.match(
                                 '/%s/%s/([0-9]+)/' %
                                 (section, self.urls['videos']),
                                 link['href'])
                             if videoid:
                                 if self.prefetch:
                                     item.urls = [
                                         self._geturl(section, videoid)
                                     ]
                                 else:
                                     item.playable = True
                                     item.info[
                                         "FileName"] = "%s?ch=%s&section=%s&id=%s" % (
                                             self.base, self.channel,
                                             section, videoid.group(1))
                                 self.xbmcitems.items.append(item)
                 self.xbmcitems.addall()
             else:
                 sys.stderr.write("sections: no videos")
         else:
             sys.stderr.write("sections: no gallery_box")
     else:
         sys.stderr.write("sections: no page.doc")
 def index(self):
     page = webpage(self.urls['base'])
     if page.doc:
         div_tag = SoupStrainer('div')
         html_divtag = BeautifulSoup(page.doc, parseOnlyThese=div_tag)
         menu = html_divtag.find(attrs={'id': 'home_nav'})
         if menu:
             menuitems = menu.findAll('a')
             for menuitem in menuitems:
                 item = tools.xbmcItem()
                 item.info["Title"] = menuitem.string
                 item.info["FileName"] = "%s?ch=%s&section=%s" % (
                     self.base, self.channel, menuitem["href"][1:-1])
                 self.xbmcitems.items.append(item)
             self.xbmcitems.addall()
         else:
             sys.stderr.write("index: no menu")
     else:
         sys.stderr.write("index: no page.doc")
 def index(self, type='showall', id=""):
     page = webpage('/'.join(
         [self.urls['base'], self.urls['media'], type, id]))
     if page.doc:
         div_tag = SoupStrainer('div')
         html_divtag = BeautifulSoup(page.doc, parseOnlyThese=div_tag)
         programmes = html_divtag.findAll(attrs={'class': 'col gu1 video'})
         if len(programmes) > 0:
             for program in programmes:
                 item = tools.xbmcItem()
                 link = re.search("/media/([a-z]+)/([0-9]+)",
                                  program.p.a['href'])
                 if link:
                     item.info["Title"] = program.p.span.string
                     item.info["Thumb"] = "%s%s" % (self.urls['base'],
                                                    program.p.a.img['src'])
                     if link.group(1) == "view":
                         item.info[
                             "Title"] += ' ' + program.p.span.next.next.next.next.next.string.strip(
                             )[6:].strip()
                         if self.prefetch:
                             item.info["FileName"] = self._geturl(
                                 link.group(2))
                         else:
                             item.playable = True
                             item.info[
                                 "FileName"] = "%s?ch=%s&view=%s&info=%s" % (
                                     self.base, self.channel, link.group(2),
                                     item.infoencode())
                     else:
                         item.info[
                             "FileName"] = "%s?ch=%s&type=%s&id=%s" % (
                                 self.base, self.channel, link.group(1),
                                 link.group(2))
                     self.xbmcitems.items.append(item)
             self.xbmcitems.addall()
         else:
             sys.stderr.write("index: no programmes")
     else:
         sys.stderr.write("index: no page.doc")
Beispiel #44
0
 def _itemsearch(self, soup,
                 provider):  # Scrape items from a table-style HTML page
     baseurl = self._base_url(provider)
     item = tools.xbmcItem()
     title = soup.find("div", attrs={"class": 'catTitle'})
     if title:
         item.info["TVShowTitle"] = title.a.string.strip()
         href = re.match(
             "%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" %
             (baseurl, self.urls["video1"], self.urls["video2"],
              self.urls["video3"]), title.a['href'])
         if href:
             image = soup.find("img")
             if image:
                 item.info["Thumb"] = image['src']
             ep = soup.find("div", attrs={"class": 'epTitle'})
             if ep:
                 if ep.a:
                     item.info.update(self._seasonepisode(ep.a))
             date = soup.find("div", attrs={"class": 'epDate'})
             #  if date:
             #   sys.stderr.write(date.span[1].string.strip())
             item.titleplot()
             if self.prefetch:
                 item.urls = self._geturls(
                     "%s,%s,%s,%s" % (href.group(1), href.group(2),
                                      href.group(3), href.group(4)),
                     provider)
             else:
                 item.playable = True
                 item.info[
                     "FileName"] = "%s?ch=TV3&id=%s&provider=%s&info=%s" % (
                         self.base, "%s,%s,%s,%s" %
                         (href.group(1), href.group(2), href.group(3),
                          href.group(4)), provider, item.infoencode())
             return item
         else:
             sys.stderr.write("_itemsearch: No href")
     else:
         sys.stderr.write("_itemsearch: No title")
Beispiel #45
0
 def _itemtable(self, soup, provider,
                title):  #Scrape items from a table-style HTML page
     item = tools.xbmcItem()
     link = soup.find('a')
     if link:
         if link.string:
             plot = link.string.strip()
             if plot != "":
                 item.info["PlotOutline"] = plot
                 item.info["TVShowTitle"] = title
                 item.info.update(self._seasonepisode(link))
                 item.titleplot()
                 href = re.search(
                     "%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" %
                     (self._base_url("tv3"), self.urls["video1"],
                      self.urls["video2"], self.urls["video3"]),
                     link['href'])
                 if href:
                     if self.prefetch:
                         item.urls = self._geturls(
                             "%s,%s,%s,%s" % (href.group(1), href.group(2),
                                              href.group(3), href.group(4)),
                             provider)
                     else:
                         item.playable = True
                         item.info[
                             "FileName"] = "%s?ch=TV3&id=%s&provider=%s&info=%s" % (
                                 self.base, "%s,%s,%s,%s" %
                                 (href.group(1), href.group(2),
                                  href.group(3), href.group(4)), provider,
                                 item.infoencode())
                 return item
             else:
                 sys.stderr.write("_itemtable: No plot")
         else:
             sys.stderr.write("_itemtable: No link.string")
     else:
         sys.stderr.write("_itemtable: No link")
 def __init__(self):
     self.base = sys.argv[0]
     self.channel = "Prime"
     self.urls = dict()
     self.urls[
         'base'] = 'http://www.primetv.co.nz/Portals/1/PrimeNewsVideo/'
     self.urls['file1'] = 'PRIME_'
     self.urls['file2'] = '_Flash.flv'
     self.programs = dict()
     self.programs[
         'News'] = "Prime News: First At 5:30 brings you the top news and sports stories from New Zealand and around the world."
     self.programs['Sport'] = "Business & Sport News"
     self.programs['Weather'] = "The Weather News"
     self.xbmcitems = tools.xbmcItems(self.channel)
     for channel, description in self.programs.iteritems():
         item = tools.xbmcItem()
         item.channel = self.channel
         item.info['Title'] = channel
         item.info["Plot"] = description
         item.info['FileName'] = self.urls['base'] + self.urls[
             'file1'] + channel.upper() + self.urls['file2']
         self.xbmcitems.items.append(item)
     self.xbmcitems.addall()
Beispiel #47
0
 def shows(self, channel
           ):  #Create a second level list of TV Shows from a TV3 webpage
     #doc = resources.tools.gethtmlpage("%s/Shows/tabid/64/Default.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
     #doc = resources.tools.gethtmlpage("%s/Shows.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
     page = webpage("%s/%s/%s" %
                    (self.channels[channel]['base'],
                     self.channels[channel]['ondemand'], "TitleAZ.aspx"))
     if page.doc:
         html_divtag = BeautifulSoup(page.doc)
         showsdiv = html_divtag.findAll('div', attrs={"class": "grid_2"})
         if len(showsdiv) > 0:
             for show in showsdiv:
                 item = tools.xbmcItem()
                 title = show.find('p').find('a')
                 if title:
                     if title.string:
                         if title['href'][len('http://www.'
                                              ):len('http://www.') +
                                          3] == channel[0:3].lower():
                             item.info["Title"] = title.string.strip()
                             image = show.find("img")
                             if image:
                                 item.info["Thumb"] = image['src']
                             item.info[
                                 "FileName"] = "%s?ch=TV3&channel=%s&cat=%s&title=%s" % (
                                     self.base, channel, "show",
                                     urllib.quote(
                                         item.info["Title"].replace(
                                             " ", "")))
                             self.xbmcitems.items.append(item)
             self.xbmcitems.addall()
         else:
             sys.stderr.write(
                 "showsindex: Couldn't find any videos in list")
     else:
         sys.stderr.write("showsindex: Couldn't get index webpage")
Beispiel #48
0
 def _itematoz(self, soup,
               provider):  #Scrape items from an AtoZ-style HTML page
     baseurl = self._base_url(provider)
     item = tools.xbmcItem()
     if soup.find('h5'):
         link = soup.h5.find("a", attrs={"href": re.compile(baseurl)})
         if link:
             infoitems = {}
             href = re.match(
                 "%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" %
                 (baseurl, self.urls["video1"], self.urls["video2"],
                  self.urls["video3"]), link['href'])
             if href:
                 if link.string:
                     title = link.string.strip()
                     if title != "":
                         item.info["TVShowTitle"] = title
                         image = soup.find("img",
                                           attrs={
                                               "src":
                                               re.compile(
                                                   self.urls["IMG_RE2"]),
                                               "title":
                                               True
                                           })
                         if image:
                             item.info["Thumb"] = image['src']
                         item.info.update(
                             self._seasonepisode(soup.contents[4]))
                         item.titleplot()
                         plot = soup.find("span", attrs={"class": "lite"})
                         if plot.string:
                             cleanedplot = plot.string.strip()
                             if cleanedplot:
                                 item.info["Plot"] = item.unescape(
                                     cleanedplot)
                         if self.prefetch:
                             item.urls = self._geturls(
                                 "%s,%s,%s,%s" %
                                 (href.group(1), href.group(2),
                                  href.group(3), href.group(4)), channel)
                         else:
                             item.playable = True
                             item.info[
                                 "FileName"] = "%s?ch=%s&id=%s&provider=%s&info=%s" % (
                                     self.base, self.channel,
                                     "%s,%s,%s,%s" %
                                     (href.group(1), href.group(2),
                                      href.group(3), href.group(4)),
                                     provider, item.infoencode())
                         if "FileName" in item.info or len(item.urls) > 0:
                             return item
                     else:
                         sys.stderr.write("_itematoz: No title")
                 else:
                     sys.stderr.write("_itematoz: No link.string")
             else:
                 sys.stderr.write("_itematoz: No href")
         else:
             sys.stderr.write("_itematoz: No link")
     else:
         sys.stderr.write("_itematoz: No h5")
Beispiel #49
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")
Beispiel #50
0
    def index(self, filter="/explore/"):
        filterarray = filter.strip('/').split('/')
        filterlevel = len(filterarray)
        print filter
        print filter.strip('/')
        print str(filterlevel)
        url = self.urls['base'] + filter
        #sys.stderr.write("URL: " + url)
        #sys.stderr.write('explore_filter_%s' % str(filterlevel))
        page = webpage(url, 'chrome', 'nzos_html5=true')
        #page = webpage(self.urls['base'])
        if page.doc:
            #resources.tools.gethtmlpage("http://www.nzonscreen.com/html5/opt_in", "chrome", 1) # Get a cookie for this session to enable the HTML5 video tag
            div_tag = SoupStrainer('div')
            html_divtag = BeautifulSoup(page.doc, parseOnlyThese=div_tag)
            sections = html_divtag.find(
                attrs={'id': 'explore_filter_%s' % str(filterlevel)})
            if not sections:
                sections = html_divtag.find(attrs={'id': 'explore_listview'})
            if sections:
                links = sections.findAll('a')
                if len(links) > 0:
                    for link in links:
                        #     if link.string:
                        #     sys.stderr.write(link.contents[0].string)
                        item = tools.xbmcItem()
                        info = item.info
                        info["FileName"] = "%s?ch=%s&filter=%s" % (
                            self.base, self.channel, urllib.quote(
                                link["href"]))
                        #info["Title"] = link.contents[0].string.strip()
                        if link.string:
                            info["Title"] = link.string.strip()
                        else:
                            filterarray = link["href"].split('/')
                            info["Title"] = filterarray[len(filterarray) -
                                                        1].capitalize()

    #     info["Thumb"] =
                        self.xbmcitems.items.append(item)
                    if filterlevel == 1:
                        item = tools.xbmcItem()
                        info = item.info
                        info["FileName"] = "%s?ch=%s&filter=search" % (
                            self.base, self.channel)
                        info["Title"] = "Search"
                        self.xbmcitems.items.append(item)
                else:
                    #    if filterarray[filterlevel] ==
                    nav = html_divtag.find(attrs={'class': 'nav_pagination'})
                    if nav:
                        pages = nav.findAll('a')
                        if pages:
                            for page in pages:
                                if page.string:
                                    lastpage = page.string.strip()
                                    #url = page['href']
                            for i in range(1, int(lastpage)):
                                item = tools.xbmcItem()
                                info = item.info
                                info[
                                    "FileName"] = "%s?ch=%s&filter=%s&page=%s" % (
                                        self.base, self.channel,
                                        urllib.quote(filter), str(i))
                                info["Title"] = 'Page %s' % str(i)
                                self.xbmcitems.items.append(item)
                self.xbmcitems.addall()
            else:
                sys.stderr.write("index: No sections")
        else:
            sys.stderr.write("index: No page.doc")
 def programmes(self, type, urlext):
     if type == "channel":
         folder = 1
         url = self.urls['base']
     elif type == "video":
         folder = 0
         url = "%s/assets/php/slider.php?channel=%s" % (self.urls['base'],
                                                        urlext)
     elif type == "search":
         folder = 0
         url = "%s/search?search_keyword=%s" % (self.urls['base'],
                                                urlext.replace(" ", "+"))
     page = webpage(url)
     if page.doc:
         if type == "channel" or type == "search":
             div_tag = SoupStrainer('div')
             html_divtag = BeautifulSoup(page.doc, parseOnlyThese=div_tag)
             programmes = html_divtag.findAll(attrs={'class': 'programmes'})
         elif type == "video":
             div_tag = SoupStrainer('body')
             html_divtag = BeautifulSoup(page.doc, parseOnlyThese=div_tag)
             programmes = html_divtag.findAll(
                 attrs={'class': 'slider slider-small'})
         if type == "search":
             type = "video"
         if len(programmes) > 0:
             for program in programmes:
                 list = program.find('ul')
                 if list:
                     listitems = list.findAll('li')
                     count = len(listitems)
                     if count > 0:
                         for listitem in listitems:
                             link = listitem.find(
                                 'a',
                                 attrs={'href': re.compile("^/%s/" % type)})
                             if link.img:
                                 if re.search("assets/images/%ss/" % type,
                                              link.img["src"]):
                                     #item = tools.xbmcItem()
                                     item = tools.xbmcItem()
                                     if listitem.p.string:
                                         item.info[
                                             "Title"] = listitem.p.string.strip(
                                             )
                                     else:
                                         item.info["Title"] = link.img[
                                             "alt"]
                                     item.info["Thumb"] = "%s/%s" % (
                                         self.urls['base'], link.img["src"])
                                     index = re.search(
                                         "assets/images/%ss/([0-9]*?)-mini.jpg"
                                         % type, link.img["src"]).group(1)
                                     item.info[
                                         "FileName"] = "%s?ch=%s&%s=%s" % (
                                             self.base, self.channel, type,
                                             urllib.quote(index))
                                     if type == "video":
                                         if self.prefetch:
                                             item.info[
                                                 "FileName"] = self._geturl(
                                                     index)
                                         else:
                                             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("Search returned no results")
         else:
             sys.stderr.write("Couldn't find any programs")
     else:
         sys.stderr.write("Couldn't get page")