コード例 #1
0
def TrendingGrid(fromPage,
                 toPage,
                 tagIds,
                 itemsPerGrid,
                 excludeArticleIds,
                 getall=True):
    r = requests.get(baseurl + '/TrendingGrid/LoadMore',
                     headers=headers,
                     params={
                         'fromPage': fromPage,
                         'toPage': toPage,
                         'tagIds': tagIds,
                         'itemsPerGrid': itemsPerGrid,
                         'excludeArticleIds': excludeArticleIds
                     })
    Log(r.url)
    Log(type(r))
    data = json.loads(
        re.search(
            rb'ReactDOM\.hydrate\(React\.createElement\(Components\.TrendingGridModule,(.+?)\), document.getElementById',
            r.content, re.DOTALL).group(1)).get('data')
    modules = data.get('modules')
    TRENDING_GRID.extend(modules)
    loadmore = data.get('loadMoreLink')
    if loadmore and getall:
        url = loadmore.get('url')
        if url:
            _params = urlparse.parse_qs(urlparse.urlparse(url).query)
            TrendingGrid(
                _params.get('fromPage')[0],
                _params.get('toPage')[0],
                _params.get('tagIds')[0],
                _params.get('itemsPerGrid')[0],
                _params.get('excludeArticleIds', [''])[0])
コード例 #2
0
 def setControlImage(self, controlId, label):
     if not controlId:
         Log('controlId {} not recognized'.format(controlId))
         return
     control = self.getControl(controlId)
     if control:
         control.setImage(label)
コード例 #3
0
def GetMediaStream(partner_id, entry_id):
    livestreamer_url = 'hlsvariant://' + media_url.format(partnerId=partner_id,
                                                          entryId=entry_id)
    streams = livestreamer.streams(livestreamer_url)
    mediaUrl = streams['best'].url
    Log(mediaUrl)
    return mediaUrl
コード例 #4
0
 def setControlVisible(self, controlId, visible):
     if not controlId:
         Log('controlId {} not recognized'.format(controlId))
         return
     control = self.getControl(controlId)
     if control:
         control.setVisible(visible)
コード例 #5
0
	def onAction(self,action):
		Log('onAction: {}'.format(action.getId()))
		if action.getId() in [ACTION_NAV_BACK,ACTION_PREVIOUS_MENU]:
			self.Close()
		elif action.getId() in [ACTION_SELECT_ITEM,ACTION_MOUSE_LEFT_CLICK]:
			if self.getFocusId() == self.MENU_LIST:
				self.PlayMedia(self.control_list.getListItem(int(self.control_list.getSelectedPosition())))
コード例 #6
0
	def onClick(self,controlId):
		Log('onClick: {}'.format(controlId))
		if controlId == self.DIALOG_BUTTON_A:
			self.DialogButtonA()
		elif controlId == self.DIALOG_BUTTON_B:
			self.DialogButtonB()
		elif controlId == self.DIALOG_BUTTON_C:
			self.DialogButtonC()
コード例 #7
0
	def onAction(self,action):
		Log('onAction: {}'.format(action.getId()))
		if action.getId() in [ACTION_NAV_BACK,ACTION_PREVIOUS_MENU]:
			self.Close()
		elif action.getId() in [ACTION_UP,ACTION_DOWN,ACTION_PAGE_UP,ACTION_PAGE_DOWN] and self.getFocusId() == self.MAIN_ITEMLIST: 
			self.LoadSubMenu(self.main_control_list.getListItem(int(self.main_control_list.getSelectedPosition())))
		elif action.getId() in [ACTION_SELECT_ITEM,ACTION_MOUSE_LEFT_CLICK]:
			if self.getFocusId() == self.SUB_ITEMLIST:
				self.SubMenuAction(self.sub_control_list.getListItem(int(self.sub_control_list.getSelectedPosition())))
コード例 #8
0
 def setControlImage(self, controlId, img):
     if not controlId:
         return
     control = self.getControl(controlId)
     if control:
         control.setImage(img)
     else:
         Log('controlId {} not recognized'.format(controlId))
         return
コード例 #9
0
	def setControlLabel(self, controlId, label):
		if not controlId:
			return
		control = self.getControl(controlId)
		if control and label:
			control.setLabel(label)
		else:
			Log('controlId {} not recognized'.format(controlId))
			return
コード例 #10
0
	def setControlText(self, controlId,text):
		if not controlId:
			return
		control = self.getControl(controlId)
		if control:
			control.setText(text)
		else:
			Log('controlId {} not recognized'.format(controlId))
			return
コード例 #11
0
	def setControlProgress(self,controlId,percent):
		if not controlId:
			return
		control = self.getControl(controlId)
		if control:
			control.setPercent(percent)
		else:
			Log('controlId {} not recognized'.format(controlId))
			return
