コード例 #1
0
def INDEX_SHOWS(provider): #Create a second level list of TV Shows from a TV3 webpage
 #doc = tools.gethtmlpage("%s/Shows/tabid/64/Default.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
 doc = tools.gethtmlpage("%s/Shows.aspx" % ("http://www.tv3.co.nz")) #Get our HTML page with a list of video categories
 if doc:
  html_divtag = BeautifulSoup(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:
     info = tools.defaultinfo(1)
     info["Title"] = link.string.strip()
     catid = link['href']
     if info["Title"] == "60 Minutes": #The URL on the next line has more videos
      info["FileName"] = "%s?ch=TV3&cat=%s&title=%s&catid=%s" % (sys.argv[0], "shows", urllib.quote(info["Title"]), urllib.quote(catid)) #"http://ondemand.tv3.co.nz/Default.aspx?TabId=80&cat=22"
     else:
      info["FileName"] = "%s?ch=TV3&cat=%s&title=%s&catid=%s" % (sys.argv[0], "shows", urllib.quote(info["Title"]), urllib.quote(catid))
     info["Count"] = count
     count += 1
     tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 1)
   else:
    sys.stderr.write("Couldn't find any videos in list")
  else:
   sys.stderr.write("Couldn't find video list")
 else:
  sys.stderr.write("Couldn't get index webpage")
コード例 #2
0
def INDEX_FOLDER(folder): #Create second level folder for the hierarchy view, only showing items for the selected top level folder
 infopages = dict()
 infopages["0"]  = ("63", localize(30052), "tv3", localize(30056)) # Latest
 infopages["1"]  = ("61", localize(30052), "tv3", localize(30057)) # Most Watched
 infopages["2"]  = ("64", localize(30052), "tv3", localize(30058)) # Expiring soon
 infopages["3"]  = ("70", localize(30052), "atoz", "A - Z")
 infopages["4"]  = ("71", localize(30053), "tv3", "TV3")
 infopages["5"]  = ("72", localize(30053), "c4tv", "FOUR")
 infopages["6"]  = ("65", localize(30054), "tv3", localize(30059)) # Comedy
 infopages["7"]  = ("66", localize(30054), "tv3", localize(30060)) # Drama
 infopages["8"]  = ("67", localize(30054), "tv3", localize(30061)) # News/Current affairs
 infopages["9"]  = ("68", localize(30054), "tv3", localize(30062)) # Reality
 infopages["10"] = ("82", localize(30054), "tv3", localize(30063)) # Sports
 infopages["11"] = ("80", localize(30052), "tv3", localize(30064)) # All
 #infopages["12"] = ("74", "RSS", "tv3", "RSS Feeds")
 #infopages["13"] = ("81", "Categories", "tv3", "C4 Highlights")
 #infopages["13"] = ("73", "Categories", "tv3", "All (Small)")
 for index in infopages:
  if infopages[index][1] == folder:
   info = tools.defaultinfo(1)
   info["Title"] = infopages[index][3]
   info["Count"] = int(index)
   info["FileName"] = "%s?ch=TV3&cat=%s&catid=%s" % (sys.argv[0], infopages[index][2], infopages[index][0])
   tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 1)
 if folder == "Shows":
  INDEX_SHOWS("tv3")
 elif folder == "Search":
  INDEX_SEARCH()
