Exemple #1
0
 def OnPageClick(self):
     focusedItem = self.GetPagesFocusedItem()
     self.SavePagesFocusedItem()
     self.SaveSectionsFocusedItem()
     url = focusedItem.GetPath()
     mc.ShowDialogWait()
     params = {
         'path': url,
         'name': focusedItem.GetLabel(),
         'image': focusedItem.GetThumbnail(),
         'referer': focusedItem.GetProperty('referer'),
         'folder': focusedItem.GetProperty('folder')
     }
     mc.LogInfo("params for loading play list dict %s" % str(params))
     playDict = self.model.pagePlaylistDict(params)
     mc.HideDialogWait()
     if playDict.has_key("playitems"):
         self.RunPlayerForItemsFromDict(focusedItem, playDict)
     elif playDict.has_key("subfolders"):
         self.OnLoadSubfolders(focusedItem, playDict)
     else:
         if self.GetNavNextPageItem() and self.GetNavNextPageItem().GetPath(
         ) == url:
             # go to next manually to not push window state
             self.OnNext()
         else:
             #we have link to dig into with pushing window state
             self.OnLoadSectionPages(focusedItem, True, True, True)
Exemple #2
0
def StartUp():
    mc.ShowDialogWait()
    if ba.Cache('database' + '{0}', 3600): refresh = False
    else: refresh = True

    if refresh:
        mc.ShowDialogNotification("Loading streams...")
        url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fadaptive.rtl.nl%2Fxl%2FVideoItem%2FIpadXML'&_maxage=3600"
        data = ba.FetchUrl(url, 3600)
        soup = BeautifulSoup(data, convertEntities="xml", smartQuotesTo="xml")

        items = []
        for info in soup.findAll('item'):
            if info.serienaam.string == info.title.string:
                item = {}
                daynr = getDate(info.broadcastdatetime.string.split('T')[0])
                item['time'] = daynr
                item['label'] = info.serienaam.string.encode('utf-8')
                item['thumb'] = str(info.thumbnail.string)
                item['desc'] = str(
                    week[daynr]) + ' - ' + info.samenvattingkort.string.encode(
                        'utf-8')
                item['path'] = str(info.movie.string)
                items.append(item)

        config.Reset('database')
        config.Reset('database')
        config.PushBackValue('database', str(time.time()).split('.')[0])
        config.PushBackValue('database', pickle.dumps(items))
    mc.HideDialogWait()
Exemple #3
0
def handleItem(listItem, fromHome=False):
    global secondaryListItems
    itemType = listItem.GetProperty("itemtype")
    url = listItem.GetPath()

    # Handle search items
    if listItem.GetProperty("search") == "1":
        search = mc.ShowDialogKeyboard(listItem.GetProperty("prompt"), "",
                                       False)
        if search:
            url += "&query=" + urllib.quote(search)
        else:
            return

    # Load screen of items
    if itemType == "Directory":
        mc.ShowDialogWait()

        # load next screen information
        machineIdentifier = listItem.GetProperty("machineidentifier")
        windowInformation = manager.getListItems(machineIdentifier, url)
        viewGroup = windowInformation.titleListItems[0].GetProperty(
            "viewgroup")
        nextWindowID = getWindowID(viewGroup)

        # save the state
        if not fromHome:
            mc.GetActiveWindow().PushState()

        # secondary items
        if viewGroup == "secondary":
            secondaryListItems = windowInformation.childListItems
            if fromHome:
                handleItem(windowInformation.childListItems[0])
            else:
                #clearItems()
                showWindowInformation(window, windowInformation)
        else:
            # start the new window
            window = activateWindow(nextWindowID)
            showWindowInformation(window, windowInformation)

    # Play video
    elif itemType == "Video":
        machineIdentifier = listItem.GetProperty("machineidentifier")
        manager.playVideoUrl(machineIdentifier, url)
        #TEMP DISABLE PLAY WINDOW AND JUST PLAY VIDEO
        #windowInformation = manager.getListItems(machineIdentifier, url)
        #mc.ActivateWindow(PLAY_DIALOG_ID)
        #mc.GetWindow(PLAY_DIALOG_ID).GetList(PLAY_DIALOG_LIST_ID).SetItems(windowInformation.childListItems)

    elif itemType == "Track":
        machineIdentifier = listItem.GetProperty("machineidentifier")
        manager.playMusicUrl(machineIdentifier, url)

    # Unknown item
    else:
        mc.ShowDialogNotification("Unknown itemType: %s" % itemType)

    mc.HideDialogWait()
