示例#1
0
 def ListLatest(self):
     self.log(u"", xbmc.LOGDEBUG)
     
     listItems = []
     
     try:
         today = date.today() 
         newLabel = u"Today"
         newListItem = xbmcgui.ListItem( label=newLabel )
         url = self.GetURLStart() + u'&date=' + today.strftime(u"%d.%m.%y")
         listItems.append( (url,newListItem,True) )
         
             # Yesterday
         newLabel = u"Yesterday"
         newListItem = xbmcgui.ListItem( label=newLabel )
         url = self.GetURLStart() + u'&date=' + (today - timedelta(1)).strftime(u"%d.%m.%y")
         listItems.append( (url,newListItem,True) )
         
         # Weekday
         newLabel = (today - timedelta(2)).strftime(u"%A")
         newListItem = xbmcgui.ListItem( label=newLabel )
         url = self.GetURLStart() + u'&date=' + (today - timedelta(2)).strftime(u"%d.%m.%y")
         listItems.append( (url,newListItem,True) )
         
         # Weekday
         newLabel = (today - timedelta(3)).strftime(u"%A")
         newListItem = xbmcgui.ListItem( label=newLabel )
         url = self.GetURLStart() + u'&date=' + (today - timedelta(3)).strftime(u"%d.%m.%y")
         listItems.append( (url,newListItem,True) )
 
         currentDate = today - timedelta(4)
         #TODO Get minus 35 dynamically
         sentinelDate = today - timedelta(36)
         while currentDate > sentinelDate:
             newLabel = currentDate.strftime(u"%A, %d %B %Y")
             newListItem = xbmcgui.ListItem( label=newLabel )
             url = self.GetURLStart() + u'&date=' + currentDate.strftime(u"%d.%m.%y")
             listItems.append( (url,newListItem,True) )
 
             currentDate = currentDate - timedelta(1) 
     
         xbmcplugin.addDirectoryItems( handle=self.pluginHandle, items=listItems )
         xbmcplugin.endOfDirectory( handle=self.pluginHandle, succeeded=True )
         
         return True
     except (Exception) as exception:
         if not isinstance(exception, LoggingException):
             exception = LoggingException.fromException(exception)
         
         if html is not None:
             msg = u"html:\n\n%s\n\n" % html
             exception.addLogMessage(msg)
             
         # "Error creating calendar list"
         message = self.language(30064)
         details = utils.valueIfDefined(minDateString, u'minDateString') + u", "
         details = details + utils.valueIfDefined(maxDateString, u'maxDateString') + u", "
         
         if utils.variableDefined( currentDate ):
             details = details + u"currentDate: " + unicode(currentDate) + u", "
         else:
             details = details + u"currentDate: Not defined"
             
         details = details + utils.valueIfDefined(url, u'url')
         
         exception.addLogMessage(logMessage = message + u"\n" + details)
         # "Error creating calendar list"
         exception.process(message, "", self.logLevel(xbmc.LOGERROR))
         return False
示例#2
0
    def ListCalendar(self):
        self.log(u"", xbmc.LOGDEBUG)
        listItems = []

        try:
            html = None
            html = self.httpManager.GetWebPage(rootMenuUrl, 300)
            minDateString = re.search(
                u"minDate: '([0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9])'",
                html).group(1)
            maxDateString = re.search(
                u"maxDate: '([0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9])'",
                html).group(1)

            minDate = date.fromtimestamp(
                mktime(strptime(minDateString, u"%m/%d/%Y")))
            today = date.fromtimestamp(
                mktime(strptime(maxDateString, u"%m/%d/%Y")))

            # Today
            newLabel = u"Today"
            newListItem = xbmcgui.ListItem(label=newLabel)
            url = self.GetURLStart() + u'&date=' + maxDateString
            listItems.append((url, newListItem, True))

            # Yesterday
            newLabel = u"Yesterday"
            newListItem = xbmcgui.ListItem(label=newLabel)
            url = self.GetURLStart() + u'&date=' + (
                today - timedelta(1)).strftime(u"%m/%d/%Y")
            listItems.append((url, newListItem, True))

            # Weekday
            newLabel = (today - timedelta(2)).strftime(u"%A")
            newListItem = xbmcgui.ListItem(label=newLabel)
            url = self.GetURLStart() + u'&date=' + (
                today - timedelta(2)).strftime(u"%m/%d/%Y")
            listItems.append((url, newListItem, True))

            # Weekday
            newLabel = (today - timedelta(3)).strftime(u"%A")
            newListItem = xbmcgui.ListItem(label=newLabel)
            url = self.GetURLStart() + u'&date=' + (
                today - timedelta(3)).strftime(u"%m/%d/%Y")
            listItems.append((url, newListItem, True))

            currentDate = today - timedelta(4)
            sentinelDate = minDate - timedelta(1)
            while currentDate > sentinelDate:
                newLabel = currentDate.strftime(u"%A, %d %B %Y")
                newListItem = xbmcgui.ListItem(label=newLabel)
                url = self.GetURLStart() + u'&date=' + currentDate.strftime(
                    u"%m/%d/%Y")
                listItems.append((url, newListItem, True))

                currentDate = currentDate - timedelta(1)

            xbmcplugin.addDirectoryItems(handle=self.pluginHandle,
                                         items=listItems)
            xbmcplugin.endOfDirectory(handle=self.pluginHandle, succeeded=True)

            return True
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            if html is not None:
                msg = u"html:\n\n%s\n\n" % html
                exception.addLogMessage(msg)

            # "Error creating calendar list"
            message = self.language(30064)
            details = utils.valueIfDefined(minDateString,
                                           u'minDateString') + u", "
            details = details + utils.valueIfDefined(maxDateString,
                                                     u'maxDateString') + u", "

            if utils.variableDefined(currentDate):
                details = details + u"currentDate: " + unicode(
                    currentDate) + u", "
            else:
                details = details + u"currentDate: Not defined"

            details = details + utils.valueIfDefined(url, u'url')

            exception.addLogMessage(logMessage=message + u"\n" + details)
            # "Error creating calendar list"
            exception.process(message, u"", self.logLevel(xbmc.LOGERROR))
            return False
