Ejemplo n.º 1
0
def removeFromPlaylist(list='favorites'):
    movieList = mc.GetActiveWindow().GetList(MOVIES_ID)
    index = movieList.GetFocusedItem()
    items = movieList.GetItems()
    movie = items[index]
    voddlerapi.getAPI().removeFromPlaylist(movie.GetProperty('id'), list)
    movie.SetProperty('is%s' % string.capitalize(list), 'false')
    mc.ShowDialogNotification("%s removed from %s" % (movie.GetLabel(), list))
    updateMovieListItem(movieList, index, movie)
Ejemplo n.º 2
0
def addToPlaylist(list='favorites'):
    movieList = mc.GetActiveWindow().GetList(MOVIES_ID)
    index = movieList.GetFocusedItem()
    items = movieList.GetItems()
    movie = movieList.GetItem(index)
    voddlerapi.getAPI().addToPlaylist(movie.GetProperty('id'), list)
    movie.SetProperty('is%s' % string.capitalize(list), 'true')
    mc.ShowDialogNotification("%s added to %s" % (movie.GetLabel(), list))
    updateMovieListItem(movieList, index, movie)
Ejemplo n.º 3
0
def playMovie(listId=MOVIES_ID):
    movieList = GetActiveWindow().GetList(listId)
    index = movieList.GetFocusedItem()
    movie = movieList.GetItem(index)

    ShowDialogWait()
    try:
        status("Playing movie %s" % movie.GetLabel())
        player = mc.GetApp().GetLocalConfig().GetValue('player')
        url = voddlerapi.getAPI().getMovieURL(movie.GetProperty('id'), player)
        if not url:
            # revert to web-url
            url = movie.GetProperty('url')
        print "Playing %s" % url
        movie.SetPath(url)
    finally:
        hideWaitDialog()
    mc.GetPlayer().PlayWithActionMenu(movie)
Ejemplo n.º 4
0
def populateGenre():
    global pageType
    genres = voddlerapi.getAPI().getGenres(pageType)
    #pprint(data)
    items = mc.ListItems()
    itemList = []
    # dicts are not that easily sorted...
    for value, name in genres.items():
        #pprint(g)
        item = ListItem(ListItem.MEDIA_UNKNOWN)
        item.SetLabel(name)
        item.SetProperty('value', value)
        itemList.append(item)
    # ... so we wait, and then sort
    for item in sorted(itemList, key=_getGenreKey):
        items.append(item)
    genre = mc.GetActiveWindow().GetList(GENRE_ID)
    genre.SetItems(items)
Ejemplo n.º 5
0
def searchPlaylist(window, mainList):
    global currentPage, pageCache, pageSize, maxCount, maxPage
    offset = currentPage * pageSize
    items = ListItems()
    if currentPage in pageCache.keys():
        items = pageCache[currentPage]
    else:
        status("Fetching page %i" % (currentPage+1))
        # TODO: Support sorting?
        maxCount, data = voddlerapi.getAPI().getMoviesOnPlaylist(pageType, 'alphabetical')
        maxPage = (maxCount-1) / pageSize
        if maxPage < 0:
            maxPage = 0
        itemsOnCurrentPage = min(pageSize, maxCount, maxCount - (currentPage*pageSize))
        for index, movie in enumerate(data):
            status("Generating page %i of %i" % (currentPage+1, maxPage+1), index+1, itemsOnCurrentPage)
            item = ListItem(ListItem.MEDIA_VIDEO_FEATURE_FILM)
            movie.showOnListItem(item, offset+index)
            items.append(item)
        pageCache[currentPage] = items
    mainList.SetItems(items)
Ejemplo n.º 6
0
def searchNormal(window, mainList):
    global currentPage, pageCache, pageSize, maxCount, maxPage
    g = getGenre()
    s = getSorting()
    c = getCategory()
    offset = currentPage * pageSize
    items = ListItems()
    if currentPage in pageCache.keys():
        items = pageCache[currentPage]
    else:
        status("Fetching page %i" % (currentPage+1))
        maxCount, data = voddlerapi.getAPI().browse(pageType, c, g, s, offset, pageSize)
        maxPage = (maxCount-1) / pageSize
        if maxPage < 0:
            maxPage = 0
        itemsOnCurrentPage = min(pageSize, maxCount, maxCount - (currentPage*pageSize))
        for index, movie in enumerate(data):
            status("Generating page %i of %i" % (currentPage+1, maxPage+1), index+1, itemsOnCurrentPage)
            item = ListItem(ListItem.MEDIA_VIDEO_FEATURE_FILM)
            movie.showOnListItem(item, offset+index)
            items.append(item)
        pageCache[currentPage] = items
    mainList.SetItems(items)