Exemple #1
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))
Exemple #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))
Exemple #3
0
def addDirectoryItem(title,
                     params,
                     thumbnail=None,
                     folder=True,
                     live=False,
                     info=None):

    li = xbmcgui.ListItem(title)

    if thumbnail:
        li.setThumbnailImage(thumbnail)

    if live:
        li.setProperty("IsLive", "true")

    if not folder:
        if params["mode"] == MODE_VIDEO:
            li.setProperty("IsPlayable", "true")
            # Add context menu item for adding a video to playlist
            plm_script = "special://home/addons/plugin.video.svtplay/resources/lib/PlaylistManager.py"
            plm_action = "add"
            if not thumbnail:
                thumbnail = ""
            li.addContextMenuItems(
                [(localize(30404),
                  "XBMC.RunScript(" + plm_script + ", " + plm_action + ", " +
                  params["url"] + ", " + title + ", " + thumbnail + ")")],
                replaceItems=True)
    if params["mode"] == MODE_PROGRAM:
        # Add context menu item for adding programs as favorites
        fm_script = "special://home/addons/plugin.video.svtplay/resources/lib/FavoritesManager.py"
        fm_action = "add"
        li.addContextMenuItems(
            [(localize(30406), "XBMC.RunScript(" + fm_script + ", " +
              fm_action + ", " + title + ", " + params["url"] + ")")],
            replaceItems=True)

    if info:
        li.setInfo("Video", info)
        if "fanart" in info.keys() and helper.getSetting("showfanart"):
            li.setArt({"fanart": info["fanart"]})

    xbmcplugin.addDirectoryItem(PLUGIN_HANDLE,
                                sys.argv[0] + '?' + urllib.urlencode(params),
                                li, folder)
Exemple #4
0
def createDirItem(article, mode):
  """
  Given an article and a mode; create directory item
  for the article.
  """
  if not helper.getSetting(S_HIDE_SIGN_LANGUAGE) or (article["title"].lower().endswith("teckentolkad") == False and article["title"].lower().find("teckenspråk".decode("utf-8")) == -1):

    params = {}
    params["mode"] = mode
    params["url"] = article["url"]
    folder = False

    if mode == MODE_PROGRAM:
      folder = True
    info = None
    if "info" in article.keys():
      info = article["info"]
    addDirectoryItem(article["title"], params, article["thumbnail"], folder, False, info)
Exemple #5
0
def addDirectoryItem(title, params, thumbnail = None, folder = True, live = False, info = None):

  li = xbmcgui.ListItem(title)

  if thumbnail:
    li.setThumbnailImage(thumbnail)

  if live:
    li.setProperty("IsLive", "true")

  if not folder:
    if params["mode"] == MODE_VIDEO:
      li.setProperty("IsPlayable", "true")
      # Add context menu item for adding a video to playlist
      plm_script = "special://home/addons/plugin.video.svtplay/resources/lib/PlaylistManager.py"
      plm_action = "add"
      if not thumbnail:
        thumbnail = ""
      li.addContextMenuItems(
        [
          (
            localize(30404),
            "XBMC.RunScript("+plm_script+", "+plm_action+", "+params["url"]+", "+title+", "+thumbnail+")"
           )
        ], replaceItems=True)
  if params["mode"] == MODE_PROGRAM:
    # Add context menu item for adding programs as favorites
    fm_script = "special://home/addons/plugin.video.svtplay/resources/lib/FavoritesManager.py"
    fm_action = "add"
    li.addContextMenuItems(
      [
        (
          localize(30406),
          "XBMC.RunScript("+fm_script+", "+fm_action+", "+title+", "+params["url"]+")"
         )
      ], replaceItems=True)

  if info:
    li.setInfo("Video", info)
    if "fanart" in info.keys() and helper.getSetting("showfanart"):
      li.setArt({"fanart": info["fanart"]})

  xbmcplugin.addDirectoryItem(PLUGIN_HANDLE, sys.argv[0] + '?' + urllib.urlencode(params), li, folder)