コード例 #3
0
def add_item_div(soup, provider, count): #Scrape items from a div-style HTML page
 baseurl = base_url(provider)
 info = tools.defaultinfo()
 info["Studio"] = provider
 sys.stderr.write(baseurl)
 link = soup.find("a", attrs={"href": re.compile(baseurl)})
 if link:
  href = re.match("%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (baseurl, tv3_urls["VIDEO1"], tv3_urls["VIDEO2"], tv3_urls["VIDEO3"]), link['href'])
  if href:
   if link.string:
    title = link.string.strip()
    if title <> "":
     info["TVShowTitle"] = title
     image = soup.find("img", attrs={"src": re.compile(tv3_urls["IMG_RE"]), "title": True})
     if image:
      info.update(tools.imageinfo(image))
     se = soup.find("span", attrs={"class": "title"})
     if se:
      info.update(seasonepisode(se))
     date = soup.find("span", attrs={"class": "dateAdded"})
     if date:
      info.update(dateduration(date))
     info["Title"] = tools.itemtitle(info["TVShowTitle"], info["PlotOutline"])
     info["Count"] = count
     plot = soup.find("div", attrs={"class": "left"}).string
     if plot:
      if plot.strip() <> "":
       info["Plot"] = tools.unescape(plot.strip())
     info["FileName"] = "%s?ch=TV3&id=%s&info=%s" % (sys.argv[0], "%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), urllib.quote(str(info)))
     tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 0)
コード例 #4
0
def INDEX(provider): #Create a list of top level folders as scraped from TV3's website
 doc = tools.gethtmlpage("%s/tabid/56/default.aspx" % (base_url(provider))) #Get our HTML page with a list of video categories
 if doc:
  a_tag = SoupStrainer('a')
  html_atag = BeautifulSoup(doc, parseOnlyThese = a_tag)
  links = html_atag.findAll(attrs={"rel": "nofollow", "href": re.compile(tv3_urls["CAT_RE"])}) #, "title": True
  if len(links) > 0:
   count = 0
   for link in links:
    info = tools.defaultinfo(1)
    info["Title"] = link.string
    caturl = link['href']
    catid = re.search('%s([0-9]+)' % (tv3_urls["CAT_RE"]), caturl).group(1)
    if info["Title"] == "Title (A - Z)":
     cat = "atoz"
    elif info["Title"] == "TV3 Shows":
     cat = "tv3"
    #elif info["Title"] == "C4TV Shows":
    elif info["Title"] == "FOUR Shows":
     cat = "c4tv"
    else:
     cat = "tv"
    if catid:
     info["Count"] = count
     count += 1
     info["FileName"] = "%s?ch=TV3&cat=%s&catid=%s" % (sys.argv[0], cat, catid)
     tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 1)
  else:
   sys.stderr.write("Couldn't find any categories")
 else:
  sys.stderr.write("Couldn't get index webpage")
