Beispiel #1
0
def start():
    player = myPlayer()

    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    if OLDVERSION != VERSION:
        #_zattooDB_.reloadDB(True)
        _zattooDB_.set_version(VERSION)

    import urllib
    #xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    _zattooDB_.cleanProg(True)

    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    _zattooDB_.updateChannels()

    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    _zattooDB_.updateProgram()

    try:
        tomorrow = datetime.datetime.today() + datetime.timedelta(days=1)
        _zattooDB_.updateProgram(tomorrow)
    except:
        pass

    startTime = datetime.datetime.now()  #-datetime.timedelta(minutes = 60)
    endTime = datetime.datetime.now() + datetime.timedelta(minutes=20)

    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    #xbmcgui.Dialog().notification(localString(31916), localString(30110),  __addon__.getAddonInfo('path') + '/icon.png', 3000, False)

    if __addon__.getSetting('dbonstart') == 'true':
        _zattooDB_.getProgInfo(True, startTime, endTime)
        recInfo()
        _library_.delete_library()  # add by samoth
        _library_.make_library()

    #xbmcgui.Dialog().notification(localString(31106), localString(31915),  __addon__.getAddonInfo('path') + '/icon.png', 3000, False)
    refreshProg()
def recInfo():
    import urllib
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()

    resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/playlist', None)
    if resultData is None: return
    for record in resultData['recordings']:
        _zattooDB_.getShowInfo(record['program_id'])
def getProgNextDay():
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()

    start = datetime.time(14, 0, 0)
    now = datetime.datetime.now().time()
    tomorrow = datetime.datetime.today() + datetime.timedelta(days=1)

    if now > start:
        #debug('NextDay ' + str(start) + ' - ' + str(now) + ' - ' + str(tomorrow))
        _zattooDB_.updateProgram(tomorrow)
    def onPlayBackStarted(self):
        from resources.lib.zattooDB import ZattooDB
        _zattooDB_ = ZattooDB()
        live = 'false'
        streams = xbmc.getInfoLabel('Player.Filenameandpath')
        showID = xbmc.getInfoLabel('VideoPlayer.Writer')
        channel = xbmc.getInfoLabel('VideoPlayer.Director')
        _zattooDB_.set_playing(channel, showID, streams, 0)

        # load Keymap for liveTV
        if streams.find('dash-live') > -1 or streams.find(
                'hls5-live') > -1 or streams.find(
                    'dashenc-live') > -1 or streams.find('hls7-live') > -1:
            live = 'true'
            self.loadKeymap()
        else:
            self.unloadKeymap()

        ret = xbmcgui.Window(12005).getProperty('after_recall')

        if ret == "2":
            program = _zattooDB_.get_showID(showID)
            nextprog = _zattooDB_.getPrograms(
                {'index': [channel]}, True,
                program[0]['end_date'] + datetime.timedelta(seconds=20),
                program[0]['end_date'] + datetime.timedelta(seconds=50))
            debug('Nextprog' + str(nextprog))
            start = to_seconds(nextprog[0]['start_date']) + 60
            now = to_seconds(datetime.datetime.now())
            while start > to_seconds(datetime.datetime.now()):
                xbmc.sleep(100)
            channel = nextprog[0]['channel']
            showID = nextprog[0]['showID']
            add = 'true'
            restart = 'true'
            start = 0
            end = 0
            xbmc.executebuiltin('RunPlugin("plugin://' + __addonId__ +
                                '/?mode=watch_c&id=' + channel + '&showID=' +
                                showID + '&restart=' + restart + '&add=' +
                                add + '")')
        elif ret == "1" and live == 'false':
            add = 'true'
            restart = 'false'
            showID = '1'
            end = 0
            start = 0
            xbmc.executebuiltin('RunPlugin("plugin://' + __addonId__ +
                                '/?mode=watch_c&id=' + channel + '&add=' +
                                add + '")')
def recInfo():
    import urllib.request, urllib.parse, urllib.error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    try:
        if accountData['nonlive']['recording_number_limit'] > 0:
            resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/playlist', None)
            if resultData is None: return
            for record in resultData['recordings']:
                _zattooDB_.getShowInfo(record['program_id'])
            _library_.delete_library()  # add by samoth
            _library_.make_library()
    except:
        return
