예제 #1
0
파일: home.py 프로젝트: emveepee/X-NEWA
 def refreshOnInit(self):
     self.win.setProperty('busy', 'true')
     if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
         try:
             self.statusData = self.xnewa.GetNextPVRInfo(self.settings.NextPVR_USER, self.settings.NextPVR_PW,self.getChannels)
             self.getChannels = False
             if self.settings.XNEWA_INTERFACE != 'NextPVR':
                 self.upcomingData = self.xnewa.getUpcomingRecordings(self.settings.NextPVR_USER, self.settings.NextPVR_PW, 10)
                 self.recentData = self.xnewa.getRecentRecordings(self.settings.NextPVR_USER, self.settings.NextPVR_PW, 10)
                 self.renderUpComing()
                 self.renderRecent()
                 self.renderStats()
             self.offline = False
         except:
             handleException()
             self.win.setProperty('busy', 'false')
             xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), smartUTF8(__language__(30120)))
             self.offline = True
     else:
         self.offline = False
         self.win.setProperty('busy', 'false')
         self.winOnline();
         xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))
         self.offline = True
         self.win.setFocusId(257)
     self.win.setProperty('busy', 'false')
예제 #2
0
 def onClick(self, controlId):
     if controlId == schedulesListBoxId:
         self.goEditSchedule()
     elif controlId == refreshButtonId:
         self.xnewa.cleanCache('scheduledRecordings.p')
         self.render()
     elif controlId == sortButtonId:
         order = [
             smartUTF8(__language__(30011)),
             smartUTF8(__language__(30012)),
             smartUTF8(__language__(30042))
         ]
         ret = xbmcgui.Dialog().select(smartUTF8(__language__(30122)),
                                       order)
         if ret != -1:
             if ret == 0:
                 self.sortkey = 'title'
             elif ret == 1:
                 self.sortkey = 'channel'
             elif ret == 2:
                 self.sortkey = 'priority'
             if self.sortkey != self.settings.XNEWA_SORT_RECURRING:
                 self.settings.XNEWA_SORT_RECURRING = self.sortkey
                 addon = Addon()
                 addon.setSetting(id='recurringSort', value=self.sortkey)
             self.render()
예제 #3
0
 def goEditSchedule(self):
     self.win.setProperty('busy', 'true')
     if self.xnewa.AreYouThere(self.settings.usewol(),
                               self.settings.NextPVR_MAC,
                               self.settings.NextPVR_BROADCAST):
         try:
             theConflicts = self.xnewa.getConflicts(
                 self.settings.NextPVR_USER, self.settings.NextPVR_PW,
                 self.conflictedData[
                     self.programsListBox.getSelectedPosition()])
             theDlg = xbmcgui.Dialog()
             theArr = []
             for conflict in theConflicts:
                 theArr.append(conflict['title'] + " " +
                               str(conflict['start']))
             pos = theDlg.select('Choose recording to cancel', theArr)
             if pos >= 0:
                 if xbmcgui.Dialog().yesno(
                         smartUTF8(__language__(30102)), "%s: %s?" %
                     (smartUTF8(__language__(30103)), theArr[pos])):
                     self.xnewa.cancelRecording(self.settings.NextPVR_USER,
                                                self.settings.NextPVR_PW,
                                                theConflicts[pos])
                     self.render()
         except:
             self.win.setProperty('busy', 'false')
             xbmcgui.Dialog().ok(smartUTF8(__language__(30104)),
                                 '%s!' % smartUTF8(__language__(30105)))
         self.win.setProperty('busy', 'false')
     else:
         self.win.setProperty('busy', 'false')
         xbmcgui.Dialog().ok('Sorry', 'An error occurred!')
예제 #4
0
파일: recent.py 프로젝트: emveepee/X-NEWA
 def formattedAirDate(self, previous, current):
     result = ''
     if not previous or previous != current:
         today = self.xnewa.formatDate(datetime.date.today())
         if current == today:
             result = smartUTF8(__language__(30133))
         else:
             yesterday = self.xnewa.formatDate(datetime.date.today() + datetime.timedelta(days=-1))
             if current == yesterday:
                 result = smartUTF8(__language__(30150))
             else:
                 result = current
     return result, current
예제 #5
0
 def formattedAirDate(self, previous, current):
     result = ''
     if not previous or previous != current:
         today = self.xnewa.formatDate(datetime.date.today())
         if current == today:
             result = smartUTF8(__language__(30133))
         else:
             tomorrow = self.xnewa.formatDate(datetime.date.today() + datetime.timedelta(days=1))
             if current == tomorrow:
                 result = smartUTF8(__language__(30134))
             else:
                 result = current
     return result, current
예제 #6
0
파일: upcoming.py 프로젝트: emveepee/X-NEWA
    def render(self):
        listItems = []
        self.programsListBox.reset()
        if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
            self.win.setProperty('busy', 'true')
            try:
                self.upcomingData = self.xnewa.getUpcomingRecordings(self.settings.NextPVR_USER, self.settings.NextPVR_PW)
                if self.upcomingData != None:
                    previous = None
                    for i, t in enumerate(self.upcomingData):
                        listItem = xbmcgui.ListItem('Row %d' % i)
                        airdate, previous = self.formattedAirDate(previous, self.xnewa.formatDate(t['start']))
                        listItem.setProperty('airdate', airdate)
                        listItem.setProperty('airdate_long', self.xnewa.formatDate(t['start'], withyear=True))
                        if ( t['significance'] == ''):
                            listItem.setProperty('title', t['title'])
                        else:
                            listItem.setProperty('title', '{0} : {1}'.format(t['title'],t['significance']))
                        listItem.setProperty('status', t['status'])
                        listItem.setProperty('start', self.xnewa.formatTime(t['start']))
                        listItem.setProperty('end', self.xnewa.formatTime(t['end']))
                        duration = ((t['end'] - t['start']).seconds) // 60
                        listItem.setProperty('duration', str(duration) )
                        listItem.setProperty('channel', t['channel'][0])
                        listItem.setProperty('description', t['desc'])
                        if t['season'] == 0:
                            listItem.setProperty('episode', t['subtitle'])
                        else:
                            listItem.setProperty('episode','({0}x{1}) {2}'.format(t['season'],t['episode'],t['subtitle']))
                        listItem.setProperty('oid', str(t['program_oid']))
                        listItems.append(listItem)
                    if len(listItems) > 0:
                        self.programsListBox.addItems(listItems)
                        self.win.setFocusId(600)
                    else:
                        self.win.setFocusId(999)

            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))

            self.win.setProperty('busy', 'false')
        else:
            #Todo: Show error message
            xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))
            self.close()
예제 #7
0
    def render(self):
        listItems = []

        self.win.setProperty('busy', 'true')
        if self.xnewa.AreYouThere(self.settings.usewol(),
                                  self.settings.NextPVR_MAC,
                                  self.settings.NextPVR_BROADCAST):
            try:
                self.conflictedData = self.xnewa.getConflictedRecordings(
                    self.settings.NextPVR_USER, self.settings.NextPVR_PW)
                if len(self.conflictedData) == 0:
                    xbmcgui.Dialog().ok('%s!' % smartUTF8(__language__(30106)),
                                        '%s!' % smartUTF8(__language__(30107)))
                    self.close()
                previous = None
                for i, t in enumerate(self.conflictedData):
                    listItem = xbmcgui.ListItem('Row %d' % i)
                    airdate, previous = self.formattedAirDate(
                        previous, self.xnewa.formatDate(t['start']))
                    listItem.setProperty('airdate', airdate)
                    listItem.setProperty('title', t['title'])
                    listItem.setProperty('start',
                                         self.xnewa.formatTime(t['start']))
                    duration = ((t['end'] - t['start']).seconds) // 60
                    listItem.setProperty('duration', str(duration))
                    listItem.setProperty('channel', t['channel'][0])
                    if len(t['subtitle']) > 0:
                        listItem.setProperty('description',
                                             t['subtitle'] + "; " + t['desc'])
                    else:
                        listItem.setProperty('description', t['desc'])
                    listItem.setProperty('description_short', t['desc'])
                    listItem.setProperty('episode', t['subtitle'])
                    listItem.setProperty('oid', str(t['program_oid']))
                    listItems.append(listItem)
                self.programsListBox.addItems(listItems)
            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                    '%s!' % smartUTF8(__language__(30109)))

            self.win.setProperty('busy', 'false')
        else:
            self.win.setProperty('busy', 'false')
            xbmcgui.Dialog().ok('Error', 'Unable to contact NextPVR Server!')
            self.close()
