How to use key_value method in localstack

Best Python code snippet using localstack_python

gamekings_const.py

Source:gamekings_const.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: UTF-8 -*-3import sys4import os5import xbmc6import xbmcaddon7from bs4 import BeautifulSoup8#9# Constants10# 11ADDON = "plugin.video.gamekings"12SETTINGS = xbmcaddon.Addon()13LANGUAGE = SETTINGS.getLocalizedString14IMAGES_PATH = os.path.join(xbmcaddon.Addon().getAddonInfo('path'), 'resources')15BASE_URL_GAMEKINGS_TV = "https://www.gamekings.tv/"16TWITCH_URL_GAMEKINGS_TV = "https://player.twitch.tv/?channel=gamekings"17PREMIUM_ONLY_VIDEO_TITLE_PREFIX = '* '18LOGIN_URL = 'https://www.gamekings.tv/wp-login.php'19NUMBER_OF_ENCODED_DIGITS_FOR_ONE_DECRYPTED_DIGIT = 220MASTER_DOT_M3U8 = "master.m3u8"21VQ4K = '4k'22VQ1080P = '1080p'23VQ720P = '720p'24VQ480P = '480p'25VQ360P = '360p'26VQ1080N = '1080n'27VQ720N = '720n'28VQ480N = '480n'29VQ360N = '360n'30HTTPSCOLONSLASHSLASH_ENCODED = "8647470737a3f2f27"31END_TAG = "</"32STREAM = "STREAM"33STOPDECODINGNOW = "STOPDECODINGNOW"34DATE = "2021-04-29"35VERSION = "1.2.20-SNAPSHOT"36if sys.version_info[0] > 2:37 unicode = str38def convertToUnicodeString(s, encoding='utf-8'):39 """Safe decode byte strings to Unicode"""40 if isinstance(s, bytes): # This works in Python 2.7 and 3+41 s = s.decode(encoding)42 return s43def convertToByteString(s, encoding='utf-8'):44 """Safe encode Unicode strings to bytes"""45 if isinstance(s, unicode):46 s = s.encode(encoding)47 return s48def log(name_object, object):49 try:50 # Let's try and remove any non-ascii stuff first51 object = object.encode('ascii', 'ignore')52 except:53 pass54 try:55 xbmc.log("[ADDON] %s v%s (%s) debug mode, %s = %s" % (56 ADDON, VERSION, DATE, name_object, convertToUnicodeString(object)), xbmc.LOGDEBUG)57 except:58 xbmc.log("[ADDON] %s v%s (%s) debug mode, %s = %s" % (59 ADDON, VERSION, DATE, name_object, "Unable to log the object due to an error while converting it to an unicode string"), xbmc.LOGDEBUG)60def getSoup(html,default_parser="html5lib"):61 soup = BeautifulSoup(html, default_parser)62 return soup63def decodeString(encoded_string):64 chunks = len(encoded_string)//NUMBER_OF_ENCODED_DIGITS_FOR_ONE_DECRYPTED_DIGIT65 chunk_size = NUMBER_OF_ENCODED_DIGITS_FOR_ONE_DECRYPTED_DIGIT66 decoded_string = ""67 for i in range(0, chunks * NUMBER_OF_ENCODED_DIGITS_FOR_ONE_DECRYPTED_DIGIT, chunk_size):68 encoded_chunk = encoded_string[i:i+chunk_size]69 decoded_digit = decryptEncodedDigit(encoded_chunk)70 # log("decoded_digit", decoded_digit)71 if decoded_digit == STOPDECODINGNOW:72 # exit the loop73 break74 decoded_string = decoded_string + str(decoded_digit)75 # log("decoded_string", decoded_string)76 # log("final decoded_string", decoded_string)77 return decoded_string78# No idea what kinda magic the encoding is.79# This is the encoding that should work for the m3u8 url part in the encoded container.80# It won't work on the rest of the container.81def decryptEncodedDigit(encoded_digit):82 key_value = {}83 key_value['16'] = 'a'84 key_value['26'] = 'b'85 key_value['36'] = 'c'86 key_value['46'] = 'd'87 key_value['56'] = 'e'88 key_value['66'] = 'f'89 key_value['76'] = 'g'90 key_value['86'] = 'h'91 key_value['96'] = 'I'92 key_value['A6'] = 'j'93 key_value['B6'] = 'k'94 key_value['C6'] = 'l'95 key_value['D6'] = 'm'96 key_value['E6'] = 'n'97 key_value['F6'] = 'o'98 key_value['07'] = 'p'99 key_value['17'] = 'q'100 key_value['27'] = 'r'101 key_value['37'] = 's'102 key_value['47'] = 't'103 key_value['57'] = 'u'104 key_value['67'] = 'v'105 key_value['77'] = 'w'106 key_value['87'] = 'x'107 key_value['97'] = 'y'108 key_value['A7'] = 'z'109 key_value['14'] = 'A'110 key_value['24'] = 'B'111 key_value['34'] = 'C'112 key_value['44'] = 'D'113 key_value['54'] = 'E'114 key_value['64'] = 'F'115 key_value['74'] = 'G'116 key_value['84'] = 'H'117 key_value['94'] = 'I'118 key_value['A4'] = 'J'119 key_value['B4'] = 'K'120 key_value['C4'] = 'L'121 key_value['D4'] = 'M'122 key_value['E4'] = 'N'123 key_value['F4'] = 'O'124 key_value['05'] = 'P'125 key_value['15'] = 'Q'126 key_value['25'] = 'R'127 key_value['35'] = 'S'128 key_value['45'] = 'T'129 key_value['55'] = 'U'130 key_value['65'] = 'V'131 key_value['75'] = 'W'132 key_value['85'] = 'X'133 key_value['95'] = 'Y'134 key_value['A5'] = 'Z'135 key_value['03'] = '0'136 key_value['13'] = '1'137 key_value['23'] = '2'138 key_value['33'] = '3'139 key_value['43'] = '4'140 key_value['53'] = '5'141 key_value['63'] = '6'142 key_value['73'] = '7'143 key_value['83'] = '8'144 key_value['93'] = '9'145 key_value['A3'] = ':'146 key_value['E2'] = '.'147 key_value['F2'] = '/'148 key_value['F5'] = '_'149 encoded_digit = str(encoded_digit).capitalize()150 # log("encoded_digit", encoded_digit)151 try:152 decoded_digit = key_value[encoded_digit]153 # log("decoded_digit", decoded_digit)154 # Only the encoded m3u8 url part in the container, can be decoded.155 # When we get a decoding error, we assume (ulp!) that we are past the m3u8 part and can quit decoding.156 except:157 log("exception while decoding this digit", encoded_digit)158 decoded_digit = STOPDECODINGNOW...

Full Screen

Full Screen

solution.py

Source:solution.py Github

copy

Full Screen

1def get_value(dictobj, key_value, key_exists = False):2 for k,v in dictobj.items():3 if k==key_value and key_exists == False:4 key_exists=True5 if key_exists==True:6 if isinstance(v, dict):7 get_value(v, key_value, key_exists)8 else:9 print("{} exists in the object, its value is :{}".format(key_value,v))10 else:11 get_value(v, key_value, key_exists)12if __name__ == "__main__":13 # Test Case : 114 dictobj= {'a':{'b':{'c':'d'}}}15 # Test 116 key_value = 'a'17 get_value(dictobj, key_value)18 # Test 219 key_value = 'b'20 get_value(dictobj, key_value)21 # Test 322 key_value = 'c'23 get_value(dictobj, key_value)24 # Test Case : 225 dictobj = {'x':{'y':{'z':'a'}}} 26 # Test 427 key_value = 'x'28 get_value(dictobj, key_value)29 # Test 530 key_value = 'y'31 get_value(dictobj, key_value)32 # Test 633 key_value = 'z'...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful