예제 #1
0
def __load_from_disk():
  global FAVORITES
  FAVORITES = {}
  if os.path.exists(FILE_PATH) and os.stat(FILE_PATH).st_size != 0:
    with open(FILE_PATH, "r") as file_handle:
        FAVORITES = json.load(file_handle)
  helper.infoMsg("Load from disk: "+str(FAVORITES))
예제 #2
0
def __save_to_disk():
  helper.infoMsg("Save to disk: "+str(FAVORITES))
  directory = os.path.dirname(FILE_PATH)
  if not os.path.exists(directory):
    os.makedirs(directory)
  with open(FILE_PATH, "w") as file_handle:
    file_handle.write(json.dumps(FAVORITES))
예제 #3
0
def __save_to_disk():
    helper.infoMsg("Save to disk: " + str(FAVORITES))
    directory = os.path.dirname(FILE_PATH)
    if not os.path.exists(directory):
        os.makedirs(directory)
    with open(FILE_PATH, "w") as file_handle:
        file_handle.write(json.dumps(FAVORITES))
예제 #4
0
def __load_from_disk():
    global FAVORITES
    FAVORITES = {}
    if os.path.exists(FILE_PATH) and os.stat(FILE_PATH).st_size != 0:
        with open(FILE_PATH, "r") as file_handle:
            FAVORITES = json.load(file_handle)
    helper.infoMsg("Load from disk: " + str(FAVORITES))
예제 #5
0
def getProgramItems(section_name, url=None):
  """
  Returns a list of program items for a show.
  Program items have 'title', 'thumbnail', 'url' and 'info' keys.
  """
  if not url:
    url = "/"
  html = getPage(url + "?sida=2")

  video_list_class = "[^\"']*play_videolist[^\"']*"

  container = common.parseDOM(html, "div", attrs = { "id" : section_name })
  if not container:
    helper.errorMsg("No container found for section "+section_name+"!")
    return None
  container = container[0]

  item_class = "[^\"']*play_vertical-list__item[^\"']*"
  items = common.parseDOM(container, "li", attrs = { "class" : item_class })
  if not items:
    helper.errorMsg("No items found in container \""+section_name+"\"")
    return None
  new_articles = []


  for index, item in enumerate(items):
    live_item = False
    if "play_live-countdown" in item:
      live_item = True
      helper.infoMsg("Skipping live item!")
      continue
    info = {}
    new_article = {}
    title = common.parseDOM(item, "a",
                            attrs = { "class" : "[^\"']*play_vertical-list__header-link[^\"']*" })[0]
    plot = common.parseDOM(item, "p",
                            attrs = { "class" : "[^\"']*play_vertical-list__description-text[^\"']*" })[0]
    new_article["url"] = common.parseDOM(item, "a",
                            attrs = { "class": "[^\"']*play_vertical-list__header-link[^\"']*" },
                            ret = "href")[0]
    thumbnail = common.parseDOM(item,
                                "img",
                                attrs = { "class": "[^\"']*play_vertical-list__image[^\"']*" },
                                ret = "src")[0]
    new_article["thumbnail"] = helper.prepareThumb(thumbnail, baseUrl=BASE_URL)
    duration = common.parseDOM(item, "time", attrs = {}, )[0]
    aired = common.parseDOM(item, "p", attrs = { "class" : "[^\"']*play_vertical-list__meta-info[^\"']*" })
    if aired:
      aired = aired[0].replace("Publicerades ", "")
    else:
      # Some items does not contain this meta data
      aired = ""

    plot = common.replaceHTMLCodes(plot)
    new_article["title"] = title
    info["title"] = title
    info["plot"] = plot
    info["aired"] = helper.convertDate(aired) 
    info["duration"] = helper.convertDuration(duration)
    info["fanart"] = helper.prepareFanart(thumbnail, baseUrl=BASE_URL)
    new_article["info"] = info
    new_articles.append(new_article)

  return new_articles
