Exemple #1
0
def SetListView(view, passive=False):
    ListView = mc.GetApp().GetLocalConfig().GetValue("listview")
    if ListView == "list":
        view = "list"
    elif ListView == "thumbnails":
        view = "thumbnails"

    if view == "default":
        oldview = 212
        newview = 112
    if view == "list":
        oldview = 212
        newview = 112
    elif view == "thumbnails":
        oldview = 112
        newview = 212
    else:  #list
        oldview = 212
        newview = 112

    if passive == False:
        mc.GetWindow(14000).GetControl(oldview).SetVisible(False)  #Hide List
        mc.GetWindow(14000).GetControl(newview).SetVisible(True)  #Show List

    return newview
Exemple #2
0
def MenuRightSelectItem(itemNumber):
    if itemNumber == 0:  #add item to favorites
        stackitem = mc.GetWindow(14000).GetList(555).GetItem(0)
        URL = stackitem.GetProperty("URL")
        if URL.find(favorites_URL) != -1:
            mc.ShowDialogOk("Error", "Cannot Add From Favorite List.")
            return
        ModifyFavoriteList('add')
        mc.GetWindow(14000).GetList(GetListView()).SetFocus()
    elif itemNumber == 1:  #remove items from favorites
        stackitem = mc.GetWindow(14000).GetList(555).GetItem(0)
        URL = stackitem.GetProperty("URL")
        if URL.find(favorites_URL) == -1:
            mc.ShowDialogOk("Error", "Please Select Favorite List First.")
            return
        ModifyFavoriteList('remove')

        userkey = mc.GetApp().GetLocalConfig().GetValue("userkey")
        arguments = "?user="******"&request=get&type=.plx"
        ParsePlaylist(URL=favorites_URL + arguments)

        mc.GetWindow(14000).GetList(GetListView()).SetFocus()
    elif itemNumber == 2:  #about Navi-X
        mc.GetWindow(14000).PushState()
        OpenTextFile(URL='readme.txt')
Exemple #3
0
def getFeaturedMixes(count):
    mc.ShowDialogWait()
    featured_url = "http://8tracks.com/mixes.json?api_key=a07ee2f7cc1577f749ed10d2c796fc52515243cc&api_version=2&per_page=%s&page=1" % count
    fd = urllib.urlopen(featured_url)
    mix_sets = simplejson.loads(fd.read())
    listItems = mc.ListItems()
    for mix in mix_sets["mixes"]:
        item = mc.ListItem(mc.ListItem.MEDIA_AUDIO_OTHER)
        item.SetArtist(str(mix["user"]["login"]))
        year = mix['first_published_at'][1:4]
        month = mix['first_published_at'][6:7]
        day=mix['first_published_at'][9:10]
        item.SetDate(int(year), int(month), int(day))
        name = mix["name"].replace(u'\xbd', '')
        item.SetLabel(str(name))
        item.SetThumbnail(str(mix['cover_urls']['original']))
        item.SetIcon(str(mix['cover_urls']['sq100']))
        
        # get the real track url, so default actions like play would work
        # this should not be here!
        trackD = urllib.urlopen("http://8tracks.com/sets/460486803/play.json?mix_id=%s&api_key=a07ee2f7cc1577f749ed10d2c796fc52515243cc&api_version=2" % mix["id"])
        trackInformation = simplejson.loads(trackD.read())
        item.SetPath(str(trackInformation['set']['track']['url']))
        item.SetProperty("id", str(mix['id']))
        listItems.append(item)
    mc.GetWindow(14000).GetList(201).SetItems(listItems)
    mc.GetWindow(14000).GetList(201).Refresh()
    mc.GetWindow(14000).GetList(201).SetFocusedItem(0)
    mc.HideDialogWait()