Exemple #4
0
def InstallApp(URL='', mediaitem=CMediaItem()):
    type = mediaitem.GetType(0)
    attributes = mediaitem.GetType(1)

    if type == 'app':
        response = mc.ShowDialogConfirm("Message", "Install Boxee App?", "No",
                                        "Yes")
        if response == False:
            return

    mc.ShowDialogWait()  #loading text

    installer = CInstaller()
    #    if attributes == 'navi-x':
    result = installer.InstallNaviX(URL, mediaitem)
    #    else:
    #        result = installer.InstallScript(URL, mediaitem)

    if result == 0:
        mc.ShowDialogOk("Installer", "Installation successful.")
        mc.ShowDialogOk("Installer", "Please restart Boxee.")
    elif result == -1:
        mc.ShowDialogOk("Installer", "Installation aborted.")
    elif result == -3:
        mc.ShowDialogOk("Installer", "Invalid ZIP file.")
    else:
        mc.ShowDialogOk("Installer", "Installation failed.")

    mc.HideDialogWait()

    return
Exemple #5
0
 def OnLoadSectionPages(self,
                        listItem,
                        startNewSection=True,
                        pushState=False,
                        pushNavItem=True):
     url = listItem.GetPath()
     mc.LogInfo("url to load: %s" % url)
     mc.ShowDialogWait()
     if listItem.GetProperty("isSearch"):
         pagesDict = self.model.searchPagesDict(url)
     else:
         pagesDict = self.model.pagesDict(url)
     listItems = self.BuildPanelItemsList(pagesDict)
     currentNavItem, nextNavItem = self.BuildCurrentAndNextItemsForLoadedPagesDict(
         listItem, pagesDict)
     if pushState is True:
         self.SaveWindowState()
     if pushState or startNewSection:
         self.StartNavNewSection(listItem.GetLabel(), currentNavItem,
                                 nextNavItem)
     else:
         self.UpdateNavigationContainerForLoadedPages(
             currentNavItem, nextNavItem, pushNavItem)
     self.GetPagesPanel().SetItems(listItems)
     mc.HideDialogWait()
Exemple #6
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 #7
0
def favoriteTeams():
    try:
        mc.ShowDialogWait()
        data = getJson(
            'http://mlb.mlb.com/lookup/json/named.team_all.bam?sport_code=%27mlb%27&active_sw=%27Y%27&all_star_sw=%27N%27'
        )
        data = data.get('team_all').get('queryResults').get('row')
        teamList = mc.ListItems()
        for team in data:
            item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
            item.SetLabel(str(team.get('name_display_full')))
            item.SetThumbnail(
                ('http://mlb.mlb.com/images/logos/200x200/200x200_%s.png' %
                 str(team.get('name_abbrev'))))
            item.SetProperty('team-id', str(team.get('team_id')))
            item.SetProperty('team-abbrev', str(team.get('team_abbrev')))
            teamList.append(item)

        favList = []
        for (
                index,
                team,
        ) in enumerate(teamList):
            if ((team.GetProperty('team-id') in favList)
                    and teamList.SetSelected(index, True)):
                pass

        mc.HideDialogWait()
        return teamList
    except Exception, e:
        raiseError(log='favoriteteams', error=e)