Exemple #6
0
def createDirItem(article, mode):
    """
  Given an article and a mode; create directory item
  for the article.
  """
    if not helper.getSetting(S_HIDE_SIGN_LANGUAGE) or (
            article["title"].lower().endswith("teckentolkad") == False
            and article["title"].lower().find(
                "teckenspråk".decode("utf-8")) == -1):

        params = {}
        params["mode"] = mode
        params["url"] = article["url"]
        folder = False

        if mode == MODE_PROGRAM:
            folder = True
        info = None
        if "info" in article.keys():
            info = article["info"]
        addDirectoryItem(article["title"], params, article["thumbnail"],
                         folder, False, info)
Exemple #7
0
MODE_PLAYLIST_MANAGER = "playlist-manager"
MODE_FAVORITES = "favorites"

S_DEBUG = "debug"
S_HIDE_SIGN_LANGUAGE = "hidesignlanguage"
S_SHOW_SUBTITLES = "showsubtitles"
S_USE_ALPHA_CATEGORIES = "alpha"

PLUGIN_HANDLE = int(sys.argv[1])

addon = xbmcaddon.Addon("plugin.video.svtplay")
localize = addon.getLocalizedString
xbmcplugin.setContent(PLUGIN_HANDLE, "tvshows")

common.plugin = addon.getAddonInfo('name') + ' ' + addon.getAddonInfo('version')
common.dbg = helper.getSetting(S_DEBUG)


def viewStart():

  addDirectoryItem(localize(30009), { "mode": MODE_POPULAR })
  addDirectoryItem(localize(30003), { "mode": MODE_LATEST })
  addDirectoryItem(localize(30010), { "mode": MODE_LAST_CHANCE })
  addDirectoryItem(localize(30002), { "mode": MODE_LIVE_PROGRAMS })
  addDirectoryItem(localize(30008), { "mode": MODE_CHANNELS })
  addDirectoryItem(localize(30000), { "mode": MODE_A_TO_O })
  addDirectoryItem(localize(30001), { "mode": MODE_CATEGORIES })
  addDirectoryItem(localize(30007), { "mode": MODE_BESTOF_CATEGORIES })
  addDirectoryItem(localize(30006), { "mode": MODE_SEARCH })
  addDirectoryItem(localize(30405), { "mode": MODE_FAVORITES })
  addDirectoryItem(localize(30400), { "mode": MODE_PLAYLIST_MANAGER }, folder=False)
Exemple #8
0
MODE_FAVORITES = "favorites"

S_DEBUG = "debug"
S_HIDE_SIGN_LANGUAGE = "hidesignlanguage"
S_SHOW_SUBTITLES = "showsubtitles"
S_USE_ALPHA_CATEGORIES = "alpha"

PLUGIN_HANDLE = int(sys.argv[1])

addon = xbmcaddon.Addon("plugin.video.svtplay")
localize = addon.getLocalizedString
xbmcplugin.setContent(PLUGIN_HANDLE, "tvshows")

common.plugin = addon.getAddonInfo('name') + ' ' + addon.getAddonInfo(
    'version')
common.dbg = helper.getSetting(S_DEBUG)


def viewStart():

    addDirectoryItem(localize(30009), {"mode": MODE_POPULAR})
    addDirectoryItem(localize(30003), {"mode": MODE_LATEST})
    addDirectoryItem(localize(30010), {"mode": MODE_LAST_CHANCE})
    addDirectoryItem(localize(30002), {"mode": MODE_LIVE_PROGRAMS})
    addDirectoryItem(localize(30008), {"mode": MODE_CHANNELS})
    addDirectoryItem(localize(30000), {"mode": MODE_A_TO_O})
    addDirectoryItem(localize(30001), {"mode": MODE_CATEGORIES})
    addDirectoryItem(localize(30007), {"mode": MODE_BESTOF_CATEGORIES})
    addDirectoryItem(localize(30006), {"mode": MODE_SEARCH})
    addDirectoryItem(localize(30405), {"mode": MODE_FAVORITES})
    addDirectoryItem(localize(30400), {"mode": MODE_PLAYLIST_MANAGER},