def refreshProg():
    import urllib
    monitor = xbmc.Monitor()
    while not monitor.abortRequested():
        if monitor.waitForAbort(600): break
        from resources.lib.zattooDB import ZattooDB
        _zattooDB_ = ZattooDB()
        #update programInfo
        startTime = datetime.datetime.now()
        endTime = datetime.datetime.now() + datetime.timedelta(minutes=120)

        try:
            getProgNextDay()
            _zattooDB_.getProgInfo(False, startTime, endTime, 'all')
        except:
            pass
    def showChannels(self):
        start = int(self.selected / 16) * 16
        channels = self.channels
        self.programms = ZattooDB().getPrograms(channels, False,
                                                datetime.datetime.now(),
                                                datetime.datetime.now())

        #xbmcgui.lock()
        for nr in range(0, 16):
            current = start + nr
            control = self.controls[nr]

            if current > (len(channels) - 2):  #-2: skip channel['index']
                control['image'].setVisible(False)
                control['logo'].setVisible(False)
                control['label'].setVisible(False)
                control['channelNr'].setVisible(False)
                control['visible'] = False
            else:
                currenChannel = channels[channels['index'][current]]
                title = ''
                control['program'] = ''
                for search in self.programms:
                    if search['channel'] == currenChannel['id']:
                        title = search['title']
                        control['program'] = search
                        break

                control['logo'].setImage(currenChannel['logo'])
                control['label'].setLabel(title)
                control['channelNr'].setLabel(str(current + 1))
                control['channel'] = currenChannel['id']
                if control['visible'] == False:
                    control['image'].setVisible(True)
                    control['logo'].setVisible(True)
                    control['label'].setVisible(True)
                    control['channelNr'].setVisible(True)
                    control['visible'] = True

        #show images
        now = int(time.time())
        for control in self.controls:
            if control['visible']:
                #src = 'http://thumb.zattic.com/' + control['channel'] + '/500x288.jpg?r=' + str(now)
                src = 'http://thumb.zattic.com/' + control[
                    'channel'] + '/256x144.jpg?r=' + str(now)
                control['image'].setImage(src, False)
Beispiel #8
0
    def onPlayBackStarted(self):
        from resources.lib.zattooDB import ZattooDB
        _zattooDB_ = ZattooDB()
        live = 'false'
        streams = xbmc.getInfoLabel('Player.Filenameandpath')
        showID = xbmc.getInfoLabel('VideoPlayer.Writer')
        channel = xbmc.getInfoLabel('VideoPlayer.Director')
        _zattooDB_.set_playing(channel, showID, streams, 0)

        # load Keymap for liveTV
        if streams.find('dash-live') > -1 or streams.find(
                'hls5-live') > -1 or streams.find(
                    'dashenc-live') > -1 or streams.find('hls7-live') > -1:
            live = 'true'
            self.loadKeymap()
        else:
            self.unloadKeymap()
Beispiel #9
0
    def onInit(self):
        self.db = ZattooDB()
        control = self.getControl(self.C_MAIN_EPG_VIEW_MARKER)
        if control:
            left, top = control.getPosition()
            self.focusPoint.x = left
            self.focusPoint.y = top
            self.epgView.left = left
            self.epgView.top = top
            self.epgView.right = left + control.getWidth()
            self.epgView.bottom = top + control.getHeight()
            self.epgView.width = control.getWidth()
            self.epgView.cellHeight = control.getHeight() / CHANNELS_PER_PAGE

            # draw epg on open
            self.onRedrawEPG(self.channelIdx, self.viewStartDate)

#        self.notification = Notification(self.database, ADDON.getAddonInfo('path')+'/resources/epg')
        self.updateTimebar()
                
        self.getControl(4400).setVisible(False)
        self.getControl(4401).setVisible(True)
Beispiel #10
0
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with zattooHiQ.  If not, see <http://www.gnu.org/licenses/>.
#

import xbmc, xbmcgui, xbmcplugin, xbmcaddon
import sys, urlparse
import time, datetime, threading
from resources.lib.zattooDB import ZattooDB

__addon__ = xbmcaddon.Addon()
__addonId__ = __addon__.getAddonInfo('id')
__addonname__ = __addon__.getAddonInfo('name')
_zattooDB_ = ZattooDB()