Exemple #8
0
 def LoadSectionsList(self, loadAttempt=1):
     mc.ShowDialogWait()
     sectionsList = self.model.sectionsList()
     if 0 == len(sectionsList) and loadAttempt < 3:
         mc.HideDialogWait()
         self.model = exmodel.exmodel(self.localizer, True)
         sectionsList = self.LoadSectionsList(loadAttempt + 1)
     mc.HideDialogWait()
     return sectionsList
Exemple #9
0
 def OnSearchEverywhere(self):
     query = mc.ShowDialogKeyboard(
         mc.GetLocalizedString(137) + " FS.TO", "", False)
     if 0 != len(query):
         mc.LogInfo("string to search: %s" % query)
         mc.ShowDialogWait()
         pagesDict = self.model.searchAllPagesDict(query)
         self.UpdatePagesPanelWithSearchResults(query, pagesDict)
         mc.HideDialogWait()
def loadSports():
    mc.ShowDialogWait()
    sportsList = mc.GetActiveWindow().GetList(9000)
    sportsItems = mc.ListItems()
    for sport in SPORTS:
        sportItem = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
        sportItem.SetLabel(sport.get('title', 'Unknown'))
        sportItem.SetProperty("id", str(sport.get('id', -1)))
        sportsItems.append(sportItem)
    sportsList.SetItems(sportsItems)
    mc.HideDialogWait()
Exemple #11
0
def search():
    term = mc.ShowDialogKeyboard("Search for:", "", False)
    mc.ShowDialogWait()
    url = "%s%s%s" % ("http://pipes.yahoo.com/pipes/pipe.run?Search=", term,
                      "&_id=acacaff9768ad4f22e06b0644879a6b1&_render=rss")
    quoted = urllib.quote_plus(url)
    apiurl = "http://tinyurl.com/api-create.php?url="
    tinyurl = urllib.urlopen(apiurl + quoted).read()
    mc.GetActiveWindow().GetList(1000).SetContentURL(tinyurl)
    mc.HideDialogWait()
    return tinyurl
Exemple #12
0
def loadFavorites():
    try:
        mc.ShowDialogWait()
        mc.GetActiveWindow().PushState()
        if isLoggedIn():
            response = callService('teams')
            data = json.loads(response)
            data = data.get('teams')
            division = {
                '200': mc.ListItems(),
                '201': mc.ListItems(),
                '202': mc.ListItems(),
                '203': mc.ListItems(),
                '204': mc.ListItems(),
                '205': mc.ListItems()
            }
            for team in data:
                item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
                item.SetLabel(str(team.get('title')))
                item.SetThumbnail(str(team.get('thumb')))
                item.SetProperty('team-id', str(team.get('team-id')))
                item.SetProperty('team-abbrev', str(team.get('team-abbrev')))
                item.SetProperty('team-leauge', str(team.get('team-leauge')))
                item.SetProperty('team-division',
                                 str(team.get('team-division')))
                item.SetProperty('team-fav', str(team.get('team-fav')))
                div = str(team.get('team-division'))
                division[div].append(item)

            for div in division:
                mc.GetActiveWindow().GetList(int(div)).SetItems(division[div])
                list = mc.GetActiveWindow().GetList(int(div))
                for (
                        i,
                        v,
                ) in enumerate(list.GetItems()):
                    if ((v.GetProperty('team-fav') == '1')
                            and list.SetSelected(i, True)):
                        pass

            mc.GetActiveWindow().GetControl(3000).SetVisible(True)
            mc.GetActiveWindow().GetList(200).SetFocusedItem(0)
            mc.GetActiveWindow().GetControl(200).SetFocus()
            mc.GetActiveWindow().GetList(200).SetFocusedItem(0)
        else:
            return raiseError(
                'You must be logged in to access your favorite teams!')
        mc.HideDialogWait()
    except Exception, e:
        mc.GetActiveWindow().PopState()
        return raiseError(
            'An error occured while accessing your favorite team settings. Are you logged in?',
            log='loadfavorites',
            error=e)