예제 #8
0
 def onClick(self, controlId):
     if controlId == schedulesListBoxId:
         self.goEditSchedule()
     elif controlId == refreshButtonId:
         self.xnewa.cleanCache('scheduledRecordings.p')
         self.render()
     elif controlId == sortButton.Id:
         order = [smartUTF8(__language__(30011)),smartUTF8(__language__(30012)),smartUTF8(__language__(30042))]
         ret = xbmcgui.Dialog().select(smartUTF8(__language__(30122)), order);
         if ret != -1:
             if ret == 0:
                 self.sortkey = 'title'
             elif ret == 1:
                 self.sortkey = 'channel'
             elif ret == 2:
                 self.sortkey = 'priority'
             if self.sortkey != self.settings.XNEWA_SORT_RECURRING:
                 self.settings.XNEWA_SORT_RECURRING = self.sortkey
                 addon = Addon()
                 addon.setSetting(id='recurringSort',value=self.sortkey)
             self.render()
예제 #9
0
 def goEditSchedule(self):
     self.win.setProperty('busy', 'true')
     if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
         try:
             theConflicts = self.xnewa.getConflicts(self.settings.NextPVR_USER, self.settings.NextPVR_PW, self.conflictedData[self.programsListBox.getSelectedPosition()])
             theDlg = xbmcgui.Dialog()
             theArr = []
             for conflict in theConflicts:
                 theArr.append(conflict['title'] + " " + str(conflict['start']) )
             pos = theDlg.select('Choose recording to cancel', theArr)
             if pos >= 0:
                 if xbmcgui.Dialog().yesno(smartUTF8(__language__(30102)), "%s: %s?" % (smartUTF8(__language__(30103)), theArr[pos])):
                     self.xnewa.cancelRecording(self.settings.NextPVR_USER, self.settings.NextPVR_PW, theConflicts[pos])
                     self.render()
         except:
             self.win.setProperty('busy', 'false')
             xbmcgui.Dialog().ok(smartUTF8(__language__(30104)), '%s!' % smartUTF8(__language__(30105)))
         self.win.setProperty('busy', 'false')
     else:
         self.win.setProperty('busy', 'false')
         xbmcgui.Dialog().ok('Sorry', 'An error occurred!')
예제 #10
0
파일: epg.py 프로젝트: emveepee/X-NEWA
 def _goToDate(self):
     # Show date select....
     nowdate = datetime.now()
     nowdate = nowdate + timedelta(hours=1)
     theDate = nowdate
     theDays = []
     theDays.append("Exit Guide")
     for i in range(10):
         theDays.append(self.xnewa.formatDate(nowdate))
         nowdate = nowdate + timedelta(days=1)
     theDlg = xbmcgui.Dialog()
     pos = theDlg.select('%s:' % smartUTF8(__language__(30142)), theDays)
     if pos < 0:
         return 0
     if pos==0:
         return -1
     pos = pos - 1
     theDate = theDate + timedelta(days=pos)
     nowdate = nowdate.replace(hour=19, minute=0)
     theHours = []
     for i in range(12):
         theHours.append(self.xnewa.formatTime(nowdate))
         nowdate = nowdate + timedelta(hours=2)
     pos = theDlg.select('%s:' % smartUTF8(__language__(30143)), theHours)
     if pos <0:
         return -1
     pos = 19 + (pos * 2)
     while pos>23:
         pos = pos - 24
     theDate = theDate.replace(hour=pos, minute=0)
     theDlg.ok(smartUTF8(__language__(30144)),"%s: %s" % (smartUTF8(__language__(30145)), self.xnewa.formatDate(theDate) + ' ' + self.xnewa.formatTime(theDate)))
     self.initDate = theDate
     self.epgStartTime = theDate
     self.loadNextPVR(theDate)
     self.updateTimeBars(0)
     self.channelTop = -999
     self.updateChannels(0)
     self.setFocus(0, 0,False)
     return pos
예제 #11
0
    def render(self):
        listItems = []

        self.win.setProperty('busy', 'true')
        if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
            try:
                self.conflictedData = self.xnewa.getConflictedRecordings(self.settings.NextPVR_USER, self.settings.NextPVR_PW)
                if len(self.conflictedData) == 0:
                    xbmcgui.Dialog().ok('%s!' % smartUTF8(__language__(30106)), '%s!' % smartUTF8(__language__(30107)))
                    self.close()
                previous = None
                for i, t in enumerate(self.conflictedData):
                    listItem = xbmcgui.ListItem('Row %d' % i)
                    airdate, previous = self.formattedAirDate(previous, self.xnewa.formatDate(t['start']))
                    listItem.setProperty('airdate', airdate)
                    listItem.setProperty('title', t['title'])
                    listItem.setProperty('start', self.xnewa.formatTime(t['start']))
                    duration = ((t['end'] - t['start']).seconds) // 60
                    listItem.setProperty('duration', str(duration) )
                    listItem.setProperty('channel', t['channel'][0])
                    if len(t['subtitle']) > 0:
                        listItem.setProperty('description', t['subtitle'] + "; " + t['desc'])
                    else:
                        listItem.setProperty('description', t['desc'])
                    listItem.setProperty('description_short', t['desc'])
                    listItem.setProperty('episode', t['subtitle'])
                    listItem.setProperty('oid', str(t['program_oid']))
                    listItems.append(listItem)
                self.programsListBox.addItems(listItems)
            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))

            self.win.setProperty('busy', 'false')
        else:
            self.win.setProperty('busy', 'false')
            xbmcgui.Dialog().ok('Error', 'Unable to contact NextPVR Server!')
            self.close()
예제 #12
0
    def render(self):
        listItems = []
        self.schedulesListBox.reset()
        if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
            self.win.setProperty('busy', 'true')
            try:
                self.scheduleData = self.xnewa.getScheduledRecordings(self.settings.NextPVR_USER, self.settings.NextPVR_PW)
                self.scheduleData.sort(key=operator.itemgetter(self.sortkey))
                previous = None
                for i, t in enumerate(self.scheduleData):
                    listItem = xbmcgui.ListItem('Row %d' % i)
                    listItem.setProperty('title', t['name'])
                    showIcon = self.xnewa.getShowIcon(t['title'])
                    listItem.setProperty('showicon',showIcon)
                    if t['channel_oid']!=0:
                        listItem.setProperty('channel', t['channel'][0])
                    else:
                        listItem.setProperty('channel', '%s %s' % (smartUTF8(__language__(30020)), smartUTF8(__language__(30057))))
                    listItem.setProperty('rectype', t['rectype'])
                    listItem.setProperty('priority', str(t['priority']))
                    listItem.setProperty('oid', str(t['recording_oid']))
                    listItems.append(listItem)
                if len(listItems) > 0:
                    self.schedulesListBox.addItems(listItems)
                    self.win.setFocusId(600)
                else:
                    self.win.setFocusId(999)

            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))

            self.win.setProperty('busy', 'false')
        else:
            #Todo: Show error message
            xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))
            self.close()