コード例 #12
0
 def onAction(self, action):
     Log('onAction: {}'.format(action.getId()))
     if action.getId() in [ACTION_NAV_BACK, ACTION_PREVIOUS_MENU]:
         self.Close()
     elif action.getId() in [ACTION_SELECT_ITEM, ACTION_MOUSE_LEFT_CLICK]:
         if self.getFocusId() == MAIN_LIST:
             d = WindowYoutubePlayListVideos(
                 self.main_list_control.getListItem(
                     int(self.main_list_control.getSelectedPosition())))
             d.doModal()
             del d
コード例 #13
0
 def _DisableUtube(self, listitem):
     cid = listitem.getProperty('channel_id')
     c = self.conn.cursor()
     Log(cid)
     c.execute("UPDATE youtube_list SET enabled=? WHERE youtube_id=?",
               (False, cid))
     c.execute("DELETE FROM youtube_channels WHERE channel_id=?", (cid, ))
     self.conn.commit()
     c.close()
     self.sel_menu_control.reset()
     self.DisableUtube()
コード例 #14
0
	def onAction(self,action):
		Log('onAction: {}'.format(action.getId()))
		if action.getId() in [ACTION_NAV_BACK,ACTION_PREVIOUS_MENU]:
			self.Close()
		elif action.getId() in [ACTION_SELECT_ITEM,ACTION_MOUSE_LEFT_CLICK]:
			if self.getFocusId() == self.ITEMLIST:
				self.MainMenuControl(self.control_list.getListItem(int(self.control_list.getSelectedPosition())))
			elif self.getFocusId() == self.LATESTPOD_LIST:
				self.PlayPod(self.control_list_pod.getListItem(int(self.control_list_pod.getSelectedPosition())))
			elif self.getFocusId() == self.LATESTUTUBE_LIST:
				self.PlayUtube(self.control_list_utube.getListItem(int(self.control_list_utube.getSelectedPosition())))
			elif self.getFocusId() == self.LATESTSPURSTV_LIST:
				self.PlaySpursTv(self.control_list_spurstv.getListItem(int(self.control_list_spurstv.getSelectedPosition())))
コード例 #15
0
 def getHighlights(self, listitem):
     matchdate_str = listitem.getProperty('matchdate_str')
     tag = listitem.getProperty('tag')
     tag_query = '%' + tag + '%'
     partmatchdate_str = 'xx.' + matchdate_str.split('.', 1)[1]
     Log(partmatchdate_str)
     c = self.conn.cursor()
     c.execute("SELECT * FROM spurs_tv_highlights WHERE matchdate=? ",
               (matchdate_str, ))
     a = c.fetchall()
     c.execute(
         "SELECT * FROM spurs_tv_highlights WHERE matchdate=? AND tags LIKE ?",
         (partmatchdate_str, tag_query))
     a = a + c.fetchall()
     return a
コード例 #16
0
 def onAction(self, action):
     Log('onAction: {}'.format(action.getId()))
     if action.getId() in [ACTION_NAV_BACK, ACTION_PREVIOUS_MENU]:
         self.Close()
     elif action.getId() in [ACTION_SELECT_ITEM, ACTION_MOUSE_LEFT_CLICK]:
         if self.getFocusId() == self.FILTER_SEASON:
             self.FilterSeason(
                 self.filter_season_list.getListItem(
                     int(self.filter_season_list.getSelectedPosition())))
         elif self.getFocusId() == self.FILTER_COMP:
             self.FilterComp(
                 self.filter_comp_list.getListItem(
                     int(self.filter_comp_list.getSelectedPosition())),
                 self.filter_season_list.getListItem(
                     int(self.filter_season_list.getSelectedPosition())))
         elif self.getFocusId() == self.GAMES_LIST:
             from . import window_matchcenteritem
             d = window_matchcenteritem.WindowMatchCenterItems(
                 self.games_list.getListItem(
                     int(self.games_list.getSelectedPosition())))
             d.doModal()
             del d
