示例#1
0
文件: seeker.py 项目: mx3L/archivczsk
 def _errorSearch(self, failure):
     showErrorMessage(self.session, _('Error while trying to retrieve search list'), 5)
     if self.searcher is not None:
         self.searcher.close()
         self.searcher = None
     self.searching = False
     self.addon = None
     if self.cb:
         self.cb()
示例#2
0
 def _errorSearch(self, failure):
     showErrorMessage(self.session, _('Error while trying to retrieve search list'), 5)
     if self.searcher is not None:
         self.searcher.close()
         self.searcher = None
     self.searching = False
     self.addon = None
     if self.cb:
         self.cb()
示例#3
0
 def open_item_success_cb(result):
     log.logDebug("Trakt (%s) call success. %s" % (action, result))
     list_items, command, args = result
     if command is not None and command.lower() == 'result_msg':
         #{'msg':msg, 'isError':isError}
         if args['isError']:
             showErrorMessage(self.session, args['msg'], 10, finishCb)
         else:
             showInfoMessage(self.session, args['msg'], 10, finishCb)
     else:
         finishCb(None)
示例#4
0
 def getInstance(session, cb=None):
     if ArchivCZSKSeeker.instance is None:
         try:
             return ArchivCZSKSeeker(session, cb)
         except ImportError:
             showInfoMessage(session, _('Cannot search, archivCZSK is not installed'), 5, cb=cb)
             print 'cannot found archivCZSK'
             return None
         except Exception:
             traceback.print_exc()
             showErrorMessage(session, _('unknown error'), 5, cb=cb)
             return None
     return ArchivCZSKSeeker.instance
示例#5
0
 def getInstance(session, cb=None):
     if ArchivCZSKSeeker.instance is None:
         try:
             return ArchivCZSKSeeker(session, cb)
         except ImportError:
             log.logError("Cannot search, archivCZSK is not installed")
             showInfoMessage(session, _('Cannot search, archivCZSK is not installed'), 5, cb=cb)
             print 'cannot found archivCZSK'
             return None
         except Exception:
             log.logError("ArchivCZSKSeeker fatala error.\n%s"%traceback.format_exc())
             traceback.print_exc()
             showErrorMessage(session, _('unknown error'), 5, cb=cb)
             return None
     return ArchivCZSKSeeker.instance
示例#6
0
 def showMsg(self, msgId, showSec, canClose=True, isError=True):
     try:
         msgType = "error"
         if not isError:
             msgType = "info"
         client.add_operation("SHOW_MSG", {
                                             'msg': self._getName(msgId),
                                             'msgType': msgType,
                                             'msgTimeout': showSec,
                                             'canClose': canClose
                                          })
     except:
         orangelog.logError("showMsg failed (minimalna verzia archivCZSK 1.1.2).\n%s"%traceback.format_exc())
         from Plugins.Extensions.archivCZSK.gui.common import showErrorMessage
         showErrorMessage(self.session, ("ERRmsg - %s"%self._getName(msgId)), showSec)
         pass
示例#7
0
 def open_item_success_cb(result):
     log.logDebug("Trakt (%s) call success. %s"%(action, result))
     #OK, ERROR
     list_items, command, args = result
     if args['isError']:
         return showErrorMessage(self.session, args['msg'], 10, finishCb)
     else:
         return showInfoMessage(self.session, args['msg'], 10, finishCb)