コード例 #5
0
def add_item_show(soup, provider, count, title): #Scrape items from a show-style HTML page
 info = tools.defaultinfo()
 info["Studio"] = provider
 bold = soup.find('b')
 if bold:
  link = bold.find("a", attrs={"href": re.compile(tv3_urls["FEEDBURNER_RE"])})
  if link:
   urltype = "other"
  else:
   link = bold.find("a", attrs={"href": re.compile(base_url("tv3"))})
   if link:
    urltype = "tv3"
  if link:
   if link.string:
    plot = link.string.strip()
    if plot <> "":
     info["PlotOutline"] = plot
     info["TVShowTitle"] = title
     image = soup.find("img", attrs={"src": re.compile(tv3_urls["IMG_RE"])})
     if image:
      info.update(tools.imageinfo(image))
     info.update(seasonepisode(link))
     info["Title"] = tools.itemtitle(info["TVShowTitle"], info["PlotOutline"])
     info["Count"] = count
     if urltype == "tv3":
      href = re.search("%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (base_url("tv3"), tv3_urls["VIDEO1"], tv3_urls["VIDEO2"], tv3_urls["VIDEO3"]), link['href'])
      if href:
       info["FileName"] = "%s?ch=TV3&id=%s&info=%s" % (sys.argv[0], "%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), urllib.quote(str(info)))
     elif urltype == "other":
      info["FileName"] = "%s?ch=TV3&id=%s&info=%s" % (sys.argv[0], urllib.quote(link["href"]), urllib.quote(str(info)))
     tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 0)
コード例 #6
0
def SHOW_EPISODES(id):
 getEpisodes(id, "%s/content/%s/ps3_xml_skin.xml" % (BASE_URL, id))
 link = tools.gethtmlpage("%s/content/%s_extras_group/ps3_xml_skin.xml" % (BASE_URL, id[:-15]), "ps3")
 if link:
  node = tools.getxmldocument(link)
  if node:
   info = tools.defaultinfo(1)
   info["FileName"] = "%s?ch=TVNZ&type=shows&id=%s_extras_group" % (sys.argv[0], id[:-15])
   info["Title"] = "Extras"
   tools.addlistitem(int(sys.argv[1]), info, FANART_URL, 1)
 return
コード例 #7
0
def PROGRAMMES(type, urlext):
 if type == "channel":
  folder = 1
  url = ziln_urls["ZILN"]
 elif type == "video":
  folder = 0
  #url = "%s/channel/%s" % (ziln_urls["ZILN"], urlext)
  url = "%s/assets/php/slider.php?channel=%s" % (ziln_urls["ZILN"], urlext)
 elif type == "search":
  folder = 0
  url = "%s/search?search_keyword=%s" % (ziln_urls["ZILN"], urlext.replace(" ", "+"))
 doc = tools.gethtmlpage(url)
 if doc:
  if type == "channel" or type == "search":
   div_tag = SoupStrainer('div')
   html_divtag = BeautifulSoup(doc, parseOnlyThese = div_tag)
   programmes = html_divtag.findAll(attrs={'class' : 'programmes'})
  elif type == "video":
   div_tag = SoupStrainer('body')
   html_divtag = BeautifulSoup(doc, parseOnlyThese = div_tag)
   programmes = html_divtag.findAll(attrs={'class' : 'slider slider-small'})
  if type == "search":
   type = "video"
  if len(programmes) > 0:
   for programme in programmes:
    list = programme.find('ul')
    if list:
     listitems = list.findAll('li')
     if len(listitems) > 0:
      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"]):
         info = tools.defaultinfo(1)
         #info["Title"] = link.img["alt"]
         if listitem.p.string:
          info["Title"] = listitem.p.string.strip()
         else:
          info["Title"] = link.img["alt"]
         info["Thumb"] = "%s/%s" % (ziln_urls["ZILN"], link.img["src"])
         info["Count"] = count
         count += 1
         #channelurl = re.search("/%s/(.*)" % type, link["href"]).group(1)
         channelurl = re.search("assets/images/%ss/([0-9]*?)-mini.jpg" % type, link.img["src"]).group(1)
         #infourl = "&info=%s" % urllib.quote(str(info))
         info["FileName"] = "%s?ch=Ziln&%s=%s" % (sys.argv[0], type, urllib.quote(channelurl))
         tools.addlistitem(int(sys.argv[1]), info, ziln_urls["Fanart"], folder)
    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")
コード例 #8
0
def RESOLVE(index): #, info
 doc = tools.gethtmlpage("%s/playlist/null/%s" % (ziln_urls["ZILN"], index))
 if doc:
  soup = BeautifulStoneSoup(doc)
  #tools.message(soup.find('media:content')["url"])
  #minidom.parseString(doc).documentElement.getElementsByTagName("media:content")[0].attributes["url"].value
  info = tools.defaultinfo(0)
  info["Title"] = soup.find('item').title.contents[0]
  info["Thumb"] = soup.find('jwplayer:image').contents[0]
  info["Plot"] = soup.find('description').contents[0]
  uri = "%s%s" % (ziln_urls["ZILN"], soup.find('media:content')["url"])
  tools.addlistitem(int(sys.argv[1]), info, ziln_urls["Fanart"], 0, 1, uri)
コード例 #9
0
def INDEX():
 info = tools.defaultinfo(1)
 info["Title"] = localize(30053)
 info["Count"] = 1
 #info["Thumb"] = "DefaultVideoPlaylists.png"
 info["FileName"] = "%s?ch=Ziln&folder=channels" % sys.argv[0]
 tools.addlistitem(int(sys.argv[1]), info, ziln_urls["Fanart"], 1)
 info = tools.defaultinfo(1)
 info["Title"] = localize(30065)
 info["Count"] = 2
 info["Thumb"] = "DefaultVideoPlaylists.png"
 info["FileName"] = "%s?ch=Ziln&folder=search" % sys.argv[0]
 tools.addlistitem(int(sys.argv[1]), info, ziln_urls["Fanart"], 1)
コード例 #10
0
def getShow(show):
 se = re.search('/content/(.*)_(episodes|extras)_group/ps3_xml_skin.xml', show.attributes["href"].value)
 if se:
  info = tools.defaultinfo(1)
  info["FileName"] = "%s?ch=TVNZ&type=singleshow&id=%s_episodes_group" % (sys.argv[0], se.group(1))
  info["Title"] = show.attributes["title"].value
  #if "videos" in show.attributes.keys():
  # videos = int(show.attributes["videos"].value)
  #else:
  # videos = 0
  #channel = show.attributes["channel"].value
  #url = "%s?ch=TVNZ&type=singleshow&id=%s_episodes_group" % (sys.argv[0],show_id)
  tools.addlistitem(int(sys.argv[1]), info, FANART_URL, 1)
コード例 #11
0
def RESOLVE(channel, count):
 info = tools.defaultinfo(0)
 info["Title"] = 'Shine TV (Live Stream)'
 info["Thumb"] = os.path.join(addon.getAddonInfo('path'), "resources/images/%s.png" % channel)
 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."
 info["Date"] = date.today().strftime("%d.%m.%Y")
 quality = 'fast'
 if addon.getSetting('%s_quality' % channel) == "Low":
  quality = 'mobile'
 elif addon.getSetting('%s_quality' % channel) == "Medium":
  quality = 'slow'
 info["FileName"] = "%s%s" % ("mms://wnss1.streaming.net.nz/rbg-shinetv-", quality)
 tools.addlistitem(int(sys.argv[1]), info, "resources/images/%s.jpg" % channel, 0, count)
コード例 #12
0
def RESOLVE(id, info):
 link = tools.gethtmlpage("%s/content/%s/ta_ent_smil_skin.smil?platform=PS3" % (BASE_URL, id), "ps3")
 if link:
  node = tools.getxmldocument(link)
  if node:
   urls=list()
   for chapter in node.getElementsByTagName('seq'):
    # grab out the advert link
    if addon.getSetting('TVNZ_showads') == 'true':
     ad = getAdvert(chapter)
     if len(ad) > 0:
      urls.append(ad)
    maxbitrate = 0
    minbitrate = 9999999999
    for video in chapter.getElementsByTagName('video'):
     bitrate = int(video.attributes["systemBitrate"].value)
     if bitrate > maxbitrate:
      maxbitrate = bitrate
     if bitrate < minbitrate:
      minbitrate = bitrate
    requiredbitrate = 700000 #Medium = 700000
    if addon.getSetting('TVNZ_quality') == "High": #High = 1500000
     requiredbitrate = maxbitrate
    elif addon.getSetting('TVNZ_quality') == "Low": #Low = 300000
     requiredbitrate = minbitrate
    for video in chapter.getElementsByTagName('video'):
     bitrate = int(video.attributes["systemBitrate"].value)
     if bitrate == requiredbitrate:
      url = video.attributes["src"].value
      if url[:7] == 'http://':
       # easy case - we have an http URL
       urls.append(url)
       sys.stderr.write("HTTP URL: " + url)
      elif url[:5] == 'rtmp:':
       # rtmp case
       rtmp_url = "rtmpe://fms-streaming.tvnz.co.nz/tvnz.co.nz"
       playpath = " playpath=" + url[5:]
       flashversion = " flashVer=MAC%2010,0,32,18"
       swfverify = " swfurl=http://tvnz.co.nz/stylesheets/tvnz/entertainment/flash/ondemand/player.swf swfvfy=true"
       conn = " conn=S:-720"
       urls.append(rtmp_url + playpath + flashversion + swfverify + conn)
       sys.stderr.write("RTMP URL: " + rtmp_url + playpath + flashversion + swfverify + conn)
   if len(urls) == 0:
    sys.stderr.write("No playback URLs found!")
    return
  
   if len(urls) == 1:
    uri = urls[0]
   elif len(urls) > 1:
    uri = tools.constructStackURL(urls)
   tools.addlistitem(int(sys.argv[1]), info, FANART_URL, 0, 1, uri)
コード例 #13
0
def INDEX_FOLDERS(): #Create a list of top level folders for the hierarchy view
 folders = dict()
 folders["0"] = localize(30052) # "Categories"
 folders["1"] = localize(30053) # "Channels"
 folders["2"] = localize(30054) # "Genres"
 #folders["3"] = localize(30055) # "Shows"
 folders["4"] = localize(30065) # "Search"
 count = len(folders)
 for index in folders:
  info = tools.defaultinfo(1)
  info["Title"] = folders[index]
  info["Count"] = int(index)
  info["FileName"] = "%s?ch=TV3&folder=%s" % (sys.argv[0], folders[index])
  tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 1, count)