Exemple #13
0
def ShowPlay(url):
    mc.ShowDialogWait()
    player = mc.GetPlayer()
    data = GetCached(url, 3600).decode('utf-8')
    playurl = re.compile(
        '<a class="wmv-player-holder" href="http://asx.sbsnet.nl/(.*?)"></a>',
        re.DOTALL + re.IGNORECASE).search(data).group(1)
    list_item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP)
    list_item.SetPath("mms://pssbswm.fplive.net/pssbswm/w/" + str(playurl))
    list_item.SetReportToServer(True)
    list_item.SetAddToHistory(True)
    mc.HideDialogWait()
    player.Play(list_item)
Exemple #14
0
def loginUser():
    username = mc.GetActiveWindow().GetEdit(991).GetText()
    password = mc.GetActiveWindow().GetEdit(992).GetText()
    _user = user.getUser()
    if (username and password):
        mc.ShowDialogWait()
        _user.authenticate(username, password)
        mc.HideDialogWait()
        if _user.isAuthenticated:
            mc.ShowDialogOk("Welcome", "You are logged in as " + username)
            ui.toggleLoginVisibility(False)
        else:
            ui.showErrorMessage("An Error Has Occured")
Exemple #15
0
def updateArchiveSpoiler():
    try:
        mc.ShowDialogWait()
        if isLoggedIn():
            response = callService('showhide')
            if ((response == 'T') and mc.GetApp().GetLocalConfig().SetValue(
                    'hide_scores', 'true')):
                pass
        else:
            mc.GetApp().GetLocalConfig().Reset('hide_scores')
        mc.HideDialogWait()
    except Exception, e:
        mc.GetApp().GetLocalConfig().Reset('hide_scores')
        return raiseError(log='updatearchivespoiler', error=e)
Exemple #16
0
def _handleMenuItem(listItem, fromWindowId):
    url = listItem.GetPath()

    # Handle search items
    if listItem.GetProperty("search") == "1":
        search = mc.ShowDialogKeyboard(listItem.GetProperty("prompt"), "",
                                       False)
        if search:
            url += "&query=" + urllib.quote(search)
        else:
            return

    mc.ShowDialogWait()
    machineIdentifier = listItem.GetProperty("machineidentifier")
    windowInformation = manager.getListItems(machineIdentifier, url)
    viewGroup = windowInformation.titleListItems[0].GetProperty("viewgroup")
    nextWindowID = getWindowID(viewGroup)
    window = mc.GetActiveWindow()

    if fromWindowId != getWindowID('home'):
        if not (listItem.GetProperty('type') == ""
                and listItem.GetProperty('secondary') == ""):
            #Not a menu item with no secondary elements
            mc.GetActiveWindow().PushState()

    if viewGroup == "secondary":
        menuItems = windowInformation.childListItems
        if fromWindowId == getWindowID('home'):
            #Clicked on Movie etc.. from home menu
            #Grab the menu items - and go to the first one
            url = menuItems[0].GetPath()
            windowInformation = manager.getListItems(machineIdentifier, url)
            window = activateWindow(nextWindowID)
            updateMenuItems(window, menuItems)
            updateWindowItems(window, windowInformation)

        else:
            #Only found more menu items, so update them
            updateMenuItems(window, menuItems)

    else:
        #Found a list of items to display
        if fromWindowId == getWindowID('home'):
            #We need a window to update
            window = activateWindow(nextWindowID)
            #This means we have no menu items

        updateWindowItems(window, windowInformation)

    mc.HideDialogWait()