예제 #13
0
 def refreshOnInit(self):
     self.win.setProperty('busy', 'true')
     if self.xnewa.AreYouThere(self.settings.usewol(),
                               self.settings.NextPVR_MAC,
                               self.settings.NextPVR_BROADCAST):
         try:
             self.statusData = self.xnewa.GetNextPVRInfo(
                 self.settings.NextPVR_USER, self.settings.NextPVR_PW,
                 self.getChannels)
             self.getChannels = False
             if self.settings.XNEWA_INTERFACE != 'NextPVR':
                 self.upcomingData = self.xnewa.getUpcomingRecordings(
                     self.settings.NextPVR_USER, self.settings.NextPVR_PW,
                     10)
                 self.recentData = self.xnewa.getRecentRecordings(
                     self.settings.NextPVR_USER, self.settings.NextPVR_PW,
                     10)
                 self.renderUpComing()
                 self.renderRecent()
                 self.renderStats()
             self.offline = False
         except:
             handleException()
             self.win.setProperty('busy', 'false')
             xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                 smartUTF8(__language__(30120)))
             self.offline = True
     else:
         self.offline = False
         self.win.setProperty('busy', 'false')
         self.winOnline()
         xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                             '%s!' % smartUTF8(__language__(30109)))
         self.offline = True
         self.win.setFocusId(257)
     self.win.setProperty('busy', 'false')
예제 #14
0
    def render(self):
        listItems = []
        self.schedulesListBox.reset()
        if self.xnewa.AreYouThere(self.settings.usewol(),
                                  self.settings.NextPVR_MAC,
                                  self.settings.NextPVR_BROADCAST):
            self.win.setProperty('busy', 'true')
            try:
                self.scheduleData = self.xnewa.getScheduledRecordings(
                    self.settings.NextPVR_USER, self.settings.NextPVR_PW)
                self.scheduleData.sort(key=operator.itemgetter(self.sortkey))
                for i, t in enumerate(self.scheduleData):
                    listItem = xbmcgui.ListItem('Row %d' % i)
                    listItem.setProperty('title', t['name'])
                    showIcon = self.xnewa.getShowIcon(t['title'])
                    listItem.setProperty('showicon', showIcon)
                    if t['channel_oid'] != 0:
                        listItem.setProperty('channel', t['channel'][0])
                    else:
                        listItem.setProperty(
                            'channel',
                            '%s %s' % (smartUTF8(__language__(30020)),
                                       smartUTF8(__language__(30057))))
                    listItem.setProperty('rectype', t['rectype'])
                    listItem.setProperty('priority', str(t['priority']))
                    listItem.setProperty('oid', str(t['recording_oid']))
                    listItems.append(listItem)
                if len(listItems) > 0:
                    self.schedulesListBox.addItems(listItems)
                    self.win.setFocusId(600)
                else:
                    self.win.setFocusId(999)

            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                    '%s!' % smartUTF8(__language__(30109)))

            self.win.setProperty('busy', 'false')
        else:
            #Todo: Show error message
            xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                '%s!' % smartUTF8(__language__(30109)))
            self.close()
예제 #15
0
    def render(self):
        self.win.setProperty('busy', 'true')
        self.programsListBox.reset()
        listItems = []
        if self.xnewa.offline == True or self.xnewa.AreYouThere(
                self.settings.usewol(), self.settings.NextPVR_MAC,
                self.settings.NextPVR_BROADCAST):
            try:
                if self.mode == 1:
                    self.win.setProperty('recordings', 'true')
                    self.recentData = self.xnewa.getRecentRecordings(
                        self.settings.NextPVR_USER,
                        self.settings.NextPVR_PW,
                        showName=self.show,
                        sortTitle=self.sortTitle[1],
                        sortDateDown=self.sortDate[1],
                        recDir=self.recDir)
                    if len(self.recentData) > 0:
                        if self.settings.XNEWA_SORT_EPISODE == 3:
                            self.recentData = sorted(
                                self.recentData,
                                key=lambda x: (x['season'], x['episode']))
                        previous = None
                        for i, t in enumerate(self.recentData):
                            if t:
                                #print ( 'the airdate for %s is %s' % (t['title'], t['start'].strftime( xbmc.getRegion('datelong') )) )
                                listItem = xbmcgui.ListItem('Row %d' % i)
                                airdate, previous = self.formattedAirDate(
                                    previous,
                                    self.xnewa.formatDate(t['start']))
                                listItem.setProperty('airdate', airdate)
                                listItem.setProperty(
                                    'airdate_long',
                                    self.xnewa.formatDate(t['start'],
                                                          withyear=True))
                                if (t['significance'] == ''):
                                    listItem.setProperty('title', t['title'])
                                else:
                                    listItem.setProperty(
                                        'title', '{0} : {1}'.format(
                                            t['title'], t['significance']))

                                listItem.setProperty('status', t['status'])
                                listItem.setProperty(
                                    'start', self.xnewa.formatTime(t['start']))
                                listItem.setProperty(
                                    'end', self.xnewa.formatTime(t['end']))
                                duration = (
                                    (t['end'] - t['start']).seconds) // 60
                                listItem.setProperty('duration', str(duration))
                                listItem.setProperty('channel',
                                                     t['channel'][0])
                                listItem.setProperty('description', t['desc'])
                                if t['season'] == 0:
                                    listItem.setProperty(
                                        'episode', t['subtitle'])
                                else:
                                    listItem.setProperty(
                                        'episode', '({0}x{1}) {2}'.format(
                                            t['season'], t['episode'],
                                            t['subtitle']))
                                listItem.setProperty('oid',
                                                     str(t['recording_oid']))
                                listItems.append(listItem)
                            else:
                                i = i - 1
                        if i == 0:
                            self.sortButton.setVisible(False)
                        newPosition = 0
                else:
                    xbmc.log('calling summary for recDir ' + str(self.recDir))
                    self.recentData = self.xnewa.getRecordingsSummary(
                        self.settings.NextPVR_USER, self.settings.NextPVR_PW,
                        self.sortTitle[0], not self.sortDate[0], self.recDir)
                    self.win.setProperty('recordings', 'false')
                    previous = None
                    for i, t in enumerate(self.recentData):
                        if t:
                            listItem = xbmcgui.ListItem('Row %d' % i)
                            airdate, previous = self.formattedAirDate(
                                previous,
                                self.xnewa.formatDate(t['start'],
                                                      gmtoffset=True))
                            listItem.setProperty('airdate', airdate)
                            listItem.setProperty(
                                'airdate_long',
                                self.xnewa.formatDate(t['start'],
                                                      withyear=True))
                            listItem.setProperty('title', t['title'])
                            showIcon = self.xnewa.getShowIcon(t['title'])
                            listItem.setProperty('showicon', showIcon)
                            listItem.setProperty('count', str(t['count']))
                            listItems.append(listItem)
                        else:
                            i = i - 1
                    newPosition = self.showPosition
                if len(listItems) > 0:
                    self.programsListBox.addItems(listItems)
                    self.programsListBox.selectItem(newPosition)
                    self.win.setFocusId(600)
                else:
                    self.win.setFocusId(999)
            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                    '%s!' % smartUTF8(__language__(30109)))
            self.sortButton.setVisible(True)
            self.win.setProperty('busy', 'false')
        else:
            xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                '%s!' % smartUTF8(__language__(30109)))
            self.close()
