def __init__(self, msg): box = msg.find_parent('div', class_='a-box-inner a-padding-extra-large') if box is None: self.head = msg.find('title').get_text(strip=True) self.hint = msg.find('p', class_='a-last').get_text(strip=True) form = msg.find('form').find('div', class_='a-box-inner') self.task = form.h4.get_text(strip=True) self.img_url = pyxbmct.Image(form.find('img')['src'], aspectRatio=2) else: self.head = box.find('span', class_='a-size-large').get_text(strip=True) self.hint = box.find( 'span', class_='a-size-base a-color-secondary').get_text(strip=True) self.task = box.find('label', class_='a-form-label').get_text(strip=True) self.img_url = pyxbmct.Image(msg['src'], aspectRatio=2) super(_Challenge, self).__init__(self.head) self.setGeometry(500, 450, 8, 2) self.cap = '' self.tb_hint = pyxbmct.TextBox() self.fl_task = pyxbmct.FadeLabel(_alignment=pyxbmct.ALIGN_CENTER) self.ed_cap = pyxbmct.Edit('', _alignment=pyxbmct.ALIGN_LEFT | pyxbmct.ALIGN_CENTER_Y) self.btn_submit = pyxbmct.Button('OK') self.btn_cancel = pyxbmct.Button(getString(30123)) self.set_controls()
def __init__(self, title='', soup=None, email=None): super(Captcha, self).__init__(title) if 'ap_captcha_img_label' in unicode(soup): head = soup.find('div', attrs={'id': 'message_warning'}) if not head: head = soup.find('div', attrs={'id': 'message_error'}) title = soup.find('div', attrs={'id': 'ap_captcha_guess_alert'}) self.head = head.p.renderContents().strip() self.head = re.sub('(?i)<[^>]*>', '', self.head) self.picurl = soup.find('div', attrs={'id': 'ap_captcha_img'}).img.get('src') else: self.head = soup.find('span', attrs={'class': 'a-list-item'}).renderContents().strip() title = soup.find('div', attrs={'id': 'auth-guess-missing-alert'}).div.div self.picurl = soup.find('div', attrs={'id': 'auth-captcha-image-container'}).img.get('src') self.setGeometry(500, 550, 9, 2) self.email = email self.pwd = '' self.cap = '' self.title = title.renderContents().strip() self.image = pyxbmct.Image('', aspectRatio=2) self.tb_head = pyxbmct.TextBox() self.fl_title = pyxbmct.FadeLabel(_alignment=pyxbmct.ALIGN_CENTER) self.username = pyxbmct.Edit('', _alignment=pyxbmct.ALIGN_LEFT | pyxbmct.ALIGN_CENTER_Y) self.password = pyxbmct.Edit('', _alignment=pyxbmct.ALIGN_LEFT | pyxbmct.ALIGN_CENTER_Y) self.captcha = pyxbmct.Edit('', _alignment=pyxbmct.ALIGN_LEFT | pyxbmct.ALIGN_CENTER_Y) self.btn_submit = pyxbmct.Button(getString(30004).split('.')[0]) self.btn_cancel = pyxbmct.Button(getString(30223)) self.set_controls() self.set_navigation()
def queue(self, sports): rssStr = ''.join([ '[B]%s[/B]%s' % (sport.upper(), ''.join([ ' %s %s %s %s %s | ' % (game['Name1'], game['Score1'], game['Name2'], game['Score2'], game['Time']) for game in games ])) for (sport, games) in sports.items() ]) rssStr = rssStr + rssStr rssLabel = pyxbmct.FadeLabel() #self.placeControl(rssLabel, 0, 0, columnspan=49, pad_y=-5) self.placeControl(rssLabel, 0, 0, columnspan=49, rowspan=4, pad_y=-1) rssLabel.addLabel(rssStr) self.placeControl(self.close_button, 0, 49, columnspan=3, rowspan=4, pad_y=-5, pad_x=5) self.connect(self.close_button, self.close) extra_iterations = 0 for key, gs in sports.items(): if len(gs) > 3: extra_iterations += len(gs) - 3 / 3 total_iterations = len(list(sports.keys())) + extra_iterations self.display_duration = self.display_duration * total_iterations self.show() xbmc.sleep(self.display_duration) self.close()
def __init__(self, title='', soup=None, email=None): super(Captcha, self).__init__(title) head = soup.find('div', attrs={'id': 'message_warning'}) if not head: head = soup.find('div', attrs={'id': 'message_error'}) title = soup.find('div', attrs={'id': 'ap_captcha_guess_alert'}) url = soup.find('div', attrs={'id': 'ap_captcha_img'}).img.get('src') pic = xbmc.translatePath('special://temp/captcha%s.jpg' % randint(0, 99999999999999)).decode('utf-8') SaveFile(pic, getURL(url, retjson=False)) self.setGeometry(500, 550, 9, 2) self.email = email self.pwd = '' self.cap = '' self.head = head.p.renderContents().strip() self.head = re.sub('(?i)<[^>]*>', '', self.head) self.title = title.renderContents().strip() self.image = pyxbmct.Image(pic, aspectRatio=2) self.tb_head = pyxbmct.TextBox() self.fl_title = pyxbmct.FadeLabel(_alignment=pyxbmct.ALIGN_CENTER) self.username = pyxbmct.Edit('', _alignment=pyxbmct.ALIGN_LEFT | pyxbmct.ALIGN_CENTER_Y) self.password = pyxbmct.Edit('', _alignment=pyxbmct.ALIGN_LEFT | pyxbmct.ALIGN_CENTER_Y) self.captcha = pyxbmct.Edit('', _alignment=pyxbmct.ALIGN_LEFT | pyxbmct.ALIGN_CENTER_Y) self.btn_submit = pyxbmct.Button(getString(30008).split('.')[0]) self.btn_cancel = pyxbmct.Button(getString(30123)) self.set_controls() self.set_navigation() xbmcvfs.delete(pic)
def set_info_controls(self): # Demo for PyXBMCt UI controls. no_int_label = pyxbmct.Label('Information output', alignment=pyxbmct.ALIGN_CENTER) self.placeControl(no_int_label, 0, 0, 1, 2) # label_label = pyxbmct.Label('Label') self.placeControl(label_label, 1, 0) # Label self.label = pyxbmct.Label('Simple label') self.placeControl(self.label, 1, 1) # fadelabel_label = pyxbmct.Label('FadeLabel') self.placeControl(fadelabel_label, 2, 0) # FadeLabel self.fade_label = pyxbmct.FadeLabel() self.placeControl(self.fade_label, 2, 1) self.fade_label.addLabel('Very long string can be here.') # textbox_label = pyxbmct.Label('TextBox') self.placeControl(textbox_label, 3, 0) # TextBox self.textbox = pyxbmct.TextBox() self.placeControl(self.textbox, 3, 1, 2, 1) self.textbox.setText( 'It can display long text.\n' 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.') # Set auto-scrolling for long TexBox contents self.textbox.autoScroll(1000, 1000, 1000) # image_label = pyxbmct.Label('Image') self.placeControl(image_label, 5, 0) # Image self.image = pyxbmct.Image(os.path.join(_addon_path, 'bbb-splash.jpg')) self.placeControl(self.image, 5, 1, 2, 1)
def set_controls(self): """Set up UI controls""" # Image control # image = pyxbmct.Image('https://peach.blender.org/wp-content/uploads/poster_rodents_small.jpg?3016dc') # self.placeControl(image, 0, 0, rowspan=3, columnspan=2) # Today button self.today_button = pyxbmct.Button('Šodien') self.placeControl(self.today_button, 0, 0) self.connect(self.today_button, self.set_guide_today) # Today button self.tomorrow_button = pyxbmct.Button('Rīt') self.placeControl(self.tomorrow_button, 0, 1) self.connect(self.tomorrow_button, self.set_guide_tomorrow) # Today button self.aftertomorrow_button = pyxbmct.Button('Parīt') self.placeControl(self.aftertomorrow_button, 0, 2) self.connect(self.aftertomorrow_button, self.set_guide_aftertomorrow) # Today button self.afteraftertomorrow_button = pyxbmct.Button('Aizparīt') self.placeControl(self.afteraftertomorrow_button, 0, 3) self.connect(self.afteraftertomorrow_button, self.set_guide_afteraftertomorrow) # Now Label self.program_name_label = pyxbmct.Label('Šodienas Programma') self.placeControl(self.program_name_label, 1, 0, 1,4) self.now_label = pyxbmct.FadeLabel() self.placeControl(self.now_label, 2, 0, 1,4) self.now_label.addLabel('Šobrīd rāda: ' + self.now_playing ) # List self.list = pyxbmct.List() self.placeControl(self.list, 3, 0, rowspan=7, columnspan=4) # Add items to the list # items = ['Item {0}'.format(i) for i in range(1, 8)] # print self.program_today self.list.addItems(self.program_today ) # Text label # label = pyxbmct.Label('Your name:') # self.placeControl(label, 8, 0) # Close button self.close_button = pyxbmct.Button('Aizvērt') self.placeControl(self.close_button, 10, 0) # Connect close button self.connect(self.close_button, self.close)
def _set_controls(self): textbox = pyxbmct.TextBox() self.placeControl(textbox, 0, 0, 2, 5) textbox.setText( _('To authorize the addon open the link below[CR]' '[B]{confirm_url}[/B],[CR]' 'scan the QR-code or check your mailbox[CR]' '[B]{email}[/B]').format(confirm_url=self._confirm_url, email=self._email)) textbox.autoScroll(1000, 1000, 1000) qr_code = pyxbmct.Image(self._qrcode_path) self.placeControl(qr_code, 2, 1, 4, 3, pad_x=35) autoclose_label = pyxbmct.FadeLabel() self.placeControl(autoclose_label, 6, 0, columnspan=5) autoclose_label.addLabel( _('This window will close automatically after authorization.')) self._cancel_btn = pyxbmct.Button(_('Cancel')) self.placeControl(self._cancel_btn, 7, 2, pad_x=-10, pad_y=10) self.setFocus(self._cancel_btn)
def set_info_controls(self): debug("set_info_controls start") self.ueberschrift=pyxbmct.Label(self.ueberschrift,alignment=pyxbmct.ALIGN_CENTER) self.placeControl(self.ueberschrift, 0, 0,columnspan=10,rowspan=1) if not "<tbody>" in self.starttext: if self.image=="" and self.trailer !="" : self.image="https://img.youtube.com/vi/"+self.trailer+"/hqdefault.jpg" self.image = pyxbmct.Image(self.image,aspectRatio=4) self.placeControl(self.image, 1, 3,columnspan=4,rowspan=6) self.beschreibung=pyxbmct.TextBox() self.placeControl(self.beschreibung, 7, 0,columnspan=10,rowspan=15) self.beschreibung.setText(self.text) self.beschreibung.autoScroll(3000, 2000, 3000) if self.trailer !="": self.info_button = pyxbmct.Button('[B]Trailer[/B]', font='font14') self.placeControl(self.info_button, 22, 0,columnspan=3,rowspan=2) self.connect(self.info_button, self.startv) self.close_button = pyxbmct.Button('[B]Close[/B]', font='font14') self.placeControl(self.close_button, 22, 7,columnspan=3,rowspan=2) self.connect(self.close_button, self.close) self.setFocus(self.close_button) else: #self.image = pyxbmct.Image(self.image,aspectRatio=4) #self.placeControl(self.image, 1, 3,columnspan=4,rowspan=4) self.beschreibung = pyxbmct.FadeLabel() self.placeControl(self.beschreibung, 1, 0,columnspan=10,rowspan=1) self.beschreibung.addLabel(self.text) kurz_inhalt = self.starttext[self.starttext.find('<tbody>')+1:] kurz_inhalt = kurz_inhalt[:kurz_inhalt.find('</tbody>')] kurz_inhalt=kurz_inhalt.replace("\n","") starty=2 startx=0 counter=0 counter2=0 spl=kurz_inhalt.split('</tr>') for i in range(0,len(spl),1): entry=spl[i] entry=entry.replace("<br />","###") match=re.compile('>(.+?)</td>', re.DOTALL).findall(entry) for feld in match: feld=ersetze(feld) feld = re.sub(r'\<.*?\>', '', feld) if len(feld)>20: gr=5 else: gr=0 if "###" in feld: sp2=feld.split('###') for i2 in range(0,len(sp2),1): entry2=sp2[i2] self.sp1=pyxbmct.Label(entry2) self.placeControl(self.sp1, starty, startx,columnspan=2+gr,rowspan=2) starty=starty+1 counter=counter+1 starty=starty-counter if counter2<counter: counter2=counter-1 counter=0 startx=startx+2+gr else: self.sp1=pyxbmct.Label(feld) self.placeControl(self.sp1, starty, startx,columnspan=2+gr,rowspan=2) startx=startx+2+gr starty=starty+1+counter2 counter2=0 startx=0 self.close_button = pyxbmct.Button('[B]Close[/B]', font='font14') self.placeControl(self.close_button, 22, 7,columnspan=3,rowspan=2) self.connect(self.close_button, self.close) self.setFocus(self.close_button) self.connectEventList([pyxbmct.ACTION_MOVE_LEFT, pyxbmct.ACTION_MOVE_RIGHT, pyxbmct.ACTION_MOUSE_DRAG, pyxbmct.ACTION_MOUSE_LEFT_CLICK], self.leftright)