示例#8
0
        def open_item_success_cb(result):
            def continue_cb(res):
                list_items.insert(0, PExit())
                self.content_screen.resolveCommand(command, args)
                self.content_screen.stopLoading()
                self.open_video_addon(item.addon, list_items)

            list_items, command, args = result
            try:
                #client.add_operation("SHOW_MSG", {'msg': 'some text'},
                #                                  'msgType': 'info|error|warning',     #optional
                #                                  'msgTimeout': 10,                    #optional
                #                                  'canClose': True                     #optional
                #                                 })

                if command is not None:
                    cmd = ("%s" % command).lower()
                    params = args
                    if cmd == "show_msg":
                        #dialogStart = datetime.datetime.now()
                        self.content_screen.stopLoading()
                        msgType = 'info'
                        if 'msgType' in args:
                            msgType = ("%s" % args['msgType']).lower()
                        msgTimeout = 15
                        if 'msgTimeout' in args:
                            msgTimeout = int(args['msgTimeout'])
                        canClose = True
                        if 'canClose' in args:
                            canClose = args['canClose']
                        if msgType == 'error':
                            return showErrorMessage(self.session,
                                                    args['msg'],
                                                    msgTimeout,
                                                    continue_cb,
                                                    enableInput=canClose)
                        if msgType == 'warning':
                            return showWarningMessage(self.session,
                                                      args['msg'],
                                                      msgTimeout,
                                                      continue_cb,
                                                      enableInput=canClose)
                        return showInfoMessage(self.session,
                                               args['msg'],
                                               msgTimeout,
                                               continue_cb,
                                               enableInput=canClose)
            except:
                log.logError(
                    "Execute HACK command failed (addon handler).\n%s" %
                    traceback.format_exc())
                command = None
                args = {}

            list_items.insert(0, PExit())
            self.content_screen.resolveCommand(command, args)
            self.content_screen.stopLoading()
            self.open_video_addon(item.addon, list_items)
示例#9
0
            def pairTrakt_cb(res):
                import json
                import urllib2
                from Plugins.Extensions.archivCZSK.settings import USER_AGENT

                def post_json(url, data, headers={}):
                    postdata = json.dumps(data)
                    headers['Content-Type'] = 'application/json'
                    req = urllib2.Request(url, postdata, headers)
                    req.add_header('User-Agent', USER_AGENT)
                    response = urllib2.urlopen(req)
                    data = response.read()
                    response.close()
                    return data

                try:
                    data = json.loads(
                        post_json(params['trakt']['url'],
                                  data={
                                      'code':
                                      params['trakt']['code'],
                                      'client_id':
                                      params['trakt']['client_id'],
                                      'client_secret':
                                      params['trakt']['client_secret']
                                  },
                                  headers={'Content-Type':
                                           'application/json'}))
                    TOKEN = data['access_token']
                    REFRESH_TOKEN = data['refresh_token']
                    expire = data['expires_in']  #seconds
                    created = data['created_at']
                    EXPIRE = expire + created

                    log.logDebug(
                        "Get token return token=%s, rtoken=%s, exp=%s" %
                        (TOKEN, REFRESH_TOKEN, EXPIRE))

                    #update settings
                    self.content_provider.video_addon.set_setting(
                        params['settings']['token'], '%s' % TOKEN)
                    self.content_provider.video_addon.set_setting(
                        params['settings']['refreshToken'],
                        '%s' % REFRESH_TOKEN)
                    self.content_provider.video_addon.set_setting(
                        params['settings']['expire'], '%s' % EXPIRE)

                    return showInfoMessage(self.session,
                                           params['msg']['success'], 20,
                                           continue_cb)
                except:
                    log.logDebug("Pair trakt failed.\n%s" %
                                 traceback.format_exc())
                return showErrorMessage(self.session, params['msg']['fail'],
                                        20, continue_cb)
示例#10
0
 def showMsg(self, msgId, showSec, canClose=True, isError=True):
     try:
         msgType = "error"
         #if not isError:
         #    msgType = "info"
         client.add_operation(
             "SHOW_MSG", {
                 'msg': self._getName(msgId),
                 'msgType': msgType,
                 'msgTimeout': showSec,
                 'canClose': canClose
             })
     except:
         o2log.logError(
             "showMsg failed (minimalna verzia archivCZSK 1.1.2).\n%s" %
             traceback.format_exc())
         from Plugins.Extensions.archivCZSK.gui.common import showErrorMessage
         showErrorMessage(self.session,
                          ("ERRmsg - %s" % self._getName(msgId)), showSec)
         pass