예제 #16
0
파일: epg.py 프로젝트: emveepee/X-NEWA
    def onAction(self, action):
        try:
            actionID = action.getId()
            buttonID = action.getButtonCode()
        except: return

        if actionID in EXIT_SCRIPT or buttonID in EXIT_SCRIPT:
            self.ready = False
            #self.cleanup()
            self.close()
            return
        elif not self.ready:
            return

        self.ready = False
        if actionID in MOVEMENT_LEFT:
            self.moveFocus(2)
            #self.updateTimeBars(-1)
            #self.updateChannels(0)
        elif actionID in MOVEMENT_RIGHT:
            self.moveFocus(1)
            #self.updateTimeBars(+1)
            #self.updateChannels(0)
        elif actionID in MOVEMENT_DOWN:
            #self.updateChannels(self.channelTop+1)
            self.moveFocus(3)
        elif actionID in MOVEMENT_UP:
            self.moveFocus(4)
            #self.updateChannels(self.channelTop-1)
        elif actionID in MOVEMENT_SCROLL_DOWN:
            i = self.channelTop + self.MaxDisplayChannels -1
            if i > (self.channelCount - self.MaxDisplayChannels):
                i = 0
            self.updateChannels(i)
            self.setFocus(0, 0,True)
        elif actionID in MOVEMENT_SCROLL_UP:

            i = self.channelTop - self.MaxDisplayChannels + 1
            if i < 0:
                i = self.channelCount - self.MaxDisplayChannels
                self.idxRow = 0
                self.idxButt = 0
            self.updateChannels(i)
            self.setFocus(0, 0,True)
        elif actionID == ACTION_PLAYER_PLAY:
            self.quickPlayer()
        elif actionID in CONTEXT_MENU or buttonID in CONTEXT_MENU:
            if self._goToDate() == -1:
                self.ready = False
                self.close()
        elif (actionID >= 58 and actionID <=69) or actionID == ACTION_INFO or (buttonID >= 0xf030 and buttonID <= 0xf039):
            dialog = xbmcgui.Dialog()
            if buttonID >= 0xf030 and buttonID <= 0xf039:
                value = dialog.numeric( 0, smartUTF8(__language__(30012)), str(buttonID-0xf030) )
            elif actionID >= 58 and actionID <= 69:
                value = dialog.numeric( 0, smartUTF8(__language__(30012)), str(actionID-58) )
            else:
                value = dialog.numeric( 0, smartUTF8(__language__(30012)))
            if value is not None:
                i = 0
                for a in self.epgData:
                    try:
                        if value == a['num']:
                            self.updateChannels(i)
                            self.setFocus(0, 0,True)
                            break
                    except:
                        print(value)
                        print(a['num'])

                    i = i + 1

        self.ready = True
예제 #17
0
파일: recent.py 프로젝트: emveepee/X-NEWA
    def processFile(self, process_type):
        deleteAll = None
        archiveSetting = None
        refresh = False
        for i in range(self.programsListBox.size()):
            if self.programsListBox.getListItem(i).isSelected():
                oid = int(self.programsListBox.getListItem(i).getProperty('oid'))
                for j,progDetails in enumerate(self.recentData):
                    if progDetails:
                        if oid == progDetails['recording_oid']:
                            if process_type == __language__(30039):
                                if archiveSetting == None:
                                    choices = list(self.xnewa.RecDirs.keys())
                                    archiveSetting =  xbmcgui.Dialog().select(smartUTF8(__language__(30115)), choices)
                                    if archiveSetting != -1:
                                        dialog = xbmcgui.Dialog()
                                        ret = dialog.yesno(choices[archiveSetting], '%s %s?' % (smartUTF8(__language__(30116)), choices[archiveSetting]))
                                        if ret != 1:
                                            archiveSetting = -1

                                if archiveSetting != -1:
                                    if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
                                        try:
                                            if self.xnewa.archiveRecording(self.settings.NextPVR_USER, self.settings.NextPVR_PW,progDetails['recording_oid'], choices[archiveSetting]  ):
                                                xbmc.log('file archived')
                                            else:
                                                xbmcgui.Dialog().ok(smartUTF8(__language__(30104)), smartUTF8(__language__(30105)))
                                        except:
                                            xbmcgui.Dialog().ok(smartUTF8(__language__(30104)), smartUTF8(__language__(30105)))


                            elif process_type == __language__(32003):
                                if progDetails['status'] == "Failed":
                                    ret = xbmcgui.Dialog().yesno('%s %s' % (smartUTF8(__language__(30135)), progDetails['title']), '%s\n%s?' % (smartUTF8(__language__(30112)), progDetails['title']))
                                elif progDetails['status'] != "In-Progress" and 'filename' in progDetails:
                                    ret = xbmcgui.Dialog().yesno('%s %s' % (smartUTF8(__language__(30054)), progDetails['title']), '%s\n%s?' % (smartUTF8(__language__(30111)), progDetails['filename']))
                                else:
                                    break
                                self.returnvalue = "DEL"
                                if ret == 1:
                                    if self.xnewa.cancelRecording(self.settings.NextPVR_USER, self.settings.NextPVR_PW, progDetails):
                                        refresh = True

                            elif process_type == __language__(30054):
                                if deleteAll==None:
                                    ret = xbmcgui.Dialog().yesno('%s %s' % (__language__(30054), progDetails['title']), '%s %d %s?' % (__language__(30111), self.selections , 'marked recording(s)' ))
                                    if ret == 1 :
                                        deleteAll = True
                                    else:
                                        deleteAll = False
                                if deleteAll==True:
                                    if self.xnewa.cancelRecording(self.settings.NextPVR_USER, self.settings.NextPVR_PW, progDetails):
                                        refresh = True
                                else:
                                    break
                            elif process_type == __language__(32004):
                                duration = progDetails['duration']
                                if duration == 0:
                                    duration = int(self.programsListBox.getListItem(i).getProperty('duration')) * 60
                                if duration > int(progDetails['resume']):
                                    retval = self.xnewa.setLibraryPlaybackPosition(progDetails['filename'], duration, duration )
                            elif process_type == __language__(30034):
                                if int(progDetails['resume']) !=0 :
                                    duration = progDetails['duration']
                                    if duration == 0:
                                        duration = int(self.programsListBox.getListItem(i).getProperty('duration')) * 60
                                    retval = self.xnewa.setLibraryPlaybackPosition(progDetails['filename'], 0, duration )
                            else:
                                xbmc.log('Unknown process type')

                            self.programsListBox.getListItem(i).select(False)
                            self.selections -= 1


        if refresh == True:
            self.xnewa.cleanCache('recentRecordings*.p')
            self.xnewa.cleanCache('summary.List')
            self.mode = 0
예제 #18
0
파일: epg.py 프로젝트: emveepee/X-NEWA
    def updateTimeBars(self, command):
        # debug("--> updateTimeBars() command=[%s]" %(command))
        if command > 0:
            interval = command * self.settings.EPG_SCROLL_INT
            tNew = self.epgStartTime + timedelta(minutes=interval) + timedelta(minutes=self.settings.EPG_DISP_INT)
            if tNew > self.EPGEndTime and self.xnewa.offline == False:
                myDlg = xbmcgui.DialogProgress()
                myDlg.create("%s..." % smartUTF8(__language__(30146)), "%s..." % smartUTF8(__language__(30139)))
                myDlg.update(33, "%s..." % smartUTF8(__language__(30140)))

                # Todo: Get correct times....
                print('start date ' + str(tNew))
                if  self.isdst == 1:
                    print('atz ' + str(time.altzone ))
                    tdate1 = tNew + timedelta(seconds=time.altzone)
                else:
                    print('tz ' + str(time.timezone))
                    tdate1 = tNew + timedelta(seconds=time.timezone)
                #cstart = tdate1.strftime("%Y-%m-%dT%H:%M:00")
                cstart = tdate1
                tNew = tNew + timedelta(hours=self.settings.EPG_RETR_INT)
                self.EPGEndTime = tNew
                if  self.isdst == 1:
                    tNew = tNew + timedelta(seconds=time.altzone)
                else:
                    tNew = tNew + timedelta(seconds=time.timezone)
                #cend = tNew.strftime("%Y-%m-%dT%H:%M:00")
                cend = tNew
#               cstart = tNew.strftime("%Y-%m-%dT%H:%M:00")
#               tNew = tNew + timedelta(hours=self.settings.EPG_RETR_INT)


#               self.EPGEndTime = tNew
#               cend = tNew.strftime("%Y-%m-%dT%H:%M:00")
                if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
                    tempData = self.xnewa.getGuideInfo(self.settings.NextPVR_USER, self.settings.NextPVR_PW, cstart, cend, self.settings.EPG_GROUP)
                else:
                    return
                # Combine tempdata and epgdata
                # Todo: Handle "empty" chsnnels.... !! Need to rewrite and check for channel oid !!
                for i, a in enumerate(self.epgData):
                    # Find epgData channel-oid in tempData..
                    thePos = -1
                    for j, b in enumerate(tempData):
                        if b['oid'] == a['oid']:
                                thePos = j
                    if thePos > -1:
                        if len(tempData[thePos]['progs']) > 0:
                            if a['progs'][len(a['progs'])-1]['oid'] == tempData[thePos]['progs'][0]['oid']:
                                a['progs'] = a['progs'] + tempData[thePos]['progs'][1:]
                            else:
                                a['progs'] = a['progs'] + tempData[thePos]['progs']
                myDlg.update(100, "Complete")
                myDlg.close()
            self.epgStartTime = self.epgStartTime + timedelta(minutes=interval)
        elif command < 0:
            interval = command * self.settings.EPG_SCROLL_INT
            self.epgStartTime = self.epgStartTime + timedelta(minutes=interval)
            if self.epgStartTime < self.initDate:
                # Todo: Make nicer....
                self.updateTimeBars(0)
        else:
            self.epgStartTime = self.initDate

        self.epgTimerBars[0].setLabel(self.xnewa.formatDate(self.epgStartTime))
        tempdate = self.epgStartTime
        for i in range (1, self.TimeIntervals):
            self.epgTimerBars[i].setLabel(self.xnewa.formatTime(tempdate))
            tempdate = tempdate + timedelta(minutes=self.settings.EPG_SCROLL_INT)
        posx = self.getPosFromTime(datetime.now())
        if posx > self.epgProgsX:
            self.removeControl(self.nowTimeCI)
            self.nowTimeCI.setPosition(posx, self.epgY)
            self.moveBar = datetime.now() + timedelta(seconds = 30)
            self.nowTimeCI.setVisible(True)
            self.addControl(self.nowTimeCI)
        else:
            self.nowTimeCI.setVisible(False)
예제 #19
0
    def render(self):
        listItems = []
        self.programsListBox.reset()
        if self.xnewa.AreYouThere(self.settings.usewol(),
                                  self.settings.NextPVR_MAC,
                                  self.settings.NextPVR_BROADCAST):
            self.win.setProperty('busy', 'true')
            try:
                self.upcomingData = self.xnewa.getUpcomingRecordings(
                    self.settings.NextPVR_USER, self.settings.NextPVR_PW)
                if self.upcomingData != None:
                    previous = None
                    for i, t in enumerate(self.upcomingData):
                        listItem = xbmcgui.ListItem('Row %d' % i)
                        airdate, previous = self.formattedAirDate(
                            previous, self.xnewa.formatDate(t['start']))
                        listItem.setProperty('airdate', airdate)
                        listItem.setProperty(
                            'airdate_long',
                            self.xnewa.formatDate(t['start'], withyear=True))
                        if (t['significance'] == ''):
                            listItem.setProperty('title', t['title'])
                        else:
                            listItem.setProperty(
                                'title',
                                '{0} : {1}'.format(t['title'],
                                                   t['significance']))
                        listItem.setProperty('status', t['status'])
                        listItem.setProperty('start',
                                             self.xnewa.formatTime(t['start']))
                        listItem.setProperty('end',
                                             self.xnewa.formatTime(t['end']))
                        duration = ((t['end'] - t['start']).seconds) // 60
                        listItem.setProperty('duration', str(duration))
                        listItem.setProperty('channel', t['channel'][0])
                        listItem.setProperty('description', t['desc'])
                        if t['season'] == 0:
                            listItem.setProperty('episode', t['subtitle'])
                        else:
                            listItem.setProperty(
                                'episode',
                                '({0}x{1}) {2}'.format(t['season'],
                                                       t['episode'],
                                                       t['subtitle']))
                        listItem.setProperty('oid', str(t['program_oid']))
                        listItems.append(listItem)
                    if len(listItems) > 0:
                        self.programsListBox.addItems(listItems)
                        self.win.setFocusId(600)
                    else:
                        self.win.setFocusId(999)

            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                    '%s!' % smartUTF8(__language__(30109)))

            self.win.setProperty('busy', 'false')
        else:
            #Todo: Show error message
            xbmcgui.Dialog().ok(smartUTF8(__language__(30108)),
                                '%s!' % smartUTF8(__language__(30109)))
            self.close()
예제 #20
0
def getChannelList_v5(self):
    xbmc.log("getChannelList v5 start")
    dic = {}
    cnt = 0
    dic['0'] = (u"Unknown", '0')
    myDlg = None
    try:
        import imghdr
        import glob
        method = 'channel.list'
        ret, channels = doRequest5(self, method)
        if ret == False:
            return dic
        for channel in channels['channels']:
            if (channel['channelIcon']):
                cnt = cnt + 1
        if cnt > 0:
            icons = glob.glob(os.path.join(self.cached_channelPath, '*.*'))
            if cnt > len(icons) + 20:
                myDlg = xbmcgui.DialogProgress()
                myDlg.create(smartUTF8(__language__(30154)),
                             smartUTF8(__language__(30139)))
            cnt = 0
        for channel in channels['channels']:
            if myDlg != None:
                completed = 100 * cnt // len(channels)
                cnt = cnt + 1
                myDlg.update(completed, py2_decode(channel['channelName']))
            if 'channelNumber' in channel:
                dic[str(channel['channelId'])] = (py2_decode(
                    channel['channelName']), str(channel['channelNumber']),
                                                  str(channel['channelMinor']))
            if channel['channelIcon']:
                try:
                    import string
                    valid_chars = "!@#&-_.,() %s%s" % (string.ascii_letters,
                                                       string.digits)
                    safename = ''.join(ch for ch in channel['channelName']
                                       if ch in valid_chars)
                    output = os.path.join(self.channelPath, safename + ".*")
                    icon = glob.glob(output)
                    if not icon:
                        method = 'channel.icon&channel_id=' + str(
                            channel['channelId'])
                        ret, binaryIcon = doRequest5(self, method, False)
                        if ret == True:
                            unknown = os.path.join(self.channelPath, "unknown")
                            with open(unknown, 'wb') as outfile:
                                outfile.write(binaryIcon)
                            img = imghdr.what(unknown)
                            if img == "png":
                                os.rename(
                                    unknown,
                                    os.path.join(self.channelPath,
                                                 py2_decode(safename) +
                                                 ".png"))
                            elif img == "jpeg":
                                os.rename(
                                    unknown,
                                    os.path.join(self.channelPath,
                                                 py2_decode(safename) +
                                                 ".jpg"))
                            elif img is None:
                                xbmc.log(py2_decode(safename) + " is unknown")
                            else:
                                xbmc.log(py2_decode(safename) + " Type " + img)
                    else:
                        pass
                except Exception as err:
                    xbmc.log(str(err))
                    xbmc.log(str(channel['channelNum']) + " Error")

                pass
            else:
                pass
    except Exception as err:
        xbmc.log(str(err))

    xbmc.log("getChannelList v5 end")
    return dic
예제 #21
0
    def onClick(self, controlId):
        if controlId == programsListBoxId:
            self.goEditSchedule()
        elif controlId == refreshButtonId:
            self.xnewa.cleanCache('recentRecordings*.p')
            self.xnewa.cleanCache('summary.List')
            self.render()
        elif controlId == importButtonId:
            dialog = xbmcgui.Dialog()
            ret = dialog.yesno(
                smartUTF8(__language__(30127)),
                '%s %s' % (smartUTF8(__language__(30121)), self.recentData[
                    self.programsListBox.getSelectedPosition()]['title']))
        elif controlId == actionButtonId:
            order = [
                __language__(30038),
                __language__(30039),
                __language__(32003),
                __language__(30054),
                __language__(32004),
                __language__(30033)
            ]
            ret = xbmcgui.Dialog().select(__language__(32005), order)
            if ret > 0:
                self.processFile(order[ret])
                if self.selections > 0:
                    self.win.setProperty('tagged', 'true')
                else:
                    self.win.setProperty('tagged', 'false')
                if self.mode == 0:
                    self.render()

        elif controlId == filterButtonId:
            choices = list(self.xnewa.RecDirs.keys())
            if self.filterButton.isSelected():
                archive = xbmcgui.Dialog().select(
                    smartUTF8(__language__(30115)), choices)
                if archive != -1:
                    self.filtered = True
                    self.win.setProperty('archive', choices[archive])
                    self.recDir = self.xnewa.RecDirs[choices[archive]]
            else:
                self.recDir = None
                archive = 0
                self.win.setProperty('archive', __language__(30020))

            if archive != -1:
                self.xnewa.cleanCache('recentRecordings*.p')
                self.xnewa.cleanCache('summary.List')
                self.render()
        elif controlId == sortButtonId:
            order = [
                smartUTF8(__language__(30011)),
                smartUTF8(__language__(30148)),
                smartUTF8(__language__(30149)),
                __language__(32006)
            ]
            ret = xbmcgui.Dialog().select(smartUTF8(__language__(30122)),
                                          order)
            if ret != -1:
                if ret == 0:
                    self.sortTitle[self.mode] = True
                    self.sortDate[self.mode] = True
                elif ret == 1:
                    self.sortTitle[self.mode] = False
                    self.sortDate[self.mode] = True
                elif ret == 2:
                    self.sortTitle[self.mode] = False
                    self.sortDate[self.mode] = False
                if self.mode == 0:
                    if ret != self.settings.XNEWA_SORT_RECORDING:
                        addon = Addon()
                        addon.setSetting(id='recordingSort', value=str(ret))
                        self.settings.XNEWA_SORT_RECORDING = ret
                        self.xnewa.cleanCache('summary.List')
                else:
                    if ret != self.settings.XNEWA_SORT_EPISODE:
                        addon = Addon()
                        addon.setSetting(id='episodeSort', value=str(ret))
                        self.settings.XNEWA_SORT_EPISODE = ret
                        self.xnewa.cleanCache('recentRecordings*.p')
                self.render()
예제 #22
0
파일: epg.py 프로젝트: emveepee/X-NEWA
    def loadNextPVR(self, theDate=None):
        # Todo: Error-Handling
        debug("--> loadNextPVR" )
        success = True
        if theDate is None:
            theDate = self.initDate

        #myDlg = xbmcgui.DialogProgress()
        #myDlg.create("%s..." % smartUTF8(__language__(30138)), "%s..." % smartUTF8(__language__(30139)))

        #myDlg.update(33, "%s..." % smartUTF8(__language__(30140)))

        # Todo: Get correct times....
        tdate = theDate
        print('start date ' + str(tdate))
        if self.isdst == 1:
            print('atz ' + str(time.altzone))
            tdate1 = tdate + timedelta(seconds=time.altzone)
        else:
            print('tz ' + str(time.timezone))
            tdate1 = tdate + timedelta(seconds=time.timezone)
        #cstart = tdate1.strftime("%Y-%m-%dT%H:%M:00")
        cstart = tdate1
        tdate = tdate1 + timedelta(hours=self.settings.EPG_RETR_INT)

        self.EPGEndTime = tdate
        '''
        if self.isdst == 1:
            tdate = tdate + timedelta(seconds=time.altzone)
        else:
            tdate = tdate + timedelta(seconds=time.timezone)
        '''
        #cend = tdate.strftime("%Y-%m-%dT%H:%M:00")

        cend = tdate


        channelGroup = self.settings.EPG_GROUP
        if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
            try:
                self.epgData = self.xnewa.getGuideInfo(self.settings.NextPVR_USER, self.settings.NextPVR_PW, cstart, cend, channelGroup)
            except:
                xbmcgui.Dialog().ok(smartUTF8(__language__(30104)), '%s!' % smartUTF8(__language__(30119)))

        #myDlg.update(66, "%s..." % smartUTF8(__language__(30140)))

        chCount = len(self.epgData)
        # debug ("Channelcount: %s" %(chCount) )
        if not chCount:
            success = False

        if success:
            self.channelCount = chCount

        self.ChLogos = []
        for a in self.epgData:
            cfile = self.xnewa.getChannelIcon(a['name'])
            if cfile is not None:
                self.ChLogos.append(cfile)
            else:
                self.ChLogos.append('noimage.png')

        #myDlg.update(100, smartUTF8(__language__(30141)))
        #myDlg.close()
        debug("<-- loadNextPVR() success=%s" % success)
        return True
예제 #23
0
                        ew.doModal()
                    elif sys.argv[1] == "schedules":
                        from nextpvr.schedules import SchedulesWindow
                        sw = SchedulesWindow('nextpvr_schedules.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                        sw.doModal()
                    elif sys.argv[1] == "epg":
                        from nextpvr.epg import EpgWindow
                        ew = EpgWindow('nextpvr_epg.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                        ew.doModal()
                    elif sys.argv[1] == "recordings":
                        from nextpvr.recent import RecentRecordingsWindow
                        rw = RecentRecordingsWindow('nextpvr_recent.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                        rw.doModal()
                    else:
                        HomeWindow('nextpvr_home.xml', WHERE_AM_I, settings=my_settings, xnewa=my_xnewa).doModal()
                else:
                    HomeWindow('nextpvr_home.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa).doModal()
            else:
                ew = EmulateWindow("nextpvr_emulate.xml", WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                ew.doModal()
        else:
            dialog = xbmcgui.Dialog()
            ok = dialog.ok('%s' % smartUTF8(__language__(30100)), '%s \n%s' % (smartUTF8(__language__(30101)), my_xnewa.ip))
    except:
        handleException()

    # remove other globals
    try:
        del dialogProgress
    except: pass
예제 #24
0
파일: recent.py 프로젝트: emveepee/X-NEWA
    def render(self):
        self.win.setProperty('busy', 'true')
        self.programsListBox.reset()
        listItems = []
        if self.xnewa.offline == True or self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
            try:
                if self.mode == 1:
                    self.win.setProperty('recordings', 'true')
                    self.recentData = self.xnewa.getRecentRecordings(self.settings.NextPVR_USER, self.settings.NextPVR_PW,showName=self.show,sortTitle=self.sortTitle[1],sortDateDown=self.sortDate[1],recDir=self.recDir)
                    if len(self.recentData) > 0:
                        if self.settings.XNEWA_SORT_EPISODE == 3:
                            self.recentData = sorted(self.recentData, key = lambda x: (x['season'], x['episode']))
                        previous = None
                        for i, t in enumerate(self.recentData):
                            if t:
                                #print ( 'the airdate for %s is %s' % (t['title'], t['start'].strftime( xbmc.getRegion('datelong') )) )
                                listItem = xbmcgui.ListItem('Row %d' % i)
                                airdate, previous = self.formattedAirDate(previous, self.xnewa.formatDate(t['start']))
                                listItem.setProperty('airdate', airdate)
                                listItem.setProperty('airdate_long',  self.xnewa.formatDate(t['start'], withyear=True))
                                if ( t['significance'] == ''):
                                    listItem.setProperty('title', t['title'])
                                else:
                                    listItem.setProperty('title', '{0} : {1}'.format(t['title'],t['significance']))


                                listItem.setProperty('status', t['status'])
                                listItem.setProperty('start', self.xnewa.formatTime(t['start']))
                                listItem.setProperty('end', self.xnewa.formatTime(t['end']))
                                duration = ((t['end'] - t['start']).seconds) // 60
                                listItem.setProperty('duration', str(duration) )
                                listItem.setProperty('channel', t['channel'][0])
                                listItem.setProperty('description', t['desc'])
                                if t['season'] == 0:
                                    listItem.setProperty('episode', t['subtitle'])
                                else:
                                    listItem.setProperty('episode','({0}x{1}) {2}'.format(t['season'],t['episode'],t['subtitle']))
                                listItem.setProperty('oid', str(t['recording_oid']))
                                listItems.append(listItem)
                            else:
                                i = i - 1
                        if i==0:
                            self.sortButton.setVisible(False)
                        newPosition = 0
                else:
                    xbmc.log( 'calling summary for recDir ' + str(self.recDir))
                    self.recentData = self.xnewa.getRecordingsSummary(self.settings.NextPVR_USER, self.settings.NextPVR_PW,self.sortTitle[0],not self.sortDate[0],self.recDir)
                    self.win.setProperty('recordings', 'false')
                    previous = None
                    for i, t in enumerate(self.recentData):
                        if t:
                            listItem = xbmcgui.ListItem('Row %d' % i)
                            airdate, previous = self.formattedAirDate(previous, self.xnewa.formatDate(t['start'], gmtoffset=True))
                            listItem.setProperty('airdate', airdate)
                            listItem.setProperty('airdate_long',  self.xnewa.formatDate(t['start'], withyear=True))
                            listItem.setProperty('title', t['title'])
                            showIcon = self.xnewa.getShowIcon(t['title'])
                            listItem.setProperty('showicon',showIcon)
                            listItem.setProperty('count', str(t['count']) )
                            listItems.append(listItem)
                        else:
                            i = i - 1
                    newPosition = self.showPosition
                if len(listItems) > 0:
                    self.programsListBox.addItems(listItems)
                    self.programsListBox.selectItem(newPosition)
                    self.win.setFocusId(600)
                else:
                    self.win.setFocusId(999)
            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))
            self.sortButton.setVisible(True)
            self.win.setProperty('busy', 'false')
        else:
            xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))
            self.close()
예제 #25
0
    def processFile(self, process_type):
        deleteAll = None
        archiveSetting = None
        refresh = False
        for i in range(self.programsListBox.size()):
            if self.programsListBox.getListItem(i).isSelected():
                oid = int(
                    self.programsListBox.getListItem(i).getProperty('oid'))
                for j, progDetails in enumerate(self.recentData):
                    if progDetails:
                        if oid == progDetails['recording_oid']:
                            if process_type == __language__(30039):
                                if archiveSetting == None:
                                    choices = list(self.xnewa.RecDirs.keys())
                                    archiveSetting = xbmcgui.Dialog().select(
                                        smartUTF8(__language__(30115)),
                                        choices)
                                    if archiveSetting != -1:
                                        dialog = xbmcgui.Dialog()
                                        ret = dialog.yesno(
                                            choices[archiveSetting], '%s %s?' %
                                            (smartUTF8(__language__(30116)),
                                             choices[archiveSetting]))
                                        if ret != 1:
                                            archiveSetting = -1

                                if archiveSetting != -1:
                                    if self.xnewa.AreYouThere(
                                            self.settings.usewol(),
                                            self.settings.NextPVR_MAC,
                                            self.settings.NextPVR_BROADCAST):
                                        try:
                                            if self.xnewa.archiveRecording(
                                                    self.settings.NextPVR_USER,
                                                    self.settings.NextPVR_PW,
                                                    progDetails[
                                                        'recording_oid'],
                                                    choices[archiveSetting]):
                                                xbmc.log('file archived')
                                            else:
                                                xbmcgui.Dialog().ok(
                                                    smartUTF8(
                                                        __language__(30104)),
                                                    smartUTF8(
                                                        __language__(30105)))
                                        except:
                                            xbmcgui.Dialog().ok(
                                                smartUTF8(__language__(30104)),
                                                smartUTF8(__language__(30105)))

                            elif process_type == __language__(32003):
                                if progDetails['status'] == "Failed":
                                    ret = xbmcgui.Dialog().yesno(
                                        '%s %s' %
                                        (smartUTF8(__language__(30135)),
                                         progDetails['title']), '%s\n%s?' %
                                        (smartUTF8(__language__(30112)),
                                         progDetails['title']))
                                elif progDetails[
                                        'status'] != "In-Progress" and 'filename' in progDetails:
                                    ret = xbmcgui.Dialog().yesno(
                                        '%s %s' %
                                        (smartUTF8(__language__(30054)),
                                         progDetails['title']), '%s\n%s?' %
                                        (smartUTF8(__language__(30111)),
                                         progDetails['filename']))
                                else:
                                    break
                                self.returnvalue = "DEL"
                                if ret == 1:
                                    if self.xnewa.cancelRecording(
                                            self.settings.NextPVR_USER,
                                            self.settings.NextPVR_PW,
                                            progDetails):
                                        refresh = True

                            elif process_type == __language__(30054):
                                if deleteAll == None:
                                    ret = xbmcgui.Dialog().yesno(
                                        '%s %s' % (__language__(30054),
                                                   progDetails['title']),
                                        '%s %d %s?' %
                                        (__language__(30111), self.selections,
                                         'marked recording(s)'))
                                    if ret == 1:
                                        deleteAll = True
                                    else:
                                        deleteAll = False
                                if deleteAll == True:
                                    if self.xnewa.cancelRecording(
                                            self.settings.NextPVR_USER,
                                            self.settings.NextPVR_PW,
                                            progDetails):
                                        refresh = True
                                else:
                                    break
                            elif process_type == __language__(32004):
                                duration = progDetails['duration']
                                if duration == 0:
                                    duration = int(
                                        self.programsListBox.getListItem(
                                            i).getProperty('duration')) * 60
                                if duration > int(progDetails['resume']):
                                    retval = self.xnewa.setLibraryPlaybackPosition(
                                        progDetails['filename'], duration,
                                        duration)
                            elif process_type == __language__(30034):
                                if int(progDetails['resume']) != 0:
                                    duration = progDetails['duration']
                                    if duration == 0:
                                        duration = int(
                                            self.programsListBox.getListItem(i)
                                            .getProperty('duration')) * 60
                                    retval = self.xnewa.setLibraryPlaybackPosition(
                                        progDetails['filename'], 0, duration)
                            else:
                                xbmc.log('Unknown process type')

                            self.programsListBox.getListItem(i).select(False)
                            self.selections -= 1

        if refresh == True:
            self.xnewa.cleanCache('recentRecordings*.p')
            self.xnewa.cleanCache('summary.List')
            self.mode = 0
예제 #26
0
파일: recent.py 프로젝트: emveepee/X-NEWA
    def onClick(self, controlId):
        if controlId == programsListBoxId:
            self.goEditSchedule()
        elif controlId == refreshButtonId:
            self.xnewa.cleanCache('recentRecordings*.p')
            self.xnewa.cleanCache('summary.List')
            self.render()
        elif controlId == importButtonId:
            dialog = xbmcgui.Dialog()
            ret = dialog.yesno(smartUTF8(__language__(30127)), '%s %s' % (smartUTF8(__language__(30121)), self.recentData[self.programsListBox.getSelectedPosition()]['title']))
        elif controlId == actionButtonId:
            order = [__language__(30038),__language__(30039),__language__(32003),__language__(30054),__language__(32004),__language__(30033)]
            ret = xbmcgui.Dialog().select(__language__(32005), order);
            if ret > 0:
                self.processFile(order[ret])
                if self.selections > 0:
                    self.win.setProperty('tagged', 'true')
                else:
                    self.win.setProperty('tagged', 'false')
                if self.mode ==0:
                    self.render()

        elif controlId == filterButtonId:
            choices = list(self.xnewa.RecDirs.keys())
            if self.filterButton.isSelected():
                archive =  xbmcgui.Dialog().select(smartUTF8(__language__(30115)), choices)
                if archive != -1:
                    self.filtered = True
                    self.win.setProperty('archive', choices[archive])
                    self.recDir = self.xnewa.RecDirs[choices[archive]]
            else:
                self.recDir = None
                archive = 0
                self.win.setProperty('archive', __language__(30020))

            if archive != -1:
                self.xnewa.cleanCache('recentRecordings*.p')
                self.xnewa.cleanCache('summary.List')
                self.render()
        elif controlId == sortButtonId:
            order = [smartUTF8(__language__(30011)),smartUTF8(__language__(30148)),smartUTF8(__language__(30149)),__language__(32006)]
            ret = xbmcgui.Dialog().select(smartUTF8(__language__(30122)), order);
            if ret != -1:
                if ret == 0:
                    self.sortTitle[self.mode] = True
                    self.sortDate[self.mode] = True
                elif ret == 1:
                    self.sortTitle[self.mode] = False
                    self.sortDate[self.mode] = True
                elif ret == 2:
                    self.sortTitle[self.mode] = False
                    self.sortDate[self.mode] = False
                if self.mode == 0:
                    if ret != self.settings.XNEWA_SORT_RECORDING:
                        addon = Addon()
                        addon.setSetting(id='recordingSort',value=str(ret))
                        self.settings.XNEWA_SORT_RECORDING = ret
                        self.xnewa.cleanCache('summary.List')
                else:
                    if ret != self.settings.XNEWA_SORT_EPISODE:
                        addon = Addon()
                        addon.setSetting(id='episodeSort',value=str(ret))
                        self.settings.XNEWA_SORT_EPISODE = ret
                        self.xnewa.cleanCache('recentRecordings*.p')
                self.render()
예제 #27
0
파일: default.py 프로젝트: emveepee/X-NEWA
                        ew.doModal()
                    elif sys.argv[1] == "schedules":
                        from nextpvr.schedules import SchedulesWindow
                        sw = SchedulesWindow('nextpvr_schedules.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                        sw.doModal()
                    elif sys.argv[1] == "epg":
                        from nextpvr.epg import EpgWindow
                        ew = EpgWindow('nextpvr_epg.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                        ew.doModal()
                    elif sys.argv[1] == "recordings":
                        from nextpvr.recent import RecentRecordingsWindow
                        rw = RecentRecordingsWindow('nextpvr_recent.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                        rw.doModal()
                    else:
                        HomeWindow('nextpvr_home.xml', WHERE_AM_I, settings=my_settings, xnewa=my_xnewa).doModal()
                else:
                    HomeWindow('nextpvr_home.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa).doModal()
            else:
                ew = EmulateWindow("nextpvr_emulate.xml", WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
                ew.doModal()
        else:
            dialog = xbmcgui.Dialog()
            ok = dialog.ok('%s' % smartUTF8(__language__(30100)), '%s \n%s' % (smartUTF8(__language__(30101)), my_xnewa.ip))
    except:
        handleException()

    # remove other globals
    try:
        del dialogProgress
    except: pass
예제 #28
0
    def render(self, reload=True):
        if reload:
            myText = self._getText("%s:" % smartUTF8(__language__(30151)),"")
            if myText is None or myText == '':
                self.close()
                return
            xbmc.executebuiltin(XBMC_DIALOG_BUSY_OPEN)
            self.xnewa.cleanCache('search.List')
        else:
            myText = None

        listItems = []
        self.programsListBox.reset()
        self.win.setProperty('busy', 'true')

        if self.xnewa.AreYouThere(self.settings.usewol(), self.settings.NextPVR_MAC, self.settings.NextPVR_BROADCAST):
            try:
                self.searchData = self.xnewa.searchProgram(self.settings.NextPVR_USER, self.settings.NextPVR_PW, myText,self.option)
                previous = None
                if not self.searchData:
                    if reload == True:
                        self.win.setProperty('busy', 'false')
                        xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), smartUTF8(__language__(30123)))
                    self.win.setFocusId(250)
                else:
                    self.searchData = sorted(self.searchData, key = lambda x: (x['start']))
                    for i, t in enumerate(self.searchData):
                        if t['rec']:
                            self.win.setProperty('recording', 'true')
                        else:
                            self.win.setProperty('recording', '')
                        listItem = xbmcgui.ListItem('Row %d' % i)
                        airdate, previous = self.formattedAirDate(previous, self.xnewa.formatDate(t['start']))
                        listItem.setProperty('airdate', airdate)
                        listItem.setProperty('airdate_long',  self.xnewa.formatDate(t['start'], withyear=True))
                        listItem.setProperty('title', t['title'])
                        listItem.setProperty('start', self.xnewa.formatTime(t['start']))
                        listItem.setProperty('end', self.xnewa.formatTime(t['end']))
                        duration = ((t['end'] - t['start']).seconds) // 60
                        listItem.setProperty('duration', str(duration))
                        listItem.setProperty('channel', t['channel'][0])
                        listItem.setProperty('description', t['desc'])
                        listItem.setProperty('episode', t['subtitle'])
                        listItem.setProperty('oid', str(t['program_oid']))
                        listItems.append(listItem)
                    if len(listItems) > 0:
                        self.programsListBox.addItems(listItems)
                        self.win.setFocusId(600)
                    else:
                        self.win.setFocusId(999)

            except:
                self.win.setProperty('busy', 'false')
                xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))
            if reload:
                xbmc.executebuiltin(XBMC_DIALOG_BUSY_CLOSE)
            self.win.setProperty('busy', 'false')
        else:
            self.win.setProperty('busy', 'false')
            xbmcgui.Dialog().ok(smartUTF8(__language__(30108)), '%s!' % smartUTF8(__language__(30109)))
            self.close()