Exemple #4
0
def _handlePhotoItem(listItem):
    list = manager.getPhotoList(listItem)
    if list != None:
        mc.ActivateWindow(PHOTO_DIALOG_ID)
        mc.GetWindow(PHOTO_DIALOG_ID).GetList(PHOTO_DIALOG_LIST_ID).SetItems(
            list)
        mc.GetWindow(PHOTO_DIALOG_ID).GetList(
            PHOTO_DIALOG_LIST_ID).SetFocusedItem(util.getIndex(listItem, list))
    else:
        mc.ShowDialogNotification("Unable to display picture")
Exemple #5
0
def init():
    """ Initializes the TORRENT_LIST and WINDOW variables
    """
    global WINDOW, TORRENT_LIST, client_ui, connection
    if not WINDOW:
        WINDOW = mc.GetWindow(14002)
    if not TORRENT_LIST:
        TORRENT_LIST = WINDOW.GetList(100)
Exemple #6
0
def PushDir():
	app = mc.GetApp()
	params = mc.Parameters()
	params["noreload"] = "1"
	app.ActivateWindow(targetwindow, params)
	list = mc.GetWindow(targetwindow).GetList(targetcontrol)
	list.SetItems(dir)
	mc.HideDialogWait()
Exemple #7
0
    def process(self):
        mc.ActivateWindow(self.dialogId)
        mc.GetWindow(self.dialogId).GetImage(self.imageId).SetTexture(
            self.imageArr[self.position])
        self.position = self.position + 1
        if (self.position == len(self.imageArr)):
            self.position = 0

        time.sleep(self.duration)
        xbmc.executebuiltin("Dialog.Close(" + str(self.dialogId) + ")")
Exemple #8
0
def EmptyEpisode():
    targetcontrol = 52
    targetwindow = 14000
    list = mc.GetWindow(targetwindow).GetList(targetcontrol)
    list_items = mc.ListItems()
    list_item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
    list_item.SetLabel('')
    list_item.SetPath('')
    list_items.append(list_item)
    list.SetItems(list_items)
Exemple #9
0
def _handleVideoItem(listItem):
    mc.ShowDialogWait()
    machineIdentifier = listItem.GetProperty("machineidentifier")
    #Create a new list item with the additional video data
    server = manager.getServer(listItem.GetProperty("machineIdentifier"))

    #Get additional meta data for item to play
    li = server.getVideoItem(listItem)
    listItems = mc.ListItems()
    listItems.append(li)

    #Load any subtitles
    subItems = server.getSubtitles(li.GetPath())

    #Show play window
    mc.ActivateWindow(PLAY_DIALOG_ID)
    mc.GetWindow(PLAY_DIALOG_ID).GetList(PLAY_DIALOG_LIST_ID).SetItems(
        listItems)
    mc.GetWindow(PLAY_DIALOG_ID).GetList(310).SetItems(subItems)
    mc.HideDialogWait()
Exemple #10
0
def MenuLeftSelectItem(itemNumber):
    if itemNumber == 0:
        SelectItem(iURL=home_URL)
        mc.GetWindow(14000).GetList(GetListView()).SetFocus()
    elif itemNumber == 1:
        userkey = mc.GetApp().GetLocalConfig().GetValue("userkey")
        arguments = "?user="******"&request=get&type=.plx"
        SelectItem(iURL=favorites_URL + arguments)
    elif itemNumber == 2:
        ListView = mc.GetApp().GetLocalConfig().GetValue("listview")
        if ListView == "default":
            mc.GetApp().GetLocalConfig().SetValue("listview", "thumbnails")
        elif ListView == "thumbnails":
            mc.GetApp().GetLocalConfig().SetValue("listview", "list")
        else:
            mc.GetApp().GetLocalConfig().SetValue("listview", "default")
        Init()
        ParsePlaylist(reload=False)
        mc.GetWindow(14000).GetList(122).SetFocus()
        mc.GetWindow(14000).GetList(122).SetFocusedItem(itemNumber)
    elif itemNumber == 3:
        if nxserver.is_user_logged_in() == True:
            response = mc.ShowDialogConfirm("Message", "Sign out?", "No",
                                            "Yes")
            if response:
                nxserver.logout()
                mc.ShowDialogOk("Sign out", "Sign out Successful.")
                Init()
        else:
            result = nxserver.login()
            if result == 0:
                mc.ShowDialogOk("Sign in", "Sign in Successful.")
                Init()
            elif result == -1:
                mc.ShowDialogOk("Sign in", "Sign in Failed.")
        mc.GetWindow(14000).GetList(GetListView()).SetFocus()
    elif itemNumber == 4:
        mc.CloseWindow()
    pass