コード例 #14
0
def INDEX():
 link = tools.gethtmlpage("%s/content/ps3_navigation/ps3_xml_skin.xml" % (BASE_URL), "ps3")
 if link:
  count = 0
  node = tools.getxmldocument(link)
  if node:
   for stat in node.getElementsByTagName('MenuItem'):
    type = stat.attributes["type"].value
    if type in ('shows', 'alphabetical'): #, 'distributor'
     m = re.search('/([0-9]+)/',stat.attributes["href"].value)
     if m:
      info = tools.defaultinfo(1)
      info["Title"] = stat.attributes["title"].value
      info["Count"] = count
      count += 1
      info["FileName"] = "%s?ch=TVNZ&type=%s&id=%s" % (sys.argv[0], type, m.group(1))
      tools.addlistitem(int(sys.argv[1]), info, FANART_URL, 1)
コード例 #15
0
def RESOLVE(channel, count):
 info = tools.defaultinfo(0)
 info["Title"] = 'Parliament TV (Live Stream)'
 info["Thumb"] = os.path.join(addon.getAddonInfo('path'), "resources/images/%s.png" % channel)
 info["Plot"] = "Parliament TV provides live broadcasts from the House of Representatives. Question time is replayed each day at 6pm and 10pm."
 info["Date"] = date.today().strftime("%d.%m.%Y")
 quality = '384'
 if addon.getSetting('%s_stream' % channel) == "Apple Quicktime":
  quality = '512'
 if addon.getSetting('%s_quality' % channel) == "Low":
  quality = '56'
 elif addon.getSetting('%s_quality' % channel) == "Medium":
  quality = '128'
 info["FileName"] = "%s%s" % ("mms://wms-parliament.harmonycdn.net/parlserv-house", quality)
 if addon.getSetting('%s_stream' % channel) == "Apple Quicktime":
  info["FileName"] = "%s%s%s" % ("rtsp://Qts1.ptv.parliament.nz/ptv-", quality, ".sdp")
 tools.addlistitem(int(sys.argv[1]), info, "resources/images/%s.jpg" % channel, 0, count)