コード例 #17
0
    def LineUpView(self, controlId, lineupKey, isSpurs):
        player_label_bg = os.path.join(addon_path, 'resources', 'skins',
                                       'Default', 'media',
                                       'rc-button-focus.png')
        c = self.conn.cursor()
        pitch = self.getControl(controlId)
        pitch_h = pitch.getHeight()
        pitch_w = pitch.getWidth()
        pitch_x = pitch.getX()
        pitch_y = pitch.getY()
        img_w = 100
        img_h = 100
        teamlineup = self.lineup.get(lineupKey)
        formation = teamlineup.get('Formation')
        Log(formation)
        startlineup = teamlineup.get('StartingLineUp')
        subs = teamlineup.get('Substitutes')
        layout = self.formations.get(formation)
        space_h = (pitch_h - (len(layout) * img_h)) / len(layout)
        for index, row in enumerate(layout):
            y_pos = int((img_h * index) + (space_h * index))
            space_w = (pitch_w - (len(row) * img_w)) / len(row)
            start_pos_x = space_w / 2
            for i, item in enumerate(row):
                x_pos = int(start_pos_x + (img_w * i) + (space_w * i) +
                            pitch_x)
                player = list(
                    filter(lambda d: d.get('FormationPlace') == item,
                           startlineup))
                if isSpurs:
                    c.execute(
                        "SELECT image FROM players_info WHERE shirt_no =?",
                        (int(player[0].get('Number')), ))
                    self.addControl(
                        xbmcgui.ControlImage(x_pos, y_pos, img_w, img_h,
                                             c.fetchone()[0], 2))
                self.addControl(
                    xbmcgui.ControlImage(x_pos, y_pos + img_h, img_w, 20,
                                         player_label_bg))
                self.addControl(
                    xbmcgui.ControlLabel(x_pos,
                                         y_pos + img_h,
                                         img_w,
                                         20,
                                         player[0].get('Name').split(' ',
                                                                     1)[-1],
                                         font='font10',
                                         textColor='0xFF000033',
                                         alignment=0x00000002 | 0x00000004))
        for s, sub in enumerate(subs):
            if isSpurs:
                c.execute("SELECT image FROM players_info WHERE shirt_no =?",
                          (int(sub.get('Number')), ))
                try:
                    img = c.fetchone()[0]
                except TypeError:
                    img = None
                sub_img_w = 50
                sub_img_h = 50
                if self.isHome:
                    startsubpos_x = pitch_x + pitch_w + 5
                    y_pos = (s * sub_img_h) + pitch_y
                    if img:
                        self.addControl(
                            xbmcgui.ControlImage(int(startsubpos_x),
                                                 int(y_pos), sub_img_w,
                                                 sub_img_h, img, 2))
                    self.addControl(
                        xbmcgui.ControlImage(int(startsubpos_x + sub_img_w),
                                             int(y_pos + sub_img_h / 2), 100,
                                             20, player_label_bg))
                    self.addControl(
                        xbmcgui.ControlLabel(int(startsubpos_x + sub_img_w),
                                             int(y_pos + sub_img_h / 2),
                                             100,
                                             20,
                                             sub.get('Name').split(' ', 1)[-1],
                                             font='font10',
                                             textColor='0xFF000033',
                                             alignment=0x00000002
                                             | 0x00000004))
                elif self.isAway:
                    startsubpos_x = pitch_x - 155
                    y_pos = (pitch_y + pitch_h) - ((s + 1) * sub_img_h)
                    if img:
                        self.addControl(
                            xbmcgui.ControlImage(int(startsubpos_x),
                                                 int(y_pos), sub_img_w,
                                                 sub_img_h, img, 2))
                    self.addControl(
                        xbmcgui.ControlImage(int(startsubpos_x + sub_img_w),
                                             int(y_pos + sub_img_h / 2), 100,
                                             20, player_label_bg))
                    self.addControl(
                        xbmcgui.ControlLabel(int(startsubpos_x + sub_img_w),
                                             int(y_pos + sub_img_h / 2),
                                             100,
                                             20,
                                             sub.get('Name').split(' ', 1)[-1],
                                             font='font10',
                                             textColor='0xFF000033',
                                             alignment=0x00000002
                                             | 0x00000004))

            else:
                if not self.isAway:
                    startsubpos_x = pitch_x - 105
                    y_pos = (pitch_y + pitch_h) - ((s + 1) * 20)
                    self.addControl(
                        xbmcgui.ControlImage(int(startsubpos_x), int(y_pos),
                                             100, 20, player_label_bg))
                    self.addControl(
                        xbmcgui.ControlLabel(int(startsubpos_x),
                                             int(y_pos),
                                             100,
                                             20,
                                             sub.get('Name').split(' ', 1)[-1],
                                             font='font10',
                                             textColor='0xFF000033',
                                             alignment=0x00000002
                                             | 0x00000004))
                elif not self.isHome:
                    startsubpos_x = pitch_x + pitch_w + 5
                    y_pos = (s * 20) + pitch_y
                    self.addControl(
                        xbmcgui.ControlImage(int(startsubpos_x), int(y_pos),
                                             100, 20, player_label_bg))
                    self.addControl(
                        xbmcgui.ControlLabel(int(startsubpos_x),
                                             int(y_pos),
                                             100,
                                             20,
                                             sub.get('Name').split(' ', 1)[-1],
                                             font='font10',
                                             textColor='0xFF000033',
                                             alignment=0x00000002
                                             | 0x00000004))
コード例 #18
0
 def onAction(self, action):
     Log('onAction: {}'.format(action.getId()))
     if action.getId() in [ACTION_NAV_BACK, ACTION_PREVIOUS_MENU]:
         self.Close()
コード例 #19
0
 def onClick(self, controlId):
     Log('onClick: {}'.format(controlId))
     if controlId == self.FILTER_SEARCH:
         self.SearchGames()