Exemple #11
0
def populateTodayScreen():
    try:
        w = mc.GetWindow(14000)
        w.GetList(120).SetFocusedItem(0)
        w.GetControl(120).SetFocus()
        w.GetList(120).SetFocusedItem(0)
        dt = getMonth(0)
        w.GetLabel(101).SetLabel(dt.strftime('%B %d, %Y'))
        games = getGames()
        if (games and w.GetList(120).SetItems(games)):
            pass
    except Exception, e:
        if (('AppException' in str(e)) and info('populateTodayScreen', e)):
            return False
Exemple #12
0
def loadContent():
    window = mc.GetWindow(getWindowID("home"))
    myLibrary = window.GetList(110)
    sharedLibraries = window.GetList(210)
    myChannels = window.GetList(310)
    myRecentlyAdded = window.GetList(410)
    myOnDeck = window.GetList(510)

    myLibrary.SetItems(manager.getMyLibrary())
    sharedLibraries.SetItems(manager.getSharedLibraries())
    myChannels.SetItems(manager.getMyChannels())
    myRecentlyAdded.SetItems(manager.getMyRecentlyAdded())
    myOnDeck.SetItems(manager.getMyOnDeck())

    window.GetControl(1000).SetFocus()
Exemple #13
0
def updateConnectionResult():
    msg = manager.getNextConnectionError()
    mc.GetWindow(CONNECT_DIALOG_ID).GetLabel(300).SetVisible(True)
    mc.GetWindow(CONNECT_DIALOG_ID).GetLabel(300).SetLabel(msg)
    mc.GetWindow(CONNECT_DIALOG_ID).GetButton(402).SetVisible(True)

    if len(manager.connectionErrors) > 1:
        mc.GetWindow(CONNECT_DIALOG_ID).GetControl(401).SetVisible(True)
        mc.GetWindow(CONNECT_DIALOG_ID).GetButton(401).SetFocus()
    else:
        mc.GetWindow(CONNECT_DIALOG_ID).GetButton(402).SetFocus()
Exemple #14
0
def categories():
    mc.ShowDialogWait()

    list = mc.ListItems()

    categories = playkanalerna.getCategories()
    for category in categories:
        item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
        item.SetLabel(str(category['name'].encode('utf-8', 'ignore')))
        item.SetPath(str(category['url'].encode('utf-8', 'ignore')))
        list.append(item)

    mc.ActivateWindow(14000)
    window = mc.GetWindow(14000)
    window.GetList(51).SetItems(list)

    mc.HideDialogWait()
Exemple #15
0
def programs(url, category):
    mc.ShowDialogWait()

    list = mc.ListItems()

    programs = playkanalerna.getPrograms(url)
    for program in programs:
        item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
        item.SetLabel(str(program['name'].encode('utf-8', 'ignore')))
        item.SetPath(str(program['url'].encode('utf-8', 'ignore')))
        list.append(item)

    mc.ActivateWindow(14001)
    window = mc.GetWindow(14001)
    window.GetList(51).SetItems(list)
    window.GetLabel(30).SetLabel(category)

    mc.HideDialogWait()
Exemple #16
0
def ShowEpisode(urlshow):
    mc.ShowDialogWait()
    targetcontrol = 52
    targetwindow = 14000

    urlbase = re.compile('http://(.*?).nl').findall(urlshow)[0]
    data = GetCached(urlshow, 3600).decode('utf-8')
    soup = BeautifulSoup(data)
    try:
        pages = soup.findAll('div', {'class': 'paginator'})[0]
        pages = pages.findAll('span')
        pages = len(pages) - 1
    except:
        pages = 1

    list = mc.GetWindow(targetwindow).GetList(targetcontrol)
    list_items = mc.ListItems()

    for i in range(1, pages + 1):
        url = str(urlshow) + '/page=' + str(i)
        data = GetCached(url, 3600).decode('utf-8')
        soup = BeautifulSoup(data)

        maindiv = soup.findAll('div', {'class': 'mo-c double'})[0]
        showdiv = maindiv.findAll('div', {'class': 'wrapper'})[0]
        thumb = showdiv.findAll('div', {'class': 'thumb'})
        airtime = showdiv.findAll('div', {'class': 'airtime'})

        count = len(thumb)

        for i in range(0, count):
            link = 'http://' + urlbase + '.nl' + thumb[i].a['href']
            thumbnail = 'http://' + urlbase + '.nl' + thumb[i].img['src']
            date = airtime[i].a.span.renderContents()
            list_item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
            list_item.SetThumbnail(str(thumbnail))
            list_item.SetLabel(str(date))
            list_item.SetPath(str(link))
            list_items.append(list_item)

    mc.HideDialogWait()
    list.SetItems(list_items)
    list.control.SetFocus(0)
Exemple #17
0
def ModifyFavoriteList(command='none'):
    list = mc.GetWindow(14000).GetList(GetListView())
    itemNumber = list.GetFocusedItem()

    if itemNumber < 0:
        return

    if command == 'add':
        listitem = list.GetItem(itemNumber)
        mediaitem = CMediaItem()
        mediaitem.type = listitem.GetProperty("media_type")
        mediaitem.name = listitem.GetLabel()
        mediaitem.thumb = listitem.GetProperty("thumb")
        mediaitem.URL = listitem.GetProperty("url")
        mediaitem.processor = listitem.GetProperty("processor")

        postdata = "type=" + mediaitem.type + "\n"
        postdata = postdata + "name=" + mediaitem.name + "\n"
        postdata = postdata + "thumb=" + mediaitem.thumb + "\n"
        postdata = postdata + "URL=" + mediaitem.URL + "\n"
        postdata = postdata + "processor=" + mediaitem.processor + "\n"

        try:
            userkey = mc.GetApp().GetLocalConfig().GetValue("userkey")
            arguments = "?user="******"&request=add"
            req = urllib2.Request(favorites_URL + arguments, postdata)
            f = urllib2.urlopen(req)
            data = f.read()
            f.close()
        except IOError:
            pass
    elif command == 'remove':
        try:
            userkey = mc.GetApp().GetLocalConfig().GetValue("userkey")
            arguments = "?user="******"&request=remove&index=" + str(
                itemNumber)
            req = urllib2.Request(favorites_URL + arguments)
            f = urllib2.urlopen(req)
            data = f.read()
            f.close()
        except IOError:
            pass
Exemple #18
0
def ShowDay(day):
    mc.ShowDialogWait()
    targetcontrol = 51
    targetwindow = 14000

    database = pickle.loads(config.GetValue('database{1}'))
    selection = list(
        filter_data(database, lambda k, v: k == 'time' and v == day))

    listref = mc.GetWindow(targetwindow).GetList(targetcontrol)
    list_items = mc.ListItems()

    for item in selection:
        list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_OTHER)
        list_item.SetLabel(item['label'])
        list_item.SetThumbnail(item['thumb'])
        list_item.SetDescription(item['desc'])
        list_item.SetPath(item['path'])
        list_items.append(list_item)

    mc.HideDialogWait()
    listref.SetItems(list_items)