コード例 #16
0
def add_item_table(soup, provider, count, title): #Scrape items from a table-style HTML page
 info = tools.defaultinfo()
 info["Studio"] = provider
 link = soup.find('a')
 if link:
  if link.string:
   plot = link.string.strip()
   if plot <> "":
    info["PlotOutline"] = plot
    info["TVShowTitle"] = title
    info.update(seasonepisode(link))
    info["Title"] = tools.itemtitle(info["TVShowTitle"], info["PlotOutline"])
    info["Count"] = count
    href = re.search("%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (base_url("tv3"), tv3_urls["VIDEO1"], tv3_urls["VIDEO2"], tv3_urls["VIDEO3"]), link['href'])
    if href:
     info["FileName"] = "%s?ch=TV3&id=%s&info=%s" % (sys.argv[0], "%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), urllib.quote(str(info)))
    tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 0)
コード例 #17
0
def add_item_search(soup, provider, count): #Scrape items from a table-style HTML page
 baseurl = base_url(provider)
 info = tools.defaultinfo()
 info["Studio"] = provider
 title = soup.find("div", attrs={"class": 'catTitle'})
 if title:
  info["TVShowTitle"] = title.a.string.strip()
  href = re.match("%s/(.*?)/%s/([0-9]+)/%s/([0-9]+)/%s/([0-9]+)/" % (baseurl, tv3_urls["VIDEO1"], tv3_urls["VIDEO2"], tv3_urls["VIDEO3"]), title.a['href'])
  image = soup.find("img")
  if image:
   info.update(tools.imageinfo(image))
  ep = soup.find("div", attrs={"class": 'epTitle'})
  if ep:
   if ep.a:
    info.update(seasonepisode(ep.a))
  date = soup.find("div", attrs={"class": 'epDate'})
#  if date:
#   sys.stderr.write(date.span[1].string.strip())
  info["Title"] = tools.itemtitle(info["TVShowTitle"], info["PlotOutline"])
  info["Count"] = count
  info["FileName"] = "%s?ch=TV3&id=%s&info=%s" % (sys.argv[0], "%s,%s,%s,%s" % (href.group(1), href.group(2), href.group(3), href.group(4)), urllib.quote(str(info)))
  tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 0)