示例#3
0
    def ListCalendar(self):
        self.log(u"", xbmc.LOGDEBUG)
        listItems = []

        try:
            html = None
            html = self.httpManager.GetWebPage(rootMenuUrl, 300)
            minDateString=re.search( u"minDate: '([0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9])'", html).group(1)
            maxDateString=re.search( u"maxDate: '([0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9])'", html).group(1)
    
            minDate = date.fromtimestamp(mktime(strptime(minDateString, u"%m/%d/%Y")))
            today = date.fromtimestamp(mktime(strptime(maxDateString, u"%m/%d/%Y")))
        
            # Today
            newLabel = u"Today"
            newListItem = xbmcgui.ListItem( label=newLabel )
            url = self.GetURLStart() + u'&date=' + maxDateString
            listItems.append( (url,newListItem,True) )
        
            # Yesterday
            newLabel = u"Yesterday"
            newListItem = xbmcgui.ListItem( label=newLabel )
            url = self.GetURLStart() + u'&date=' + (today - timedelta(1)).strftime(u"%m/%d/%Y")
            listItems.append( (url,newListItem,True) )
        
            # Weekday
            newLabel = (today - timedelta(2)).strftime(u"%A")
            newListItem = xbmcgui.ListItem( label=newLabel )
            url = self.GetURLStart() + u'&date=' + (today - timedelta(2)).strftime(u"%m/%d/%Y")
            listItems.append( (url,newListItem,True) )
        
            # Weekday
            newLabel = (today - timedelta(3)).strftime(u"%A")
            newListItem = xbmcgui.ListItem( label=newLabel )
            url = self.GetURLStart() + u'&date=' + (today - timedelta(3)).strftime(u"%m/%d/%Y")
            listItems.append( (url,newListItem,True) )
        
            currentDate = today - timedelta(4)
            sentinelDate = minDate - timedelta(1)
            while currentDate > sentinelDate:
                newLabel = currentDate.strftime(u"%A, %d %B %Y")
                newListItem = xbmcgui.ListItem( label=newLabel )
                url = self.GetURLStart() + u'&date=' + currentDate.strftime(u"%m/%d/%Y")
                listItems.append( (url,newListItem,True) )
    
                currentDate = currentDate - timedelta(1) 
        
            xbmcplugin.addDirectoryItems( handle=self.pluginHandle, items=listItems )
            xbmcplugin.endOfDirectory( handle=self.pluginHandle, succeeded=True )
            
            return True
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)
            
            if html is not None:
                msg = u"html:\n\n%s\n\n" % html
                exception.addLogMessage(msg)
                
            # "Error creating calendar list"
            message = self.language(30064)
            details = utils.valueIfDefined(minDateString, u'minDateString') + u", "
            details = details + utils.valueIfDefined(maxDateString, u'maxDateString') + u", "
            
            if utils.variableDefined( currentDate ):
                details = details + u"currentDate: " + unicode(currentDate) + u", "
            else:
                details = details + u"currentDate: Not defined"
                
            details = details + utils.valueIfDefined(url, u'url')
            
            exception.addLogMessage(logMessage = message + u"\n" + details)
            # "Error creating calendar list"
            exception.process(message, u"", self.logLevel(xbmc.LOGERROR))
            return False