示例#11
0
文件: addon.py 项目: mx3L/archivczsk
        def open_item_success_cb(result):
            def continue_cb(res):
                list_items.insert(0, PExit())
                self.content_screen.resolveCommand(command, args)
                self.content_screen.stopLoading()
                self.open_video_addon(item.addon, list_items)

            list_items, command, args = result
            try:
                #client.add_operation("SHOW_MSG", {'msg': 'some text'},
                #                                  'msgType': 'info|error|warning',     #optional
                #                                  'msgTimeout': 10,                    #optional
                #                                  'canClose': True                     #optional
                #                                 })

                if command is not None:
                   cmd = ("%s"%command).lower()
                   params = args
                   if cmd == "show_msg":
                       #dialogStart = datetime.datetime.now()
                       self.content_screen.stopLoading()
                       msgType = 'info'
                       if 'msgType' in args:
                           msgType = ("%s"%args['msgType']).lower()
                       msgTimeout = 15
                       if 'msgTimeout' in args:
                           msgTimeout = int(args['msgTimeout'])
                       canClose = True
                       if 'canClose' in args:
                           canClose = args['canClose']
                       if msgType == 'error':
                           return showErrorMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose)
                       if msgType == 'warning':
                           return showWarningMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose)
                       return showInfoMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose)
            except:
                log.logError("Execute HACK command failed (addon handler).\n%s"%traceback.format_exc())
                command = None
                args = {}

            list_items.insert(0, PExit())
            self.content_screen.resolveCommand(command, args)
            self.content_screen.stopLoading()
            self.open_video_addon(item.addon, list_items)
示例#12
0
 def open_item_error_cb(failure):
     log.logDebug("Trakt (%s) call failed. %s" % (action, failure))
     showErrorMessage(self.session, "Operation failed.", 5, finishCb)