コード例 #18
0
def INDEX():
 channels = dict()
 channels["0"] = "TV3"
 channels["1"] = "TVNZ"
 if addon.getSetting('Ziln_hide') == "false":
  channels["2"] = "Ziln"
 #channels["3"] = "iSKY"
# streamingchannels = dict()
# streamingchannels["0"] = "Shine"
# streamingchannels["1"] = "Parliament"
 count = len(channels) + 1 #+ len(streamingchannels)
 for index in channels:
  info = tools.defaultinfo(1)
  info["Title"] = channels[index]
  info["Thumb"] = os.path.join(addon.getAddonInfo('path'), "resources/images/%s.png" % channels[index])
  info["Count"] = int(index)
  info["FileName"] = "%s?ch=%s" % (sys.argv[0], channels[index])
  tools.addlistitem(int(sys.argv[1]), info, "resources/images/%s.jpg" % channels[index], 1, count)
 if addon.getSetting('Parliament_hide') == "false":
  import parliament
  parliament.RESOLVE("Parliament", count)
 if addon.getSetting('Shine_hide') == "false":
  import shine
  shine.RESOLVE("Shine", count)
コード例 #19
0
def addEpisode(ep):
 #url,liz = getEpisode(ep)
 #xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz,isFolder=False)
 tools.addlistitem(int(sys.argv[1]), getEpisode(ep), FANART_URL, 0)