_timezone_ = int(
    __addon__.getSetting('time_offset')) * 60 * -60  #-time.altzone

DEBUG = __addon__.getSetting('debug')


def debug(s):
    if DEBUG: xbmc.log(str(s), xbmc.LOGDEBUG)


class library:
    def make_library(self):
        folder = __addon__.getSetting('library_dir')
        if folder == '': return
def start():
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    # reload Account
    xbmcgui.Dialog().notification(
        localString(30104), localString(31024),
        __addon__.getAddonInfo('path') + '/resources/icon.png', 500, False)
    profilePath = xbmc.translatePath(__addon__.getAddonInfo('profile'))
    os.remove(os.path.join(profilePath, 'cookie.cache'))
    os.remove(os.path.join(profilePath, 'session.cache'))
    os.remove(os.path.join(profilePath, 'account.cache'))
    _zattooDB_.zapiSession()

    player = myPlayer()
    VERSION = __addon__.getAddonInfo('version')
    OLDVERSION = _zattooDB_.get_version(VERSION)

    if OLDVERSION != VERSION:

        # reload DB
        _zattooDB_.reloadDB()
        # set Version
        _zattooDB_.set_version(VERSION)

    import urllib
    #xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    _zattooDB_.cleanProg(True)

    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    _zattooDB_.updateChannels()

    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    _zattooDB_.updateProgram()

    try:
        tomorrow = datetime.datetime.today() + datetime.timedelta(days=1)
        _zattooDB_.updateProgram(tomorrow)
    except:
        pass

    startTime = datetime.datetime.now()  #-datetime.timedelta(minutes = 60)
    endTime = datetime.datetime.now() + datetime.timedelta(minutes=20)

    #re-import ZattooDB to prevent "convert_timestamp" error
    from resources.lib.zattooDB import ZattooDB
    _zattooDB_ = ZattooDB()
    #xbmcgui.Dialog().notification(localString(31916), localString(30110),  __addon__.getAddonInfo('path') + '/icon.png', 3000, False)

    if __addon__.getSetting('dbonstart') == 'true':
        _zattooDB_.getProgInfo(True, startTime, endTime)
        recInfo()

    #xbmcgui.Dialog().notification(localString(31106), localString(31915),  __addon__.getAddonInfo('path') + '/icon.png', 3000, False)
    refreshProg()