示例#13
0
        def open_item_success_cb(result):
            def continue_cb(res):
                list_items = []
                args = {}
                list_items.insert(0, PExit())
                self.content_screen.startLoading()
                if not self.content_screen.refreshing:
                    self.content_screen.save()
                else:
                    self.content_screen.refreshing = False

                if self.is_search(item):
                    parent_content = self.content_screen.getParent()
                    if parent_content:
                        parent_content['refresh'] = True

                content = {
                    'parent_it': item,
                    'lst_items': list_items,
                    'refresh': False,
                    'index': kwargs.get('position', 0)
                }
                self.content_screen.load(content)
                self.content_screen.stopLoading()
                self.content_screen.showList()
                self.content_screen.workingFinished()

            def pairTrakt_cb(res):
                import json
                import urllib2
                from Plugins.Extensions.archivCZSK.settings import USER_AGENT

                def post_json(url, data, headers={}):
                    postdata = json.dumps(data)
                    headers['Content-Type'] = 'application/json'
                    req = urllib2.Request(url, postdata, headers)
                    req.add_header('User-Agent', USER_AGENT)
                    response = urllib2.urlopen(req)
                    data = response.read()
                    response.close()
                    return data

                try:
                    data = json.loads(
                        post_json(params['trakt']['url'],
                                  data={
                                      'code':
                                      params['trakt']['code'],
                                      'client_id':
                                      params['trakt']['client_id'],
                                      'client_secret':
                                      params['trakt']['client_secret']
                                  },
                                  headers={'Content-Type':
                                           'application/json'}))
                    TOKEN = data['access_token']
                    REFRESH_TOKEN = data['refresh_token']
                    expire = data['expires_in']  #seconds
                    created = data['created_at']
                    EXPIRE = expire + created

                    log.logDebug(
                        "Get token return token=%s, rtoken=%s, exp=%s" %
                        (TOKEN, REFRESH_TOKEN, EXPIRE))

                    #update settings
                    self.content_provider.video_addon.set_setting(
                        params['settings']['token'], '%s' % TOKEN)
                    self.content_provider.video_addon.set_setting(
                        params['settings']['refreshToken'],
                        '%s' % REFRESH_TOKEN)
                    self.content_provider.video_addon.set_setting(
                        params['settings']['expire'], '%s' % EXPIRE)

                    return showInfoMessage(self.session,
                                           params['msg']['success'], 20,
                                           continue_cb)
                except:
                    log.logDebug("Pair trakt failed.\n%s" %
                                 traceback.format_exc())
                return showErrorMessage(self.session, params['msg']['fail'],
                                        20, continue_cb)

            def continue_cb_normal(res):
                if not list_items and screen_command is not None:
                    self.content_screen.resolveCommand(screen_command, args)
                else:
                    list_items.insert(0, PExit())
                    if screen_command is not None:
                        self.content_screen.resolveCommand(
                            screen_command, args)

                    if not self.content_screen.refreshing:
                        self.content_screen.save()
                    else:
                        self.content_screen.refreshing = False

                    if self.is_search(item):
                        parent_content = self.content_screen.getParent()
                        if parent_content:
                            parent_content['refresh'] = True

                    content = {
                        'parent_it': item,
                        'lst_items': list_items,
                        'refresh': False,
                        'index': kwargs.get('position', 0)
                    }
                    self.content_screen.load(content)
                    self.content_screen.stopLoading()
                    self.content_screen.showList()
                    self.content_screen.workingFinished()

            list_items, screen_command, args = result

            try:
                #client.add_operation("TRAKT_PAIR", {'trakt': {'url':self.tapi.API+'/token',
                #                                                      'code':self.code,
                #                                                      'client_id':self.tapi.CLIENT_ID,
                #                                                      'client_secret': self.tapi.CLIENT_SECRET},
                #                                    'msg': {'pair': msg, 'success':succ, 'fail':fail},
                #                                    'settings': {'token': 'trakt_token',
                #                                                 'refreshToken':'trakt_refresh_token',
                #                                                 'expire':'trakt_token_expire'}})
                #client.add_operation("SHOW_MSG", {'msg': 'some text'},
                #                                  'msgType': 'info|error|warning',     #optional
                #                                  'msgTimeout': 10,                    #optional
                #                                  'canClose': True                     #optional
                #                                 })

                if screen_command is not None:
                    cmd = ("%s" % screen_command).lower()
                    params = args
                    if cmd == "trakt_pair":
                        self.content_screen.stopLoading()
                        return showInfoMessage(self.session,
                                               args['msg']['pair'], -1,
                                               pairTrakt_cb)
                    if cmd == "show_msg":
                        #dialogStart = datetime.datetime.now()
                        self.content_screen.stopLoading()
                        msgType = 'info'
                        if 'msgType' in args:
                            msgType = ("%s" % args['msgType']).lower()
                        msgTimeout = 15
                        if 'msgTimeout' in args:
                            msgTimeout = int(args['msgTimeout'])
                        canClose = True
                        if 'canClose' in args:
                            canClose = args['canClose']
                        if msgType == 'error':
                            return showErrorMessage(self.session,
                                                    args['msg'],
                                                    msgTimeout,
                                                    continue_cb_normal,
                                                    enableInput=canClose)
                        if msgType == 'warning':
                            return showWarningMessage(self.session,
                                                      args['msg'],
                                                      msgTimeout,
                                                      continue_cb_normal,
                                                      enableInput=canClose)
                        return showInfoMessage(self.session,
                                               args['msg'],
                                               msgTimeout,
                                               continue_cb_normal,
                                               enableInput=canClose)
            except:
                log.logError("Execute HACK command failed.\n%s" %
                             traceback.format_exc())
                screen_command = None
                args = {}

            if not list_items and screen_command is not None:
                self.content_screen.resolveCommand(screen_command, args)
            else:
                list_items.insert(0, PExit())
                if screen_command is not None:
                    self.content_screen.resolveCommand(screen_command, args)

                if not self.content_screen.refreshing:
                    self.content_screen.save()
                else:
                    self.content_screen.refreshing = False

                if self.is_search(item):
                    parent_content = self.content_screen.getParent()
                    if parent_content:
                        parent_content['refresh'] = True

                content = {
                    'parent_it': item,
                    'lst_items': list_items,
                    'refresh': False,
                    'index': kwargs.get('position', 0)
                }
                self.content_screen.load(content)
                self.content_screen.stopLoading()
                self.content_screen.showList()
                self.content_screen.workingFinished()
