def get_streams_by_game(gamename): html = webrequest.get_url(twitch.streams_per_game() % gamename) json_file = json.loads(html) items = [] for stream in json_file['streams']: icon = None if user_settings['enable_previews'] == 'false': icon = settings.get_image(stream['channel']['logo'], stream['channel']['name']) else: icon = settings.get_image(stream['preview']['small'], "video_preview_%s" % stream['channel']['name']) items.append(workflow.create_item( arg = stream['channel']['url'], title = "%s (%s viewers)" % (stream['channel']['name'], stream['viewers']), subtitle = stream['channel']['status'], icon = icon)) workflow.output_items(items)
def get_channels(channel_list): html = webrequest.get_url(twitch.stream_objects() % (','.join(channel_list))) json_file = json.loads(html) streams = [] for stream in json_file['streams']: streamer = [ stream['channel']['url'], stream['channel']['name'] + " - " + stream['channel']['game'], stream['channel']['status'], stream['channel']['logo'], stream['viewers'] ] streams.append(streamer) sorted(streams, key=lambda x: x[4]) items = [] if len(streams) == 0: items.append(workflow.create_item()) else: for streamer in streams: items.append( workflow.create_item(arg=streamer[0], title=streamer[1], subtitle=streamer[2], icon=settings.get_image( streamer[3], streamer[1]))) workflow.output_items(items)
def __init__(self, size): super(CookButton, self).__init__() self.size = size image_path = 'images/stove.png' self.image = settings.get_image(image_path).convert_alpha() self.image = main.pygame.transform.scale(self.image, (size, size)) self.image_rect = self.image.get_rect() self.image_rect.topleft = (2 * settings.WINDOWWIDTH / 3, settings.WINDOWHEIGHT - size)
def __init__(self, size): super(Recycle, self).__init__() self.size = size image_path = 'images/recycle.png' #self.image = main.pygame.image.load(image_path).convert_alpha() self.image = settings.get_image(image_path).convert_alpha() self.image = main.pygame.transform.scale(self.image, (size, size)) self.image_rect = self.image.get_rect() self.image_rect.bottomright = (settings.WINDOWWIDTH, settings.WINDOWHEIGHT)
def get_followed_channels(): json_file = settings.load_followed(user_settings['user']) items = [] for follow in json_file['follows']: channel = follow['channel'] items.append(workflow.create_item( arg = channel['url'], title = channel['name'], subtitle = channel['game'], icon = settings.get_image(channel['logo'], channel['name']))) workflow.output_items(items)
def search_streams(term): html = webrequest.get_url(twitch.search_channels() % term) json_file = json.loads(html) items = [] for channel in json_file['channels']: items.append(workflow.create_item( arg = channel['url'], title = channel['name'], subtitle = channel['game'], icon = settings.get_image(channel['logo'], "video_preview_%s" % channel['name']))) workflow.output_items(items)
def get_top_games(): html = webrequest.get_url(twitch.top_games()) json_file = json.loads(html) items = [] for game in json_file['top']: game_name = game['game']['name'] items.append(workflow.create_item( arg = game_name, title = game_name, subtitle = "%s Viewers" % game['game']['popularity'], icon = settings.get_image(game['game']['box']['small'], game_name))) workflow.output_items(items)
def get_followed_channels(): json_file = settings.load_followed(user_settings['user']) items = [] for follow in json_file['follows']: channel = follow['channel'] items.append( workflow.create_item(arg=channel['url'], title=channel['name'], subtitle=channel['game'], icon=settings.get_image( channel['logo'], channel['name']))) workflow.output_items(items)
def get_streams_by_game(gamename): html = webrequest.get_url(twitch.streams_per_game() % gamename) json_file = json.loads(html) items = [] for stream in json_file['streams']: icon = None if user_settings['enable_previews'] == 'false': icon = settings.get_image(stream['channel']['logo'], stream['channel']['name']) else: icon = settings.get_image( stream['preview']['small'], "video_preview_%s" % stream['channel']['name']) items.append( workflow.create_item( arg=stream['channel']['url'], title="%s (%s viewers)" % (stream['channel']['name'], stream['viewers']), subtitle=stream['channel']['status'], icon=icon)) workflow.output_items(items)
def search_games(search): html = webrequest.get_url(twitch.search_games() % search) json_file = json.loads(html) items = [] for game in json_file['games']: game_name = game['name'] items.append( workflow.create_item(arg=game_name, title=game_name, subtitle="%s Viewers" % game['popularity'], icon=settings.get_image( game['box']['small'], game_name))) workflow.output_items(items)
def search_streams(term): html = webrequest.get_url(twitch.search_channels() % term) json_file = json.loads(html) items = [] for channel in json_file['channels']: items.append( workflow.create_item(arg=channel['url'], title=channel['name'], subtitle=channel['game'], icon=settings.get_image( channel['logo'], "video_preview_%s" % channel['name']))) workflow.output_items(items)
def __init__(self, text, center, bank, path): super(Block, self).__init__() self.drag = False self.text = text self.bank = bank # Use to keep track of static bank blocks which don't ever move/disappear self.snapped = False # Use to update BOARD state when you pick up a snapped block self.path = path self.height = int(settings.WINDOWHEIGHT / 24) # self.blockSurf = main.pygame.Surface((10 * length, 20)) self.blockSurf = settings.get_image(path).convert_alpha() self.blockSurf = main.pygame.transform.scale( self.blockSurf, (self.height * 2, self.height)) self.blockRect = self.blockSurf.get_rect() # self.textSurf = settings.BASICFONT.render(text, True, settings.WHITE) # self.textRect = self.textSurf.get_rect() self.setPos(center)
def get_videos(channelname): html = webrequest.get_url(twitch.videos() % channelname) json_file = json.loads(html) items = [] index = 0 for video in json_file['videos']: filename = 'video_preview_%s_%d' % (video['channel']['name'], index) icon = None if user_settings['enable_previews'] == 'false': icon = 'Images/%s' % channelname else: icon = settings.get_image(video['preview'], filename) items.append(workflow.create_item( arg = video['url'], title = video['title'], subtitle = "%s (%s views)" % (video['created_at'].split('T')[0], video['views']), icon = icon)) index += 1 workflow.output_items(items)
def get_channels(channel_list): html = webrequest.get_url(twitch.stream_objects() % (','.join(channel_list))) json_file = json.loads(html) streams = [] for stream in json_file['streams']: streamer = [stream['channel']['url'], stream['channel']['name'] + " - " + stream['channel']['game'], stream['channel']['status'], stream['channel']['logo'], stream['viewers']] streams.append(streamer) sorted(streams, key=lambda x: x[4]) items = [] if len(streams) == 0: items.append(workflow.create_item()) else: for streamer in streams: items.append(workflow.create_item( arg = streamer[0], title = streamer[1], subtitle = streamer[2], icon = settings.get_image(streamer[3], streamer[1]))) workflow.output_items(items)
def get_videos(channelname): html = webrequest.get_url(twitch.videos() % channelname) json_file = json.loads(html) items = [] index = 0 for video in json_file['videos']: filename = 'video_preview_%s_%d' % (video['channel']['name'], index) icon = None if user_settings['enable_previews'] == 'false': icon = 'Images/%s' % channelname else: icon = settings.get_image(video['preview'], filename) items.append( workflow.create_item( arg=video['url'], title=video['title'], subtitle="%s (%s views)" % (video['created_at'].split('T')[0], video['views']), icon=icon)) index += 1 workflow.output_items(items)
def __init__(self, path): super(Tooltip, self).__init__() size = 0 self.image = settings.get_image(path).convert_alpha() self.image = main.pygame.transform.scale(self.image, (size, size)) self.image_rect = self.image.get_rect()