Beispiel #12
0
 def _showDescription(self, id):
     description = ZattooDB().getShowInfo(id,'description')
     if description == '': description = strings(NO_DESCRIPTION)
     self.setControlText(self.C_MAIN_DESCRIPTION, description)
    def showInfo(self, jump=True):
        controlNr = self.selected % 16

        endPos = self.getControlPos(controlNr)
        if (not jump):
            #moving highlight
            pos = self.highlightImage.getPosition()
            stepX = (endPos['x'] - pos[0]) / 5
            stepY = (endPos['y'] - pos[1]) / 5

            for nr in range(1, 5):
                self.highlightImage.setPosition(pos[0] + (stepX * nr),
                                                pos[1] + (stepY * nr))
                xbmc.sleep(10)
        self.highlightImage.setPosition(endPos['x'], endPos['y'])

        #refresh image
        if hasattr(self, 'refreshImageTimer'): self.refreshImageTimer.cancel()
        src = 'http://thumb.zattic.com/' + self.controls[controlNr][
            'channel'] + '/256x144.jpg?r=' + str(int(time.time()))
        self.refreshImageTimer = threading.Timer(
            1, lambda: self.controls[controlNr]['image'].setImage(src, False))
        self.refreshImageTimer.start()

        #program= self.controls[controlNr]['program']

        program = ZattooDB().getPrograms(
            {'index': [self.controls[controlNr]['channel']]}, False,
            datetime.datetime.now(), datetime.datetime.now())[0]
        nextprog = ZattooDB().getPrograms(
            {'index': [self.controls[controlNr]['channel']]}, False,
            program['end_date'] + datetime.timedelta(seconds=60),
            program['end_date'] + datetime.timedelta(seconds=60))

        self.controls[controlNr]['label'].setLabel('')
        self.highLabel = program['title']
        self.scrollLabel.reset()
        self.scrollLabel.setPosition(endPos['x'] + 6, endPos['y'] + 149)
        self.scrollLabel.addLabel(program['title'])

        #update info
        channel = self.channels[self.channels['index'][self.selected]]
        self.infoLogo.setImage(channel['logo'], False)

        self.infoTitle.reset()
        self.infoDesc.reset()
        self.infoNext.reset()

        if (not program):
            self.infoChannelTitle.setLabel('[B]' + channel['title'] +
                                           '[/B]\n ')
            self.infoTitle.addLabel('[B] [/B]')
            self.infoImg.setImage('')
            self.infoDesc.addLabel('[B] [/B]')
            self.infoPlot.setText('')
            self.infoNext.addLabel('')

        else:
            self.infoChannelTitle.setLabel(
                '[B]' + channel['title'] + '[/B]\n' +
                program['start_date'].strftime('%H:%M') + ' - ' +
                program['end_date'].strftime('%H:%M'))
            self.infoTitle.addLabel('[B]' + program['title'] + '[/B]')
            self.infoImg.setImage(program['image_small'], False)
            self.infoNext.addLabel(
                '[COLOR blue]' + localString(30010) + '[/COLOR]' +
                '[COLOR aquamarine]' + nextprog[0]['title'] + '[/COLOR]' +
                '  ' + '[COLOR khaki]' +
                nextprog[0]['start_date'].strftime('%H:%M') + ' - ' +
                nextprog[0]['end_date'].strftime('%H:%M') + '[/COLOR]')

            desc = program['description']
            if (not desc): desc = " "
            self.infoDesc.addLabel('[B]' + desc + '[/B]')

            plot = self.db.getShowInfo(program['showID'], 'description')
            if (not plot): plot = "No description "
            self.infoPlot.setText(plot)
    def createPreview(self, fav):
        imgW = 256
        imgH = 150
        # collect all controls and add them in one call to save time
        allControls = []
        # create preview images first so they are behind highlight image
        images = []

        for nr in range(0, 16):
            pos = self.getControlPos(nr)
            image = xbmcgui.ControlImage(pos['x'], pos['y'] + 1, imgW - 2,
                                         imgH, '')
            allControls.append(image)
            images.append(image)

        self.highlightImage = xbmcgui.ControlImage(0, 0, imgW, 178, '')
        allControls.append(self.highlightImage)
        self.highLabel = ''

        #add a scroll label for highlighted item
        self.scrollLabel = xbmcgui.ControlFadeLabel(0, 0, 240, 30, 'font13',
                                                    '0xFF000000')
        allControls.append(self.scrollLabel)

        #preloadImage is buffer for image update
        self.preloadImage = xbmcgui.ControlImage(0, -200, 256, 150, '')
        allControls.append(self.preloadImage)

        for nr in range(0, 16):
            pos = self.getControlPos(nr)
            logo = xbmcgui.ControlImage(pos['x'] + 5, pos['y'] + 100, 84, 48,
                                        '')
            label = xbmcgui.ControlLabel(pos['x'] + 6, pos['y'] + imgH - 1,
                                         250, 30, 'font13')
            channelNr = xbmcgui.ControlLabel(pos['x'] + 200,
                                             pos['y'] + 5,
                                             50,
                                             20,
                                             'font13',
                                             alignment=1)

            allControls.append(logo)
            allControls.append(label)
            allControls.append(channelNr)

            self.controls.append({
                'image': images[nr],
                'logo': logo,
                'label': label,
                'channelNr': channelNr,
                'program': '',
                'visible': True
            })

        addonPath = xbmcaddon.Addon().getAddonInfo('path')

        #add info controls
        posX = 768
        #bg = xbmcgui.ControlImage(posX-10, -10, 530, 376, 'recentaddedback.png')
        #bg = xbmcgui.ControlImage(posX, 0, 512, 360, 'ContentPanel.png')
        #bg = xbmcgui.ControlImage(posX, 0, 512, 360, 'episodematte.png', colorDiffuse='0xFF333333')
        bg = xbmcgui.ControlImage(
            posX, 0, 512, 360, addonPath + '/resources/media/previewInfo.png')

        self.infoLogo = xbmcgui.ControlImage(
            74 + posX, 5, 140, 70, (xbmcaddon.Addon().getAddonInfo('path') +
                                    '/resources/media/channel-highlight.png'))
        self.infoChannelTitle = xbmcgui.ControlLabel(0 + posX,
                                                     85,
                                                     287,
                                                     30,
                                                     'TITLE',
                                                     alignment=2)
        self.infoImg = xbmcgui.ControlImage(
            284 + posX, 3, 225, 146,
            (xbmcaddon.Addon().getAddonInfo('path') +
             '/resources/media/channel-highlight.png'))

        self.infoTitle = xbmcgui.ControlFadeLabel(5 + posX, 150, 500, 20,
                                                  'font16', '0xFFFFFFFF', 2)
        self.infoDesc = xbmcgui.ControlFadeLabel(5 + posX, 180, 500, 20,
                                                 'font13', '0xFFFFFFFF', 2)
        self.infoPlot = xbmcgui.ControlTextBox(8 + posX, 205, 500, 128,
                                               'font13')
        self.infoNext = xbmcgui.ControlFadeLabel(8 + posX, 333, 500, 128,
                                                 'font12', '0xFFFFFFFF', 2)

        allControls.append(bg)
        allControls.append(self.infoLogo)
        allControls.append(self.infoChannelTitle)
        allControls.append(self.infoImg)
        allControls.append(self.infoTitle)
        allControls.append(self.infoDesc)
        allControls.append(self.infoPlot)
        allControls.append(self.infoNext)

        self.addControls(allControls)
        self.highlightImage.setImage(addonPath +
                                     '/resources/media/channel-highlight.png')
        self.infoPlot.autoScroll(5000, 1800, 5000)

        self.db = ZattooDB()
        if fav == 'popular': self.channels = self.db.getPopularList()
        else: self.channels = self.db.getChannelList(fav)
    def __init__(self):
        super(Teletext, self).__init__()

        self.channelID = ZattooDB().get_playing()['channel']

        self.imagePath = ''
        self.pageInput = ''

        self.bgImage = xbmcgui.ControlImage(0, 0, 1280, 720, '')
        self.addControl(self.bgImage)
        self.bgImage.setImage(
            __addon__.getAddonInfo('path') + '/resources/media/teletextBG.png')

        self.pageInputCtrl = xbmcgui.ControlLabel(0,
                                                  0,
                                                  265,
                                                  100,
                                                  '100',
                                                  font='font30',
                                                  alignment=2)
        self.addControl(self.pageInputCtrl)
        self.pageInputCtrl.setVisible(False)

        self.pageImage = xbmcgui.ControlImage(260, 0, 800, 720, "")
        self.addControl(self.pageImage)

        self.button0 = xbmcgui.ControlButton(50,
                                             640,
                                             170,
                                             40,
                                             localString(31912),
                                             font='font20',
                                             alignment=6)
        self.addControl(self.button0)

        self.button1 = xbmcgui.ControlButton(1090,
                                             640,
                                             60,
                                             40,
                                             "<",
                                             font='font30',
                                             alignment=6)
        self.addControl(self.button1)

        self.button2 = xbmcgui.ControlButton(1180,
                                             640,
                                             60,
                                             40,
                                             ">",
                                             font='font30',
                                             alignment=6)
        self.addControl(self.button2)

        self.button3 = xbmcgui.ControlButton(50,
                                             580,
                                             60,
                                             40,
                                             "<",
                                             font='font30',
                                             alignment=6)
        self.addControl(self.button3)

        self.button4 = xbmcgui.ControlButton(1180,
                                             40,
                                             60,
                                             40,
                                             "X",
                                             font='font30',
                                             alignment=6)
        self.addControl(self.button4)

        self.button5 = xbmcgui.ControlButton(160,
                                             580,
                                             60,
                                             40,
                                             ">",
                                             font='font30',
                                             alignment=6)
        self.addControl(self.button5)

        self.button6 = xbmcgui.ControlButton(50,
                                             520,
                                             60,
                                             40,
                                             "<<",
                                             font='font30',
                                             alignment=6)
        self.addControl(self.button6)

        self.button7 = xbmcgui.ControlButton(160,
                                             520,
                                             60,
                                             40,
                                             ">>",
                                             font='font30',
                                             alignment=6)
        self.addControl(self.button7)

        self.currentPage = 100
        self.subPage = 1
        self.showPage(str(self.currentPage))  #, str(self.subPage))