示例#14
0
文件: media.py 项目: mx3L/archivczsk
 def open_item_error_cb(failure):
     log.logDebug("Trakt (%s) call failed. %s"%(action,failure))
     return showErrorMessage(self.session, "Operation failed.", 10, finishCb)
示例#15
0
        def open_item_success_cb(result):
            def continue_cb(res):
                self._filter_by_quality(list_items)
                if len(list_items) > 1:
                    choices = []
                    for i in list_items:
                        name = i.name
                        # TODO remove workaround of embedding
                        # quality in title in addons
                        if i.quality and i.quality not in i.name:
                            if "[???]" in i.name:
                                name = i.name.replace("[???]","[%s]"%(i.quality))
                            else:
                                name = "[%s] %s"%(i.quality, i.name)
                        choices.append((toString(name), i))
                    self.session.openWithCallback(selected_source,
                            ChoiceBox, _("Please select source"),
                            list = choices,
                            skin_name = ["ArchivCZSKVideoSourceSelection"])
                elif len(list_items) == 1:
                    item = list_items[0]
                    callback(item)
                else: # no video
                    self.content_screen.workingFinished()

            self.content_screen.stopLoading()
            self.content_screen.showList()
            list_items, command, args = result

            try:
                #client.add_operation("SHOW_MSG", {'msg': 'some text'},
                #                                  'msgType': 'info|error|warning',     #optional
                #                                  'msgTimeout': 10,                    #optional
                #                                  'canClose': True                     #optional
                #                                 })

                if command is not None:
                   cmd = ("%s"%command).lower()
                   params = args
                   if cmd == "show_msg":
                       #dialogStart = datetime.datetime.now()
                       self.content_screen.stopLoading()
                       msgType = 'info'
                       if 'msgType' in args:
                           msgType = ("%s"%args['msgType']).lower()
                       msgTimeout = 15
                       if 'msgTimeout' in args:
                           msgTimeout = int(args['msgTimeout'])
                       canClose = True
                       if 'canClose' in args:
                           canClose = args['canClose']
                       if msgType == 'error':
                           return showErrorMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose)
                       if msgType == 'warning':
                           return showWarningMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose)
                       return showInfoMessage(self.session, args['msg'], msgTimeout, continue_cb, enableInput=canClose)
            except:
                log.logError("Execute HACK command failed (media handler).\n%s"%traceback.format_exc())
                command = None
                args = {}

            self._filter_by_quality(list_items)
            if len(list_items) > 1:
                choices = []
                for i in list_items:
                    name = i.name
                    # TODO remove workaround of embedding
                    # quality in title in addons
                    if i.quality and i.quality not in i.name:
                        if "[???]" in i.name:
                            name = i.name.replace("[???]","[%s]"%(i.quality))
                        else:
                            name = "[%s] %s"%(i.quality, i.name)
                    choices.append((toString(name), i))
                self.session.openWithCallback(selected_source,
                        ChoiceBox, _("Please select source"),
                        list = choices,
                        skin_name = ["ArchivCZSKVideoSourceSelection"])
            elif len(list_items) == 1:
                item = list_items[0]
                callback(item)
            else: # no video
                self.content_screen.workingFinished()