Exemple #17
0
    def onClick(self, controlID):
 
	if controlID == 90:
            if mc.GetPlayer().IsPlayingAudio(): mc.ActivateWindow(12006)
            elif mc.GetPlayer().IsPlayingVideo(): mc.ActivateWindow(12005)

	if controlID == 1001:
            if mlb.isLoggedIn():
                #mc.GetActiveWindow().ClearStateStack()
                mc.ActivateWindow(14003)
            else:
                mc.ShowDialogNotification("You must be logged in to make changes to your settings.", "mlb-icon.png")

	if controlID == 1002:
            #mc.GetActiveWindow().ClearStateStack()
            mc.ActivateWindow(14000)

	if controlID == 120:
            #mc.GetActiveWindow().PushState()

            wait = mc.ShowDialogWait()
            mlb.standings('national')
            mc.GetActiveWindow().GetControl(2000).SetVisible(False)
            mc.GetActiveWindow().GetLabel(3001).SetLabel('National League')
            mc.GetActiveWindow().GetControl(3000).SetVisible(True)
            mc.GetActiveWindow().GetControl(4000).SetFocus()
            mc.GetActiveWindow().GetControl(3002).SetFocus()
            mc.HideDialogWait(wait)

	if controlID == 121:
            #mc.GetActiveWindow().PushState()
            wait = mc.ShowDialogWait()
            mlb.standings('american')
            mc.GetActiveWindow().GetControl(2000).SetVisible(False)
            mc.GetActiveWindow().GetLabel(3001).SetLabel('American League')
            mc.GetActiveWindow().GetControl(3000).SetVisible(True)
            mc.HideDialogWait(wait)
Exemple #18
0
def standings(league):
    try:
        mc.ShowDialogWait()
        if (league == 'national'):
            league = 0
        elif (league == 'american'):
            league = 1
        data = getJson(
            'http://mlb.mlb.com/lookup/json/named.standings_all_league_repeater.bam?sit_code=%27h0%27&league_id=104&league_id=103&season=2010'
        )
        data = data.get('standings_all_league_repeater').get(
            'standings_all')[league]
        stand = data.get('queryResults').get('row')
        east = mc.ListItems()
        west = mc.ListItems()
        central = mc.ListItems()
        for team in stand:
            item = mc.ListItem(mc.ListItem.MEDIA_UNKNOWN)
            item.SetLabel(str(team.get('team_short')))
            item.SetThumbnail(
                ('http://mlb.mlb.com/images/logos/200x200/200x200_%s.png' %
                 str(team.get('team_abbrev'))))
            item.SetProperty('games-back', str(team.get('gb')))
            item.SetProperty('wild-card', str(team.get('wild_card')))
            item.SetProperty('elim-wildcard', str(team.get('elim_wildcard')))
            details = (((
                ((((((((((((('Steak (' + team.get('streak')) + '), Home (') +
                           team.get('home')) + '), Away (') + team.get('away'))
                        + '), Vs Division (') + team.get('vs_division')) +
                      '), Last Ten (') + team.get('last_ten')) +
                    ')[CR]Winning Percentage (') + team.get('pct')) +
                  '%), Wildcard (') + team.get('wild_card')) +
                '), Elimination Wildcard (') + team.get('elim_wildcard')) +
                       ')')
            item.SetDescription(str(details))
            division = str(team.get('division'))
            if (('East' in division) and east.append(item)):
                pass

        mc.GetActiveWindow().GetList(3002).SetItems(west)
        mc.GetActiveWindow().GetList(3003).SetItems(central)
        mc.GetActiveWindow().GetList(3004).SetItems(east)
        mc.HideDialogWait()
    except Exception, e:
        return raiseError(
            message=
            'There was a problem accessing standings. Please try again later.',
            log='league',
            error=e)
Exemple #19
0
def saveArchiveSpoiler(value):
    try:
        mc.ShowDialogWait()
        if isLoggedIn():
            response = callService('showhidesave', {'value': value})
            if ((response == '1') and mc.ShowDialogNotification(
                    'Score spoiler settings saved successfully!',
                    'mlb-icon.png')):
                pass
        else:
            mc.ShowDialogNotification(
                'You must be logged in to modify settings.', 'mlb-icon.png')
        mc.HideDialogWait()
    except Exception, e:
        return raiseError(log='savearchivespoiler', error=e)
Exemple #20
0
 def OnSearchInActiveSection(self):
     if self.GetNavSearchContext():
         query = mc.ShowDialogKeyboard(
             mc.GetLocalizedString(137) + " " +
             mc.GetLocalizedString(1405) + " " + self.GetNavSectionName(),
             "", False)
         if 0 != len(query):
             mc.ShowDialogWait()
             pagesDict = self.model.searchInSectionPagesDict(
                 self.GetNavSearchContext(), query)
             self.UpdatePagesPanelWithSearchResults(query, pagesDict)
             mc.HideDialogWait()
     else:
         mc.LogInfo(
             "No search context present - unable to perform search in active section"
         )
Exemple #21
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 #22
0
def viewImage(mode=0, mediaitem=''):
    mc.ShowDialogWait()

    URL = mediaitem.URL
    ext = getFileExtension(URL)

    mc.HideDialogWait()

    listitem_image = mc.ListItem(mc.ListItem.MEDIA_PICTURE)
    listitem_image.SetContentType("url")
    listitem_image.SetLabel(mediaitem.name)
    listitem_image.SetPath(URL)

    player = mc.Player()
    player.PlayWithActionMenu(listitem_image)

    return 0
Exemple #23
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 #24
0
    def __init__(self):
        mc.ShowDialogWait()
        self.useCoverArt = True
        self.player = mc.GetPlayer()
        self.defaultCoverArt = 'default-cover.png'
        self.xbmcPlaylist = mc.PlayList(mc.PlayList.PLAYLIST_MUSIC)
        self.gs = GrooveAPI(enableDebug=__debugging__,
                            cwd=__cwd__,
                            clientUuid=None,
                            clientVersion=None)
        username = __settings__.GetValue("username")
        password = __settings__.GetValue("password")
        self.gs.startSession(username, password)
        self.gs.setRemoveDuplicates(True)
        self._search = None

        self.start()
        mc.HideDialogWait()
Exemple #25
0
 def OnPageClick(self):
     focusedItem = self.GetPagesFocusedItem()
     self.SavePagesFocusedItem()
     self.SaveSectionsFocusedItem()
     url = focusedItem.GetPath()
     mc.ShowDialogWait()
     playDict = self.model.pagePlaylistDict({"url": url})
     mc.HideDialogWait()
     if playDict.has_key("playitems"):
         self.RunPlayerForItemsFromDict(focusedItem, playDict)
     else:
         if self.GetNavNextPageItem() and self.GetNavNextPageItem().GetPath(
         ) == url:
             # go to next manually to not push window state
             self.OnNext()
         else:
             #we have link to dig into with pushing window state
             self.OnLoadSectionPages(focusedItem, True, True, True)
Exemple #26
0
def saveFavorites():
    try:
        mc.ShowDialogWait()
        favs = []
        for div in range(200, 206):
            items = mc.GetActiveWindow().GetList(div).GetSelected()
            for team in items:
                favs.append(team.GetProperty('team-id'))

        favs = ';'.join(favs)
        response = callService('setfavorites', {'teamids': favs})
        if ((response == '1') and mc.ShowDialogNotification(
                'Your favorite teams have been saved successfully.',
                'mlb-icon.png')):
            pass
        mc.HideDialogWait()
    except Exception, e:
        mc.GetActiveWindow().PopState()
        return raiseError(log='savefavorites', error=e)
Exemple #27
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 #28
0
 def OnLoadSubfolders(self, listItem, playDict):
     subfolders = playDict['subfolders']
     mc.ShowDialogWait()
     pagesDict = {
         'pages': subfolders,
         'url': listItem.GetPath(),
         'paging': ''
     }
     listItems = self.BuildPanelItemsList(pagesDict)
     currentNavItem, nextNavItem = self.BuildCurrentAndNextItemsForLoadedPagesDict(
         listItem, pagesDict)
     #if pushState is True:
     self.SaveWindowState()
     #if pushState or startNewSection:
     self.StartNavNewSection(listItem.GetLabel(), currentNavItem,
                             nextNavItem)
     #else:
     #self.UpdateNavigationContainerForLoadedPages(currentNavItem, nextNavItem, True)
     self.GetPagesPanel().SetItems(listItems)
     mc.HideDialogWait()
Exemple #29
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 #30
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)