Exemple #19
0
def episodes(url, show):
    mc.ShowDialogWait()

    list = mc.ListItems()

    episodes = playkanalerna.getEpisodes(url)
    for episode in episodes:
        item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP)
        item.SetLabel(str(episode['name'].encode('utf-8', 'ignore')))
        item.SetPath(
            'flash://%s/src=%s&bx-jsactions=%s' %
            ("video", quote(str(episode['url'].encode('utf-8', 'ignore'))),
             quote('http://boxee.jakob.edge.vinnovera.se/tv3play.js')))
        if episode['image'] is not None:
            item.SetThumbnail(str(episode['image'].encode('utf-8', 'ignore')))
        list.append(item)

    mc.ActivateWindow(14002)
    window = mc.GetWindow(14002)
    window.GetList(51).SetItems(list)
    window.GetLabel(30).SetLabel(show)

    mc.HideDialogWait()
Exemple #20
0
def ShowNet(net):
    mc.ShowDialogWait()
    targetcontrol = 51
    targetwindow = 14000

    if net == 1:
        urlbase = SBS6_BASE
        url = SBS6_HOME
        zender = 'sbs'
    if net == 2:
        urlbase = NET5_BASE
        url = NET5_HOME
        zender = 'net5'
    if net == 3:
        urlbase = VERONICA_BASE
        url = VERONICA_HOME
        zender = 'veronica'

    data = GetCached(url, 3600).decode('utf-8')
    soup = BeautifulSoup(data)
    maindiv = soup.findAll('div', {'class': 'mo-a alphabetical'})[0]
    showdiv = maindiv.findAll('div', {'class': 'wrapper'})[0]

    list = mc.GetWindow(targetwindow).GetList(targetcontrol)
    list_items = mc.ListItems()

    for info in showdiv.findAll('a'):
        title = info.renderContents()
        link = urlbase + str(info['href'])
        list_item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
        list_item.SetLabel(str(title))
        list_item.SetProperty("zender", str(zender))
        list_item.SetPath(str(link))
        list_items.append(list_item)

    list.SetItems(list_items)
    mc.HideDialogWait()
Exemple #21
0
def set_watched(command):
	list = mc.GetWindow(10483).GetList(52)
	item = list.GetItem(1)

	series = mc.GetInfoString("Container(52).ListItem.TVShowTitle")
	db_path = xbmc.translatePath('special://profile/Database/')
	itemList = list.GetItems()
	seasons = []
	episodes_count = 0
	for item in itemList:
		season = item.GetSeason()
		if(season != -1):
			seasons.append(season)
			episodes_count = episodes_count + 1

	seasons = dict.fromkeys(seasons)
	seasons = seasons.keys()

	use_season = -1
	display_name = series
	season_string = ""
	if(len(seasons) == 1):
		display_name = "Season %s" % (seasons[0])
		season_string = " %s" % display_name
		use_season = seasons[0]

	dialog = xbmcgui.Dialog()
    	if dialog.yesno("Watched", "Do you want to mark all episodes of %s%s as %s?" % (series, season_string, command)):
        	progress = xbmcgui.DialogProgress()
        	progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command))

		current_count = 0
		info_count = 0

		sql = ".timeout 100000;\n"
				
		for item in itemList:
			episode = item.GetEpisode()
			boxeeid = mc.GetInfoString("Container(52).ListItem("+str(info_count)+").Property(boxeeid)")
			info_count = info_count + 1
			print boxeeid
			if(episode != -1):
				current_count = current_count+1
				percent = int( ( episodes_count / current_count ) * 100)
				message = "Episode " + str(current_count) + " out of " + str(episodes_count)
				progress.update( percent, "", message, "" )
				path = item.GetPath()

				# First make sure we don't get double values in the DB, so remove any old ones				
				sql = sql + "DELETE FROM watched WHERE strPath = \""+path+"\" or (strBoxeeId != \"\" AND strBoxeeId = \""+boxeeid+"\");\n"
				if command == "watched":
					sql = sql + "INSERT INTO watched VALUES(null, \""+path+"\", \""+boxeeid+"\", 1, 0, -1.0);\n"

		file_put_contents("/tmp/sqlinject", sql)
		os.system('cat /tmp/sqlinject | /data/hack/bin/sqlite3 ' + db_path + 'boxee_user_catalog.db')

		xbmc.executebuiltin("Container.Update")
		xbmc.executebuiltin("Container.Refresh")
		xbmc.executebuiltin("Window.Refresh")
		progress.close()

		xbmc.executebuiltin("XBMC.ReplaceWindow(10483)")