예제 #6
0
  """
    xbmc.Player().play(__playlist)


def __create_list_item(url, title, thumbnail, urlResolved=False):
    list_item = xbmcgui.ListItem(label=title, thumbnailImage=thumbnail)
    video_url = url
    if not urlResolved:
        # If URL has not been resolved already
        video_url = __get_video_url(url)
    list_item.setProperty("url", video_url)
    return list_item


def __get_video_url(url):
    url = svt.BASE_URL + url + svt.JSON_SUFFIX
    show_obj = helper.resolveShowURL(url)
    if not show_obj["videoUrl"]:
        return ""
    return show_obj["videoUrl"]


# To support XBMC.RunScript
if __name__ == "__main__":
    helper.infoMsg("PLM called as script!")
    if len(sys.argv) < 2:
        helper.infoMsg("No argument given!")
    else:
        if sys.argv[1] == "add" and len(sys.argv) > 4:
            add(sys.argv[2], sys.argv[3], sys.argv[4])
예제 #7
0
    })
  return favorites

def __load_from_disk():
  global FAVORITES
  FAVORITES = {}
  if os.path.exists(FILE_PATH) and os.stat(FILE_PATH).st_size != 0:
    with open(FILE_PATH, "r") as file_handle:
        FAVORITES = json.load(file_handle)
  helper.infoMsg("Load from disk: "+str(FAVORITES))

def __save_to_disk():
  helper.infoMsg("Save to disk: "+str(FAVORITES))
  directory = os.path.dirname(FILE_PATH)
  if not os.path.exists(directory):
    os.makedirs(directory)
  with open(FILE_PATH, "w") as file_handle:
    file_handle.write(json.dumps(FAVORITES))

# To support XBMC.RunScript
if __name__ == "__main__":
  helper.infoMsg("FM called as script!")
  if len(sys.argv) < 2:
    helper.errorMsg("No argument given!")
  else:
    if sys.argv[1] == "add" and len(sys.argv) > 3:
      add(sys.argv[2], sys.argv[3])
    elif sys.argv[1] == "remove" and len(sys.argv) > 2:
      remove(sys.argv[2])
      xbmc.executebuiltin("XBMC.Container.Refresh")
예제 #8
0
  xbmc.Player().play(__playlist)

def __create_list_item(url, title, thumbnail, urlResolved=False):
    list_item = xbmcgui.ListItem(
        label = title,
        thumbnailImage = thumbnail
        )
    video_url = url
    if not urlResolved:
      # If URL has not been resolved already
      video_url = __get_video_url(url)
    list_item.setProperty("url", video_url)
    return list_item


def __get_video_url(url):
  url = svt.BASE_URL + url + svt.JSON_SUFFIX
  show_obj = helper.resolveShowURL(url)
  if not show_obj["videoUrl"]:
    return ""
  return show_obj["videoUrl"]

# To support XBMC.RunScript
if __name__ == "__main__":
  helper.infoMsg("PLM called as script!")
  if len(sys.argv) < 2:
    helper.infoMsg("No argument given!")
  else:
    if sys.argv[1] == "add" and len(sys.argv) > 4:
      add(sys.argv[2], sys.argv[3], sys.argv[4])
예제 #9
0
def __load_from_disk():
    global FAVORITES
    FAVORITES = {}
    if os.path.exists(FILE_PATH) and os.stat(FILE_PATH).st_size != 0:
        with open(FILE_PATH, "r") as file_handle:
            FAVORITES = json.load(file_handle)
    helper.infoMsg("Load from disk: " + str(FAVORITES))


def __save_to_disk():
    helper.infoMsg("Save to disk: " + str(FAVORITES))
    directory = os.path.dirname(FILE_PATH)
    if not os.path.exists(directory):
        os.makedirs(directory)
    with open(FILE_PATH, "w") as file_handle:
        file_handle.write(json.dumps(FAVORITES))


# To support XBMC.RunScript
if __name__ == "__main__":
    helper.infoMsg("FM called as script!")
    if len(sys.argv) < 2:
        helper.errorMsg("No argument given!")
    else:
        if sys.argv[1] == "add" and len(sys.argv) > 3:
            add(sys.argv[2], sys.argv[3])
        elif sys.argv[1] == "remove" and len(sys.argv) > 2:
            remove(sys.argv[2])
            xbmc.executebuiltin("XBMC.Container.Refresh")