コード例 #20
0
def RESOLVE(id, info): #Scrape a page for a given OnDemand video and build an RTMP URL from the info in the page, then play the URL
 ids = id.split(",")
 if len(ids) == 4:
  pageUrl = "%s/%s/%s/%s/%s/%s/%s/%s/%s" % (base_url(info["Studio"]), ids[0], tv3_urls["VIDEO1"], ids[1], tv3_urls["VIDEO2"], ids[2], tv3_urls["VIDEO3"], ids[3], tv3_urls["VIDEO4"])
  doc = tools.gethtmlpage(pageUrl)
 else:
  doc = tools.gethtmlpage("id")
 if doc:
  #videoid = re.search('var video ="/\*transfer\*([0-9]+)\*([0-9A-Z]+)";', doc)
  videoid = re.search('var video ="\*(.*?)\*([0-9]+)\*(.*?)";', doc)
  if videoid:
   #videoplayer = re.search('var fo = new FlashObject\("(http://static.mediaworks.co.nz/(.*?).swf)', doc)
   videoplayer = re.search('swfobject.embedSWF\("(http://static.mediaworks.co.nz/(.*?).swf)', doc)
   if videoplayer:
    auth = re.search('random_num = "([0-9]+)";', doc)
    realstudio = 'tv3'
    site = re.search("var pageloc='TV-(FOUR|TV3)-Video(Extras)?-OnDemand-", doc)
    if site:
     if site.group(1) <> 'TV3':
      realstudio = 'c4'
    playlist=list()
    #if addon.getSetting('TV3_showads') == 'true':
     #playlist.append(ad)
    fifteen = re.search('flashvars.fifteenHundred = "yes";', doc)
    seven = re.search('flashvars.sevenHundred = "yes";', doc)
    if fifteen and seven:
     LowQuality = "330K"
     MediumQuality = "700K"
     HighQuality = "1500K"
    elif fifteen:
     LowQuality = "128K"
     MediumQuality = "330K"
     HighQuality = "1500K"
    elif seven:
     LowQuality = "128K"
     MediumQuality = "330K"
     HighQuality = "700K"
    else:
     LowQuality = "128K"
     MediumQuality = "330K"
     HighQuality = "330K"
    #elif re.search('flashvars.highEnd = "true";', doc):
    quality = HighQuality
    quality2 = MediumQuality
    quality3 = LowQuality
    if addon.getSetting('TV3_quality') == "Low":
     quality = LowQuality
     quality3 = HighQuality
    elif addon.getSetting('TV3_quality') == "Medium":
     quality = MediumQuality
     quality2 = HighQuality
    geo = re.search('var geo= "(no|geo)";', doc)
    if (geo.group(1) == 'no'):
     url = '%s%s/%s/%s_%s.%s' % (http(realstudio), videoid.group(1), videoid.group(2), urllib.quote(videoid.group(3)), quality, "mp4")
    else:
     #swfverify = ' swfUrl=%s swfVfy=true' % (videoplayer.group(1))
     #rtmpurl = '%s%s/%s/%s_%s' % (rtmp(info["Studio"]), videoid.group(1), videoid.group(2), urllib.quote(videoid.group(3)), quality)
     url = '%s%s/%s/%s_%s' % (rtmp(realstudio), videoid.group(1), videoid.group(2), urllib.quote(videoid.group(3)), quality)
     if auth:
      swfverify = ' swfUrl=%s?rnd=%s pageUrl=%s swfVfy=true' % (videoplayer.group(1), auth.group(1), pageUrl)
     else:
      swfverify = ' swfUrl=%s pageUrl=%s swfVfy=true' % (videoplayer.group(1), pageUrl)
     url += swfverify
    sys.stderr.write("URL: %s" % (url))
    #sys.stderr.write("Flash Player: %s" % (videoplayer.group(1)))
    playlist.append(url)
    if len(playlist) > 1:
     uri = constructStackURL(playlist)
    elif len(playlist) == 1:
     uri = playlist[0]
    #liz = xbmcgui.ListItem(id, iconImage = info["Icon"], thumbnailImage = info["Thumb"])
    #liz.setInfo( type = "Video", infoLabels = info)
    #liz.setProperty("IsPlayable", "true")
    #liz.setPath(uri)
    #xbmcplugin.setResolvedUrl(handle = int(sys.argv[1]), succeeded = True, listitem = liz)
    info["FileName"] = url
    tools.addlistitem(int(sys.argv[1]), info, tv3_urls["Fanart"], 0, 1, uri)
   else:
    sys.stderr.write("Couldn't get video player URL")
  else:
   sys.stderr.write("Couldn't get video RTMP URL")
 else:
  sys.stderr.write("Couldn't get video webpage")