#        	progress = xbmcgui.DialogProgress()
#        	progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command))
#
#		for x in range(0, 10):
#			time.sleep(1);
#			xbmc.executebuiltin("Container.Update")
#			xbmc.executebuiltin("Container.Refresh")
#			xbmc.executebuiltin("Window.Refresh")
#
#		progress.close()
#
#		xbmc.executebuiltin("XBMC.ReplaceWindow(10483)")

		xbmc.executebuiltin("Notification(,%s marked as %s...,2000)" % (display_name, command))
Exemple #22
0
    'dialog-search-options': 15150,
    'dialog-text': 15160,
    'dialog-subtitle': 15170,
    'dialog-settings': 15190,
    'dialog-options': 15200,
    'dialog-image': 15210,
}
WINDOWS_STACK = []

sys.path.append(os.path.join(ROOT, 'libs'))
sys.path.append(os.path.join(ROOT, 'external'))

import mc
import xbmc
import re

# Init App
if (__name__ == "__main__"):
    mc.ActivateWindow(15000)
    mc.ActivateWindow(15110)
    mc.ActivateWindow(15100)

    import navi

    if len(mc.GetWindow(15000).GetList(60).GetItems()) < 1:
        app = navi.Navi_APP()
    else:
        app.api.download.active = False
        app.gui.HideDialog('dialog-wait')
    app.gui.HideDialog('dialog-splash')
	def GetFineArtImage(self):
		return mc.GetWindow(self.WINDOW_ID).GetImage(self.FINEART_IMAGE_ID)
	def GetActionsList(self):
		return mc.GetWindow(self.WINDOW_ID).GetList(self.ACTIONS_LIST_ID)
	def GetDialogTitleLabel(self):
		return mc.GetWindow(self.WINDOW_ID).GetLabel(self.DIALOG_LABEL_ID)
	def GetPlaylistList(self):
		return mc.GetWindow(self.WINDOW_ID).GetList(self.PLAYLIST_LIST_ID)
	def OnLoadPlaylistPlotDialog(self):
		items = mc.ListItems()
		items.append(self.GetPlaylistList().GetItem(self.GetPlaylistList().GetFocusedItem()))
		mc.GetWindow(self.PLOT_WINDOW_ID).GetList(111).SetItems(items)
		mc.GetWindow(self.PLOT_WINDOW_ID).GetList(111).SetFocusedItem(0)
Exemple #28
0
import time, threading, operator
import mc

CONFIG = mc.GetApp().GetLocalConfig()
WINDOW = mc.GetWindow(14002)
TORRENT_LIST = WINDOW.GetList(100)
STATUS = WINDOW.GetLabel(105)
REFRESH_EVERY = 10  # every 20 seconds


def timer_update(ui):
    """ Function accessible from the threading.Timer class.
    """
    ui.update_list()


def start_status_update(ui):
    ev = threading.Event()
    thread = threading.Thread(target=status_update, args=(ui, ev))
    thread.start()


def status_update(ui, ev):
    """ Updates the status bar (including count-down of next refresh)
    """
    while True:
        t = time.time()
        diff = ui.last_update + REFRESH_EVERY - t
        if diff < 0:
            diff = 0
        WINDOW.GetLabel(111).SetLabel(
Exemple #29
0
def get_list(listNum, special):
    try:
        lst = mc.GetWindow(get_window_id(special)).GetList(listNum)
    except:
        lst = ""
    return lst
Exemple #30
0
def get_control(controlNum, special):
    try:
        control = mc.GetWindow(get_window_id(special)).GetControl(controlNum)
    except:
        control = ""
    return control