示例#1
0
  def test_resolveShowURL(self):
    # Test with a good URL
    show_obj = helper.resolveShowURL("good")
    self.assertIsNotNone(show_obj["videoUrl"])

    show_obj = None

    # Test with a bad URL
    show_obj = helper.resolveShowURL("bad")
    self.assertIsNone(show_obj["videoUrl"])
示例#2
0
def startVideo(url):
  """
  Starts the XBMC player if a valid video URL is
  found for the given page URL.
  """
  if not url.startswith("/"):
    url = "/" + url

  url = svt.BASE_URL + url + svt.JSON_SUFFIX

  show_obj = helper.resolveShowURL(url)
  player = xbmc.Player()
  startTime = time.time()

  if show_obj["videoUrl"]:
    xbmcplugin.setResolvedUrl(PLUGIN_HANDLE, True, xbmcgui.ListItem(path=show_obj["videoUrl"]))

    if show_obj["subtitleUrl"]:
      while not player.isPlaying() and time.time() - startTime < 10:
        time.sleep(1.)

      player.setSubtitles(show_obj["subtitleUrl"])

      if not helper.getSetting(S_SHOW_SUBTITLES):
        player.showSubtitles(False)
  else:
    # No video URL was found
    dialog = xbmcgui.Dialog()
    dialog.ok("SVT Play", localize(30100))
示例#3
0
def startVideo(url):
    """
  Starts the XBMC player if a valid video URL is
  found for the given page URL.
  """
    if not url.startswith("/"):
        url = "/" + url

    url = svt.BASE_URL + url + svt.JSON_SUFFIX

    show_obj = helper.resolveShowURL(url)
    player = xbmc.Player()
    startTime = time.time()

    if show_obj["videoUrl"]:
        xbmcplugin.setResolvedUrl(PLUGIN_HANDLE, True,
                                  xbmcgui.ListItem(path=show_obj["videoUrl"]))

        if show_obj["subtitleUrl"]:
            while not player.isPlaying() and time.time() - startTime < 10:
                time.sleep(1.)

            player.setSubtitles(show_obj["subtitleUrl"])

            if not helper.getSetting(S_SHOW_SUBTITLES):
                player.showSubtitles(False)
    else:
        # No video URL was found
        dialog = xbmcgui.Dialog()
        dialog.ok("SVT Play", localize(30100))