def test_actionIndex(mocker, actionIndex, main, xbmcplugin, xbmcgui): main() c = u"[COLOR FFFFF000]{}[/COLOR]" expected_results = [ (handle, plugin.format("search"), c.format(u"Поиск"), False), (handle, plugin.format("items"), c.format(u"Последние"), True), (handle, plugin.format("items?sort=-rating"), c.format(u"Популярные"), True), (handle, plugin.format("tv"), c.format(u"ТВ"), True), (handle, plugin.format("bookmarks"), c.format(u"Закладки"), True), (handle, plugin.format("watching"), c.format(u"Я смотрю"), True), (handle, plugin.format("collections"), c.format(u"Подборки"), True), (handle, plugin.format("index?type=movie"), u"Фильмы", True), (handle, plugin.format("index?type=serial"), u"Сериалы", True), (handle, plugin.format("index?type=tvshow"), u"ТВ шоу", True), (handle, plugin.format("index?type=4k"), u"4K", True), (handle, plugin.format("index?type=3d"), u"3D", True), (handle, plugin.format("index?type=concert"), u"Концерты", True), (handle, plugin.format("index?type=documovie"), u"Документальные фильмы", True), (handle, plugin.format("index?type=docuserial"), u"Документальные сериалы", True) ] for result in expected_results: handle_, link, title, is_directory = result xbmcgui.ListItem.assert_any_call(title.encode("utf-8")) li = xbmcgui.ListItem() xbmcplugin.addDirectoryItem.assert_any_call(handle_, link, li, is_directory) xbmcplugin.endOfDirectory.assert_called_once_with(handle)
def test_actionItems(main, actionItems, xbmcgui, xbmcplugin): main() s = plugin i = [item["id"] for item in actionItems_response["items"]] t = [ item["title"].encode("utf-8") for item in actionItems_response["items"] ] expected_results = [ (handle, s.format("play?{}".format(urlencode({ "id": i[0], "title": t[0] }))), t[0], False), (handle, s.format("play?{}".format(urlencode({ "id": i[1], "title": t[1] }))), t[1], False), (handle, s.format("view?id={}".format(i[2])), t[2], True), (handle, s.format("view?id={}".format(i[3])), t[3], True), (handle, s.format("view?id={}".format(i[4])), t[4], True) ] for result in expected_results: handle_, link, title, is_directory = result xbmcgui.ListItem.assert_any_call(title) li = xbmcgui.ListItem() xbmcplugin.addDirectoryItem.assert_any_call(handle_, link, li, is_directory) xbmcplugin.endOfDirectory.assert_called_once_with(handle)
def test_actionView_standalone_episodes(request, main, actionView_standalone_episodes, xbmcgui, xbmcplugin): main() item = actionView_without_seasons_response["item"] for video in item["videos"]: episode_title = "e{:02d}".format(video["number"]) if video["title"]: episode_title = "{} | {}".format(episode_title, video["title"].encode("utf-8")) link = plugin.format("play?{}".format( urlencode({ "id": item["id"], "title": episode_title, "number": video["number"], "video": json.dumps(video) }))) xbmcgui.ListItem.assert_any_call(episode_title, iconImage=video["thumbnail"], thumbnailImage=video["thumbnail"]) li = xbmcgui.ListItem() li.setInfo.assert_any_call("Video", {"playcount": video["watched"]}) li.setArt.assert_any_call({"poster": item["posters"]["big"]}) li.setProperty.assert_any_call("IsPlayable", "true") xbmcplugin.addDirectoryItem.assert_any_call(handle, link, xbmcgui.ListItem(), False) xbmcplugin.setContent.assert_called_once_with(handle, "episodes") xbmcplugin.endOfDirectory.assert_called_once_with(handle)
def test_actionPlay(actionPlay, main, xbmcgui, xbmcplugin): stream, video_quality = actionPlay main() title = actionPlay_response["item"]["title"].encode("utf-8") xbmcgui.ListItem.assert_called_with(title) li = xbmcgui.ListItem(title) link = "https://example.com/{}/{}".format(stream, video_quality.rstrip("p")) li.setPath.assert_called_once_with(link) xbmcplugin.setResolvedUrl.assert_called_once_with(handle, True, li)
def test_actionView_seasons(main, actionView_seasons, xbmcgui, xbmcplugin): main() i = actionView_seasons_response["item"]["id"] seasons = actionView_seasons_response["item"]["seasons"] for season in seasons: xbmcgui.ListItem.assert_any_call("Сезон {}".format(season["number"])) link = plugin.format("view_season_episodes?season={}&id={}".format( season["number"], i)) xbmcplugin.addDirectoryItem.assert_any_call(handle, link, xbmcgui.ListItem(), True) xbmcplugin.endOfDirectory.assert_called_once_with(handle)
addon = xbmcaddon.Addon() addon_id = addon.getAddonInfo('id') version = addon.getAddonInfo('version') autostart = True if addon.getSetting("autostart").lower() == 'true' else False wolAfterStandby = True if addon.getSetting("wolAfterStandby").lower() == 'true' else False wolDelayOnLaunch = int(addon.getSetting("wolDelayOnLaunch")) * 1000 wolDelayAfterStandby = int(addon.getSetting("wolDelayAfterStandby")) * 1000 if autostart: import default if wolDelayOnLaunch > 0: xbmc.sleep(wolDelayOnLaunch) default.main(True) if wolAfterStandby: xbmc.log('[{} {}]: Waiting for resume from standby'.format(addon_id, version), xbmc.LOGDEBUG) previousTime = int(time.time()) while not xbmc.Monitor().abortRequested: elapsedTime = int(time.time()) - previousTime if elapsedTime > 5: if wolDelayAfterStandby > 0: xbmc.sleep(wolDelayAfterStandby) xbmc.log('[{} {}]: Start WOL script after return ' 'from standby (took {} secs)'.format(addon_id, version, int(time.time() - previousTime)), xbmc.LOGDEBUG) default.main(True)
# Copyright (C) 2013 # Written on behalf of Flirc # by Sean Poyser ([email protected]) # import utils utils.log("Service Starting") try: if utils.getSetting('autoStart') == 'true': utils.log("Initialising Automatic Programming Mode") import default default.main(utils.MINIMAL, True) except Exception, e: utils.log("******************* ERROR IN SERVICE *******************") utils.log(e)
def main(): # main_img is used as screen buffer, all image composing/drawing is done in PIL, # the main_img is then copied to the display (drawing on the disp itself is no fun) # main_img = Image.new("1", (epd2in9.EPD_WIDTH, epd2in9.EPD_HEIGHT)) # draw = ImageDraw.Draw(main_img) # fonts for drawing within PIL andale_ttf_small = ImageFont.truetype( "source/fonts/andale_mono/AndaleMono.ttf", 16) andale_ttf_large = ImageFont.truetype( "source/fonts/andale_mono/AndaleMono.ttf", 26) epd = epd2in9.EPD() epd.init(epd.lut_full_update) # For simplicity, the arguments are explicit numerical coordinates image = Image.new('1', (epd2in9.EPD_WIDTH, epd2in9.EPD_HEIGHT), 255) # 255: clear the frame draw = ImageDraw.Draw(image) # perform initial setup of display and GPIO button_logic.setup_gpio(change_state_pin, trigger_pin, yellow_led, blue_led, green_led) # announce that we're ready GPIO.output(green_led, True) # FIXME: draw to epaper display default.main() while True: starttime = time.time() state_button = GPIO.input(change_state_pin) trigger_button = GPIO.input(trigger_pin) if state_button == False: button_logic.change_state(yellow_led, blue_led, green_led) print "Button press!" time.sleep(0.2) elif trigger_button == False: text, pos_x, pos_y = generate_sentence(font=andale_ttf_small) # create binary image filled with white base_image = Image.new("1", size=(epd2in9.EPD_WIDTH, epd2in9.EPD_HEIGHT), color=255) # create the text image text_image = Image.new('1', (epd2in9.EPD_HEIGHT, epd2in9.EPD_WIDTH)) # draw the text and rotate it -90 degrees so that it fits the portait orientation text_draw_buffer = ImageDraw.Draw(text_image) text_draw_buffer.text((pos_x, pos_y), text, font=andale_ttf_small, fill=255) text_image = text_image.rotate(270, expand=1) result = ImageChops.multiply(text_image, base_image) result.save("result.png") epd.clear_frame_memory(0xFF) epd.set_frame_memory(result, 0, 0) epd.display_frame() epd.delay_ms(2000)
# Wake-On-LAN import xbmcaddon, sys, time # Read Settings settings = xbmcaddon.Addon( id="script.advanced.wol" ) autostart = settings.getSetting("autostart") wolAfterStandby = settings.getSetting("wolAfterStandby") wolDelayOnLaunch = int(settings.getSetting("wolDelayOnLaunch")) wolDelayAfterStandby = int(settings.getSetting("wolDelayAfterStandby")) if (autostart == "true"): import default if (wolDelayOnLaunch > 0): xbmc.sleep(wolDelayOnLaunch*1000) default.main(True) if (wolAfterStandby == "true"): print "script.advanced.wol: Waiting for resume from standby" previousTime = time.time() while (not xbmc.abortRequested): elapsedTime = time.time()-previousTime if ( elapsedTime > 5): if (wolDelayAfterStandby > 0): xbmc.sleep(wolDelayAfterStandby*1000) print "script.advanced.wol: Start WOL script after return from standby (Standby took "+str(time.time()-previousTime)+" sec.)" default.main(True) print "script.advanced.wol: Waiting for resume from standby" previousTime = time.time() xbmc.sleep(1000) else: previousTime = time.time()