def __init__(self, configFile): appId = getProperty(configFile, 'baidu-aip-app-id') apiKey = getProperty(configFile, 'baidu-aip-api-key') secretKey = getProperty(configFile, 'baidu-aip-secret-key') self.init(appId, apiKey, secretKey)
def run(name, configFile): sourcePath = getProperty(configFile, 'source-path') outputPath = getProperty(configFile, 'output-path') lesson = Lesson(sourcePath, outputPath) lesson.start()
def login(self, exitCallback, uuid=None): def isLoginned(uuid): for count in range(10): status = int(itchat.check_login(uuid)) if status is 200: return True if status is 201: print 'Wait for confirm in mobile #', count randomSleep(1, 2) continue print 'Error status:', status return False return False if uuid is None: statusFile = getProperty(self.configFile, 'wechat-status-file') itchat.auto_login(hotReload=True, statusStorageDir=statusFile) else: if not isLoginned(uuid): raise Exception('Failed to login with {}'.format(uuid)) userInfo = itchat.web_init() itchat.show_mobile_login() itchat.get_friends(True) itchat.start_receiving(exitCallback) self.me = itchat.search_friends() print self.me['NickName'], 'is working' self.watchFriends = list() names = getProperty(self.configFile, 'wechat-watch-friends').split(';') for name in names: friends = itchat.search_friends(name=name) self.watchFriends.extend(friends) self.watchGroups = list() names = getProperty(self.configFile, 'wechat-watch-groups').split(';') for name in names: groups = itchat.search_chatrooms(name=name) self.watchGroups.extend(groups) self.searchReplyPlate = getProperty(self.configFile, 'search-reply-plate') itchat.run(blockThread=False) # Run in a new thread self.run()
def init(configFile): UrlUtils.SHORT_URL_TRANSLATOR_URL = getProperty(configFile, 'short-url-translator-url') UrlUtils.SHORT_URL_REFERER = getProperty(configFile, 'short-url-referer') UrlUtils.SHORT_URL_USER_AGENT = getProperty(configFile, 'short-url-user-agent') UrlUtils.SHORT_URL_SOURCE = getProperty(configFile, 'short-url-source') UrlUtils.SHORT_URL_CALLBACK = getProperty(configFile, 'short-url-callback')
def __init__(self, configFile): LadyThread.__init__(self) self.qwd = QWD(configFile) self.url = getProperty(configFile, 'share-url') self.imageType = int(getProperty(configFile, 'share-image-type')) self.isUpdateNeeded = True
def uploadHtmlToFtp(self, path): host = getProperty(path, 'host') user = getProperty(path, 'user') passwd = getProperty(path, 'passwd') dirname = getProperty(path, 'dirname') flag = getProperty(path, 'isProtected') if flag and 'true' == flag.lower(): isProtected = True else: isProtected = False uploadFtp(host, dirname, 'data/index.html', user, passwd, isProtected) uploadFtp(host, '{}/json'.format(dirname), 'data/index.json', user, passwd, isProtected)
def run(configfile, name): OutputPath.init(configFile) thread = ThreadWritableObject(configFile, name) thread.start() sys.stdout = thread sys.errout = thread # XXX: Actually, it does NOT work try: db = Database(configFile, 'specials') db.initialize() evaluation = Evaluation(configFile, db) evaluation.updateOverdue() path = OutputPath.getSharePath() sharePath = getProperty(configFile, 'output-share-file') cmd = '/bin/rm -f {1} && /bin/ln -s {0} {1}'.format(path, sharePath) runCommand(cmd) data = evaluation.output() with open(path, 'w') as fp: fp.write(reprDict(data)) except KeyboardInterrupt: pass except Exception, e: print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S') traceback.print_exc(file=sys.stdout)
def __init__(self): self.channels = [] self.channelNames = [] self.maxGuidedata = 48 self.maxChannels = None self.uEPGRunning = utils.getProperty('uEPGRunning') == "True" self.useKodiSkin = utils.REAL_SETTINGS.getSetting( 'useKodiSkin') == "true"
def updateWatchers(self): self.watchFriends = list() names = getProperty(self.configFile, 'wechat-watch-friends').split(';') for name in names: friends = itchat.search_friends(name=name) self.watchFriends.extend(friends) self.friendsActions = getProperty(self.configFile, 'wechat-friends-actions').split('|') self.watchGroups = list() names = getProperty(self.configFile, 'wechat-watch-groups').split(';') for name in names: groups = itchat.search_chatrooms(name=name) self.watchGroups.extend(groups) self.groupsActions = getProperty(self.configFile, 'wechat-groups-actions').split('|')
def prepare(self): self.width = int(self.contentConfig['width']) self.height = int(self.contentConfig['height']) # Font self.font = self.contentConfig['font'] if not self.font: self.font = getProperty(self.configFile, 'font-path')
def getEmail(config): protocol = getProperty(config, 'email-protocol') if 'smtp' == protocol or 'smtpssl' == protocol: return SmtpEmail(config) if 'exchange' == protocol: return ExchangeEmail(config) raise Exception('unkown email protocol: {}'.format(protocol))
def login(self): if self.apptoken is not None: return True # Url url = getProperty(self.configFile, 'cps-qwd-login-url') # Data data = { 'appid': self.appid, 'ctype': self.ctype, 'ie': self.ie, 'p': self.p, 'pin': self.pin, 'tgt': self.tgt, 'uuid': self.uuid } # Request r = requests.post(url, data=data) response = r.content obj = json.loads(response.decode('utf-8', 'ignore')) # Login status errCode = int(obj.pop('errCode')) if errCode is not 0: print 'Failed to login to', url, ':\n', response return False print('Logined to qwd.jd.com') obj = obj.pop('loginInfo') self.apptoken = obj.pop('apptoken') self.pinType = obj.pop('pinType') self.jxjpin = obj.pop('jxjpin') self.cookies = { 'app_id': self.appid, 'apptoken': self.apptoken, 'client_type': self.ctype, 'jxjpin': self.jxjpin, 'pinType': self.pinType, 'tgt': self.tgt, 'qwd_chn': self.qwd_chn, 'qwd_schn': self.qwd_schn, 'login_mode': self.login_mode } return True
def init(configFile): NLP.NLP_URL = getProperty(configFile, 'nlp-url') NLP.NLP_DATA_SCHEMA_KEYWORDS = getProperty(configFile, 'nlp-data-schema-keywords') NLP.NLP_API_KEYWORDS = getProperty(configFile, 'nlp-api-keywords') NLP.NLP_DATA_SCHEME_MORPHOLOGY = getProperty( configFile, 'nlp-data-scheme-morphology') NLP.NLP_API_MORPHOLOGY = getProperty(configFile, 'nlp-api-morphology') NLP.NLP_ORIGIN = getProperty(configFile, 'nlp-origin') NLP.NLP_REFERER = getProperty(configFile, 'nlp-referer') NLP.NLP_USER_AGENT = getProperty(configFile, 'nlp-user-agent')
def __init__(self, configFile, dbName): AutoReleaseThread.__init__(self) self.host = getProperty(configFile, 'mysql-host') self.username = getProperty(configFile, 'mysql-user') self.password = getProperty(configFile, 'mysql-password') self.enabled = False enabled = getProperty(configFile, 'db-enabled') if None != enabled: enabled = enabled.upper() if 'Y' == enabled or 'YES' == enabled: self.enabled = True self.dbName = dbName self.db = None self.tableDict = None if self.enabled: self.start()
def __init__(self, config): self.enabled = False enabled = getProperty(config, 'email-enabled') if None != enabled: enabled = enabled.upper() if 'Y' == enabled or 'YES' == enabled: self.enabled = True if not self.enabled: return domain = getProperty(config, 'email-domain') username = getProperty(config, 'email-username') password = getProperty(config, 'email-password') for retries in range(5): try: transport = WindowsHttpAuthenticated(username=username, password=password) self.client = suds.client.Client( "https://%s/EWS/Services.wsdl" % domain, transport=transport, plugins=[ewsclient.AddService()]) print 'Create email client of "', domain, '". Retries:', retries break except WebFault, f: errMsg = f + '\n' + f.fault except Exception, e: errMsg = e print traceback.print_exc()
def __init__(self, *args, **kwargs): xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs) self.mediaPath = '' self.toRemove = [] self.infoOffset = 0 self.infoOffsetV = 0 self.shownTime = 0 self.centerPosition = 0 self.centerChannel = 0 self.currentChannel = 1 self.newChannel = -1 self.focusRow = 0 self.defaultRows = 9 self.focusIndex = -1 self.onInitReturn = False self.player = Player() self.player.uEPG = self self.rowCount = (int(utils.getProperty("uEPG.rowCount") or self.defaultRows)) self.overlay = BackgroundWindow('%s.overlay.xml'%utils.ADDON_ID,utils.ADDON_PATH,"default") self.overlay.uEPG = self
def __init__(self, config): self.enabled = False enabled = getProperty(config, 'email-enabled') if None != enabled: enabled = enabled.upper() if 'Y' == enabled or 'YES' == enabled: self.enabled = True if not self.enabled: return self.protocol = getProperty(config, 'email-protocol') self.domain = getProperty(config, 'email-domain') self.sender = getProperty(config, 'email-sender') self.username = getProperty(config, 'email-username') self.password = getProperty(config, 'email-password')
def onInit(self): utils.log('onInit') utils.setProperty('uEPGRunning','True') self.closeCount = 0 curtime = time.time() self.lastActTime = time.time() self.windowID = self.getWindowID() self.windowIDS = ["ActivateWindow(fullscreenvideo)","ActivateWindow(%s)"%self.windowID] self.windowToggle = itertools.cycle(self.windowIDS).next if self.onInitReturn == False: utils.log('onInit, onInitReturn = False') self.guideLimit = 14400 self.rowCount = self.chkRows(self.rowCount) self.epgButtonwidth = float((utils.getProperty("uEPG.buttonWidth")) or "5400.0") self.timeCount = int((utils.getProperty("uEPG.timeCount")) or "3") self.textColor = hex(int((utils.getProperty("uEPG.textColor") or "0xFFFFFFFF"),16))[2:] self.disabledColor = hex(int((utils.getProperty("uEPG.disabledColor") or "0xFFFFFFFF"),16))[2:] self.focusedColor = hex(int((utils.getProperty("uEPG.focusedColor") or "0xFFFFFFFF"),16))[2:] self.shadowColor = hex(int((utils.getProperty("uEPG.shadowColor") or "0xFF000000"),16))[2:] self.pastColor = hex(int((utils.getProperty("uEPG.pastColor") or "0xFF0f85a5"),16))[2:] self.timeColor = hex(int((utils.getProperty("uEPG.timeColor") or "0xFF0f85a5"),16))[2:] self.futureColor = hex(int((utils.getProperty("uEPG.futureColor") or "0xFF0f85a5"),16))[2:] self.singleLineFade = (utils.getProperty("uEPG.singleLineFade") or "false") == "true" self.textFont = (utils.getProperty("uEPG.timeCount") or "font12") self.timeFormat = (urllib.unquote(utils.getProperty("uEPG.timeFormat")) or "%A, %B %d") self.clockMode = int(utils.REAL_SETTINGS.getSetting("ClockMode")) self.channelButtons = [None] * self.rowCount for i in range(self.rowCount): self.channelButtons[i] = [] try: self.removeControl(self.fadePast) self.removeControl(self.currentTimeBar) except: pass self.focusChannel = self.getControl(33009) self.currentHighLT = self.getControl(33010) self.currentTime = self.getControl(33007) timetx, timety = self.currentTime.getPosition() timetw = self.currentTime.getWidth() timeth = self.currentTime.getHeight() self.currentLine = self.getControl(33013) timex, timey = self.currentLine.getPosition() timew = self.currentLine.getWidth() timeh = self.currentLine.getHeight() self.timeButtonBar = os.path.join(self.channelLST.mediaFolder,utils.TIME_BAR) self.currentTimeBar = xbmcgui.ControlImage(timex, timey, timew, timeh, self.timeButtonBar, colorDiffuse=self.timeColor) self.addControl(self.currentTimeBar) self.pastLine = self.getControl(33011) timex, timey = self.pastLine.getPosition() timew = self.pastLine.getWidth() timeh = self.pastLine.getHeight() self.pastTime = os.path.join(self.channelLST.mediaFolder,utils.PAST_FADE) self.fadePast = xbmcgui.ControlImage(timex, timey, timew, timeh, self.pastTime, colorDiffuse=self.pastColor) self.addControl(self.fadePast) self.futureLine = self.getControl(33012) timex, timey = self.futureLine.getPosition() timew = self.futureLine.getWidth() timeh = self.futureLine.getHeight() self.futureTime = os.path.join(self.channelLST.mediaFolder,utils.FUTURE_FADE) self.fadeFuture = xbmcgui.ControlImage(timex, timey, timew, timeh, self.futureTime, colorDiffuse=self.futureColor) self.addControl(self.fadeFuture) self.TimeXYW = {} for i in range(self.timeCount): self.TimeXYW['Time%dX'%(i + 1)] = self.getControl(33101 + i).getPosition()[0] self.TimeXYW['Time%dY'%(i + 1)] = self.getControl(33101 + i).getPosition()[1] self.TimeXYW['Time%dW'%(i + 1)] = int(round(self.getControl(33101 + i).getWidth()//2)) self.TimeRange = {} for i in range(self.timeCount): self.TimeRange['Time%dRange'%(i + 1)] = range(self.TimeXYW['Time%dX'%(i + 1)] - self.TimeXYW['Time%dW'%(i + 1)],self.TimeXYW['Time%dX'%(i + 1)] + self.TimeXYW['Time%dW'%(i + 1)]) if self.setChannelButtons(curtime, self.fixChannel(self.currentChannel)) == False: utils.log('Unable to add channel buttons') utils.notificationDialog("%s Error, Contact %s for support"%(self.channelLST.pluginName, self.channelLST.pluginAuthor)) self.closeUEPG() self.setChannelButtons(curtime, self.fixChannel(self.currentChannel)) basex, basey = self.getControl(33611 + self.focusRow).getPosition() basew = self.getControl(33611 + self.focusRow).getWidth() for i in range(len(self.channelButtons[self.focusRow])): left, top = self.channelButtons[self.focusRow][i].getPosition() width = self.channelButtons[self.focusRow][i].getWidth() left = left - basex starttime = self.shownTime + (left / (basew / self.epgButtonwidth)) endtime = starttime + (width / (basew / self.epgButtonwidth)) if curtime >= starttime and curtime <= endtime: utils.log('curtime focusIndex = %s'%i) self.focusIndex = i self.setFocus(self.channelButtons[self.focusRow][i]) self.focusTime = int(curtime) self.focusEndTime = endtime break if self.focusIndex == -1: self.focusIndex = 0 self.setFocus(self.channelButtons[self.focusRow][self.focusIndex]) left, top = self.channelButtons[self.focusRow][self.focusIndex].getPosition() width = self.channelButtons[self.focusRow][self.focusIndex].getWidth() left = left - basex starttime = self.shownTime + (left / (basew / self.epgButtonwidth)) endtime = starttime + (width / (basew / self.epgButtonwidth)) self.focusTime = int(starttime + 30) self.focusEndTime = endtime self.setProperButton(0) self.setShowInfo() self.onInitReturn = True utils.log('onInit return')
def initChannels(params, data, dataType): utils.log('initChannels, params = ' + str(params)) with busy_dialog(): hasChannels = False channelLST = ChannelList() channelLST.incHDHR = ( params.get('include_hdhr', '') or utils.REAL_SETTINGS.getSetting('Enable_HDHR')) == 'true' channelLST.skinPath = (utils.unquote(params.get('skin_path', '')) or channelLST.chkSkinPath()) channelLST.mediaFolder = os.path.join(channelLST.skinPath, 'resources', 'skins', 'default', 'media') channelLST.refreshPath = (utils.unquote(params.get('refresh_path', '')) or utils.ADDON_ID) channelLST.refreshIntvl = int( params.get('refresh_interval', '') or '0') channelLST.skinFolder = os.path.join( channelLST.skinPath, 'resources', 'skins', 'default', '1080i', ) if xbmcvfs.exists( os.path.join(channelLST.skinPath, 'resources', 'skins', 'default', '1080i', '%s.guide.xml' % utils.ADDON_ID)) else os.path.join( channelLST.skinPath, 'resources', 'skins', 'default', '720p') utils.setProperty('uEPG.rowCount', (params.get('row_count', '') or '9')) channelLST.pluginName, channelLST.pluginAuthor, channelLST.pluginIcon, channelLST.pluginFanart, channelLST.pluginPath = utils.getPluginMeta( channelLST.refreshPath) utils.log('dataType = ' + str(dataType)) utils.log('skinPath = ' + str(channelLST.skinPath)) utils.log('skinFolder = ' + str(channelLST.skinFolder)) utils.log('rowCount = ' + utils.getProperty('uEPG.rowCount')) utils.log('refreshPath = ' + str(channelLST.refreshPath)) utils.log('refreshIntvl = ' + str(channelLST.refreshIntvl)) utils.setProperty('PluginName', channelLST.pluginName) utils.setProperty('PluginIcon', channelLST.pluginIcon) utils.setProperty('PluginFanart', channelLST.pluginFanart) utils.setProperty('PluginAuthor', channelLST.pluginAuthor) utils.setProperty('pluginPath', channelLST.pluginPath) #show optional load screen # if channelLST.uEPGRunning == False and utils.getProperty('uEPGSplash') != 'True' and xbmcvfs.exists(os.path.join(channelLST.skinFolder,'%s.splash.xml'%utils.ADDON_ID)) == True: # mySplash = epg.Splash('%s.splash.xml'%utils.ADDON_ID,channelLST.skinPath,'default') # mySplash.show() # xbmc.sleep(100) if utils.HDHR().hasHDHR(): if utils.REAL_SETTINGS.getSetting( 'FirstTime_HDHR') == "true" and not channelLST.incHDHR: utils.REAL_SETTINGS.setSetting('FirstTime_HDHR', 'false') if utils.yesnoDialog( (utils.LANGUAGE(30012) % (channelLST.pluginName)), custom='Later'): utils.REAL_SETTINGS.setSetting('Enable_HDHR', 'true') channelLST.incHDHR = True utils.log('incHDHR = ' + str(channelLST.incHDHR)) if dataType == 'wrap': hasChannels = channelLST.prepareJson(data) elif dataType == 'json': hasChannels = channelLST.prepareJson( utils.loadJson(utils.unquote(data))) elif dataType == 'property': hasChannels = channelLST.prepareJson( utils.loadJson(utils.unquote(utils.getProperty(data)))) elif dataType == 'listitem': hasChannels = channelLST.prepareVFS(utils.unquote(data)) if hasChannels == True: if utils.REAL_SETTINGS.getSetting('FirstTime_Run') == "true": utils.REAL_SETTINGS.setSetting('FirstTime_Run', 'false') utils.textViewer( utils.LANGUAGE(30008), '%s / %s' % (utils.ADDON_NAME, channelLST.pluginName)) # if utils.getProperty('uEPGSplash') == 'True': # mySplash.close() # del mySplash # xbmc.sleep(100) if channelLST.refreshIntvl > 0 and channelLST.refreshPath is not None: channelLST.startRefreshTimer() if channelLST.uEPGRunning == False and utils.getProperty( 'uEPGGuide') != 'True': channelLST.myEPG = epg.uEPG('%s.guide.xml' % utils.ADDON_ID, channelLST.skinPath, 'default') channelLST.myEPG.channelLST = channelLST channelLST.myEPG.doModal() del channelLST.myEPG xbmc.sleep(100) else: utils.log("invalid uEPG information", xbmc.LOGERROR) # utils.notificationDialog(utils.LANGUAGE(30002)%(channelLST.pluginName,channelLST.pluginAuthor),icon=channelLST.pluginIcon) # utils.REAL_SETTINGS.openSettings() del utils.KODI_MONITOR
self.refreshTimer = threading.Timer(float(self.refreshIntvl), self.refresh) self.refreshTimer.name = "refreshTimer" if self.refreshTimer.isAlive() == True: utils.log('startRefreshTimer, canceling refreshTimer') self.refreshTimer.cancel() self.refreshTimer.start() def refresh(self): utils.log('refresh, triggering refreshTimer') utils.notificationDialog(utils.LANGUAGE(30003), icon=self.pluginIame) xbmc.executebuiltin("RunPlugin(%s)"%self.refreshPath) if __name__ == '__main__': if utils.getProperty('PseudoTVRunning') != "True": try: params = dict(arg.split('=') for arg in sys.argv[1].split('&')) except: params = {} dataType = None utils.log('params = ' + str(params)) for type in ['json','property','listitem']: try: data = params[type] dataType = type break except: pass hasChannels= False channelLST = ChannelList() channelLST.incHDHR = (utils.loadJson(utils.unquote(params.get('include_hdhr',''))) or channelLST.incHDHR) channelLST.skinPath = ((utils.loadJson(utils.unquote(params.get('skin_path','')))) or channelLST.chkSkinPath())
def __init__(self, configFile, qwd): self.qwd = qwd self.imageType = int(getProperty(configFile, 'share-image-type'))
def __init__(self, configFile): self.configFile = configFile self.loginMethod = int( getProperty(self.configFile, 'cps-qwd-login-method')) self.ploginUrl = getProperty(self.configFile, 'cps-qwd-plogin-url') self.ploginSeccessfulUrl = getProperty( self.configFile, 'cps-qwd-plogin-seccessful-url') self.appid = getProperty(self.configFile, 'cps-qwd-appid') self.ctype = getProperty(self.configFile, 'cps-qwd-ctype') self.ie = getProperty(self.configFile, 'cps-qwd-ie') self.p = getProperty(self.configFile, 'cps-qwd-p') self.qwd_chn = getProperty(self.configFile, 'cps-qwd-qwd_chn') self.qwd_schn = getProperty(self.configFile, 'cps-qwd-qwd_schn') self.login_mode = getProperty(self.configFile, 'cps-qwd-login_mode') self.pageindex = getProperty(self.configFile, 'cps-qwd-pageindex') self.pagesize = getProperty(self.configFile, 'cps-qwd-pagesize') self.uniquespu = getProperty(self.configFile, 'cps-qwd-uniquespu') self.storestatus = getProperty(self.configFile, 'cps-qwd-storestatus') self.comsrate = getProperty(self.configFile, 'cps-qwd-comsrate') self.sortBy = getProperty(self.configFile, 'cps-qwd-sortby').split(';') self.order = getProperty(self.configFile, 'cps-qwd-order').split(';') self.coupon = getProperty(self.configFile, 'cps-qwd-coupon') self.pwprice = getProperty(self.configFile, 'cps-qwd-pwprice') self.delivery = getProperty(self.configFile, 'cps-qwd-delivery') self.uuid = getProperty(self.configFile, 'cps-qwd-uuid') self.pin = getProperty(self.configFile, 'cps-qwd-pin') self.password = getProperty(self.configFile, 'cps-qwd-password') self.tgt = getProperty(self.configFile, 'cps-qwd-tgt') self.shareUrl = getProperty(self.configFile, 'cps-qwd-share-url') self.searchItemUrl = getProperty(self.configFile, 'cps-qwd-search-item-url') self.userAgent = getProperty(self.configFile, 'cps-qwd-http-user-agent') self.reset()
self.refreshTimer = threading.Timer(float(self.refreshIntvl), self.refresh) self.refreshTimer.name = "refreshTimer" if self.refreshTimer.isAlive() == True: utils.log('startRefreshTimer, canceling refreshTimer') self.refreshTimer.cancel() self.refreshTimer.start() def refresh(self): utils.log('refresh, triggering refreshTimer') utils.notificationDialog(utils.LANGUAGE(30003), icon=self.pluginIame) xbmc.executebuiltin("RunPlugin(%s)" % self.refreshPath) if __name__ == '__main__': if utils.getProperty('PseudoTVRunning') != "True": try: params = dict(arg.split('=') for arg in sys.argv[1].split('&')) except: params = {} dataType = None utils.log('params = ' + str(params)) for type in ['json', 'property', 'listitem']: try: data = params[type] dataType = type break except: pass
def prepare(self): self.width = int(self.contentConfig['width']) self.height = int(self.contentConfig['height']) # Logo: logo = self.contentConfig['logo'] if logo: prefix = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'logo.original') logo = Network.saveUrl(prefix, logo) else: logo = getProperty(self.configFile, 'logo-path') if logo: self.logo = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'logo.jpg') logoWidth = int(self.contentConfig['logo-width']) logoHeight = int(self.contentConfig['logo-height']) print('Create logo', self.logo, 'from', logo) ''' cmd = 'ffmpeg -y -i {} -vf scale="{}:{}" {}'.format(logo, logoWidth, logoHeight, self.logo) runCommand(cmd) ''' ImageKit.stretch(self.logo, logo, (logoWidth, logoHeight)) else: self.logo = None # Background: background = self.contentConfig['background'] if background: prefix = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'background.original') background = Network.saveUrl(prefix, background) else: background = getProperty(self.configFile, 'background-path') if background: self.background = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'background.jpg') scalePath = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'bg-scale.jpg') print('Create background', self.background, 'from', background) ''' cmd = 'ffmpeg -y -i {} -vf scale="{}:{}" {}'.format(background, self.width, self.height, self.background) runCommand(cmd) ''' ImageKit.crop(scalePath, background, (self.width, self.height)) ImageKit.blurdim(self.background, scalePath) else: self.background = None # Create silence self.silencePath = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'silence.mp3') print('Create silence in', self.silencePath) cmd = 'ffmpeg -y -f lavfi -i anullsrc=r=22050:cl=mono -t 1 -q:a 9 -acodec libmp3lame {}'.format(self.silencePath) runCommand(cmd) # To m4a audioPath = '{}m4a'.format(self.silencePath[:-3]) print('Translate', self.silencePath, 'to', audioPath) cmd = 'ffmpeg -y -i {} -vn -acodec aac -strict -2 \'-bsf:a\' aac_adtstoasc {}'.format(self.silencePath, audioPath) runCommand(cmd) # Create separator between videos separatorPath = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'image.mp4') print('Create separator in', separatorPath) cmd = 'ffmpeg -y -loop 1 -i {} -c:v libx264 -t 1 -pix_fmt yuv420p {}'.format(self.background, separatorPath) runCommand(cmd) # Merge image and audio self.separatorPath = os.path.join(OutputPath.DATA_OUTPUT_PATH, 'separator.mp4') print('Merge', separatorPath, 'and', audioPath, 'to', self.separatorPath) cmd = 'ffmpeg -y -i {} -i {} -c copy -map \'0:v:0\' -map \'1:a:0\' {}'.format(separatorPath, audioPath, self.separatorPath) runCommand(cmd)
def plogin(self): def isValidAuthCode(code): if code is None or len(code) != 4: return False for c in code: if c.isdigit(): continue if c.isalpha(): continue # Wrong word return False return True if self.pCookies is not None: return True # https://github.com/mozilla/geckodriver/releases # browser = webdriver.Firefox() # https://chromedriver.storage.googleapis.com/index.html browser = webdriver.Chrome() try: # Plogin browser.get(self.ploginUrl) # Login by username and password # Username and password randomSleep(1, 2) inputElement(browser.find_element_by_id('username'), self.pin) randomSleep(1, 2) inputElement(browser.find_element_by_id('password'), self.password) # Submit buttonElement = browser.find_element_by_id('loginBtn') # Code codeElement = browser.find_element_by_id('code') imageElement = browser.find_element_by_id('imgCode') times = 0 if codeElement.is_displayed(): while codeElement.is_displayed() and times < 50: times += 1 # Image to text path = OutputPath.getAuthPath(self.pin) ImageKit.saveCapture(browser, imageElement, path) code = ImageKit.getText(path) codeElement.send_keys(code) if not isValidAuthCode(code): # Refresh auth code randomSleep(0.5, 1) imageElement.click() # Wait for updating auth code randomSleep(1, 2) codeElement.clear() continue # Submit randomSleep(1, 2) buttonElement.click() error = self.getBrowserError(browser) if error is None: print 'Succeed after', times, 'tries.' break if u'验证码' not in error: raise Exception('Unable to login for "{}": {}'.format( self.pin, error)) randomSleep(1, 2) codeElement.clear() randomSleep(1, 2) else: raise Exception('Unable to login for "{}"'.format( self.pin)) else: # Submit randomSleep(1, 2) buttonElement.click() wait = WebDriverWait(browser, 3) error = self.getBrowserError(browser) if error is not None: raise Exception('Unable to login for "{}": {}'.format( self.pin, error)) print 'Loginned for', self.pin # Redirect to wqs qwsUrl = getProperty(self.configFile, 'cps-qwd-wqs-url') browser.get(qwsUrl) time.sleep(10) # Save as type of cookie for requests self.pCookies = dict() for cookie in browser.get_cookies(): k = cookie['name'] v = cookie['value'] self.pCookies[k] = v except Exception as e: print e finally: browser.quit()
def __init__(self, configFile): self.qwd = QWD(configFile) self.url = getProperty(configFile, 'search-url') self.configFile = configFile
def init(configFile): Validation.BAD_COMMENTS = getProperty(configFile, 'bad-comments')
self.refreshTimer = threading.Timer(float(self.refreshIntvl), self.refresh) self.refreshTimer.name = "refreshTimer" if self.refreshTimer.isAlive() == True: utils.log('startRefreshTimer, canceling refreshTimer') self.refreshTimer.cancel() self.refreshTimer.start() def refresh(self): utils.log('refresh, triggering refreshTimer') utils.notificationDialog(utils.LANGUAGE(30003), icon=self.pluginIame) xbmc.executebuiltin("RunPlugin(%s)" % self.refreshPath) if __name__ == '__main__': if utils.getProperty('PseudoTVRunning') != "True": try: params = dict(arg.split('=') for arg in sys.argv[1].split('&')) except: params = {} dataType = None utils.log('params = ' + str(params)) for type in ['json', 'property', 'listitem']: try: data = params[type] dataType = type break except: pass hasChannels = False