def plot_lhd_value(lhd, header): plt.plot(lhd) ofile = header + "_lhd.png" plt.savefig(ofile) plt.clf() utility.log("# " + ofile + " min=" + str(min(lhd)) + " max=" + str(max(lhd)))
def cache(): try: xbmcvfs.rmdir(utility.cache_dir(), force=True) utility.log('Cache folder deleted.') utility.notification(utility.get_string(30309)) except Exception: pass
def update(self, requestModel, httpRequestResponse): """ Allows for new data to be stored regarding our already stored requests. They are persisted to disk for reduced RAM usage. In particular, this method is called when requests are repeated, and new information is stored regarding those responses, such as the status code or the response length. It is safe to call this method from multiple threads because it implements a lock. Args: requestModel: the RequestModel that was modified. Because of python internals, this is a pointer to the same object present in self.endpoints[x].request, and can therefore be modified directly. httpRequestResponse: the HttpRequestResponse object returned by performing the new request. """ with self.lock: if not httpRequestResponse.response: msg = "No response received on update call() for %s. Is the server now offline?" % (requestModel.analyzedRequest.url) log(msg) raise NoResponseException(msg) httpRequestResponse = self.callbacks.saveBuffersToTempFiles(httpRequestResponse) requestModel.repeatedHttpRequestResponse = httpRequestResponse requestModel.repeatedAnalyzedResponse = self.callbacks.helpers.analyzeResponse(httpRequestResponse.response) requestModel.repeatedAnalyzedRequest = self.callbacks.helpers.analyzeRequest(httpRequestResponse.request) requestModel.repeated = True self.fireTableDataChanged()
def timeExtract(df, config): print(df.keys()) time_cols = [c for c in list(df.keys()) if c.startswith(TIME_PREFIX)] for c in config['test_time']: tmp = config['test_time'][c] if tmp['hour'] >= MIN_HOUR_CONSIDER: df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + HOUR_SUFFIX] = df[c].dt.hour.apply(str).astype( 'category') if tmp['day'] >= MIN_DAY_CONSIDER: df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + WKD_SUFFIX] = df[c].dt.weekday.apply(str).astype( 'category') if tmp['month'] >= MIN_MONTH_CONSIDER: df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + MONTH_SUFFIX] = df[c].dt.month.apply(str).astype( 'category') df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + MIN_SUFFIX] = df[c].dt.minute.apply(str).astype('category') print(time_cols) for c in time_cols: if 'table' in c: tot_second = (df.iloc[config[CONSTANT.TRAIN_DATA_LENGTH]:][c].max() - df.iloc[config[CONSTANT.TRAIN_DATA_LENGTH]:][c].min()).total_seconds() log(('time last', c, tot_second / 3600, tot_second / 3600 / 24, tot_second / 3600 / 24 / 30)) if tot_second / 3600 >= 12: df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + HOUR_SUFFIX] = df[c].dt.hour.apply(str).astype( 'category') if tot_second / 3600 / 24 >= MIN_DAY_CONSIDER: df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + WKD_SUFFIX] = df[c].dt.weekday.apply(str).astype( 'category') if tot_second / 3600 / 24 / 30 >= MIN_MONTH_CONSIDER: df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + MONTH_SUFFIX] = df[c].dt.month.apply(str).astype( 'category') df[CONSTANT.CATEGORY_PREFIX + TIME_SUFFIX + c + MIN_SUFFIX] = df[c].dt.minute.apply(str).astype('category') df.drop(time_cols, axis=1, inplace=True)
def __init__(self, login, repository): self.repository = repository self.count = 0 self.contributed_commit = 0 self.total_commit = 0 self.rate = 0 repository.validate_code() if repository.is_code: log('valid code repo', repository.name_with_owner) q = Repository.query_for_contributors(repository.name_with_owner) try: cs = API.get_v3(q) except HTTPError: cs = [] for c in cs: _login = c['author']['login'] total = c['total'] self.total_commit += total if _login == login: self.contributed_commit = total if self.total_commit != 0: self.rate = self.contributed_commit / self.total_commit self.count = repository.start_count * self.rate
def velohero_process_show(args): log("execute_vh_show", "start") velohero_check_sso_login() tree = load_workout_data(args.workout_id) # log("response", str(r.text)) print_simple_input(tree, 'workout_date') print_simple_input(tree, 'workout_start_time') print_simple_input(tree, 'workout_dist_km') print_simple_input(tree, 'workout_asc_m') print_simple_input(tree, 'workout_dur_time') print_simple_input(tree, 'workout_dsc_m') print_simple_input(tree, 'workout_alt_min_m') print_simple_input(tree, 'workout_alt_max_m') print_simple_input(tree, 'workout_spd_avg_kph') print_simple_input(tree, 'workout_spd_max_kph') print_simple_input(tree, 'workout_hr_avg_bpm') print_simple_input(tree, 'workout_hr_max_bpm') print_textarea(tree, 'workout_comment') print("") print_select_values(tree, "sport_id") print("") print_select_values(tree, "type_id") print("") print_select_values(tree, "route_id") print("") print_select_values(tree, "equipment_ids") log("execute_vh_show", "start")
def consumer(base_socket, contour_id, send_socket): context = zmq.Context() contour_receiver = context.socket(zmq.PULL) contour_receiver.connect("tcp://192.168.43.144:" + str(int(base_socket) + int(contour_id) // 2)) # send work contour_sender = context.socket(zmq.PUSH) contour_sender.connect("tcp://127.0.0.1:" + send_socket) while True: result = contour_receiver.recv_pyobj() contours = skimage.measure.find_contours(result["img"], 0.8) boxes = [] for box in contours: boundaries = {} boundaries["Xmin"] = int(np.min(box[:, 1])) boundaries["Xmax"] = int(np.max(box[:, 1])) boundaries["Ymin"] = int(np.min(box[:, 0])) boundaries["Ymax"] = int(np.max(box[:, 0])) boxes.append(boundaries) contour_sender.send_pyobj({ "frame_no": result["frame_no"], "res": boxes }) log("frame no" + str(result["frame_no"]) + " processed successfully", contour_id)
def process_load(args): log("process_load", "start") if args.info: print_info() return if args.file: create_load(args.file) elif args.directory: create_load(get_next_track_file(args.directory)) else: dir = config.get_download_dir() if dir is None: exit_on_error("No load directory configured. Use 'heroscript config --load_directory PATH' or use " "an optional argument '--file FILE' or '--directory DIRECTORY'.") else: create_load(get_next_track_file(dir)) if args.strava: load_strava_activity() log("process_load", "end")
def add_store_and_item_and_delete_again_store_first(): store = models.StoreModel("StoreToAddFkTest") store.save_to_db() item1 = models.ItemModel('item1FkTest', 9.98, store.id) item2 = models.ItemModel('item2FkTest', 8.98, store.id) item1.save_to_db() item2.save_to_db() count_items_for_store(store.id) print("Item_Count from LogicRule: {}".format(store.item_count)) try: store.delete_from_db() except ConstraintException as e: print("expected exception: {} ".format(e)) session = db.Session() session.rollback() except Exception: session = db.Session() session.rollback() util.log( "Missing Constraint exception: 'Delete rejected - items has rows'") finally: count_items_for_store(store.id) item1.delete_from_db() item2.delete_from_db() count_items_for_store(store.id) store.delete_from_db() print("Finally Delete Store and Items in correct order")
def load(): if utility.get_setting("selected_profile"): connect.load_site(utility.profile_switch_url + utility.get_setting("selected_profile")) connect.save_session() else: utility.log("Load profile: no stored profile found!", loglevel=xbmc.LOGERROR) get_my_list_change_authorisation()
def feature_calculate(g, data, column_names, save_to): pairs = list(map(lambda x: (x[0], x[1]), data)) jaccard = nx.jaccard_coefficient(g, pairs) preferential = nx.preferential_attachment(g, pairs) rai = nx.resource_allocation_index(g, pairs) # shortest path total = len(data) current = 0 for row_data in zip(data, jaccard, preferential, rai): row = row_data[0] try: thisjaccard = row_data[1][2] except: thisjaccard = -1 try: thispreferential = row_data[2][2] except: thispreferential = -1 try: thisrai = row_data[3][2] except: thisrai = -1 # pred = row_data[1] # resource_allocation_index = pred[2] if current % 1000 == 0: ut.log("calculating {}/{}...".format(current, total)) path_length = 99999 try: path = nx.shortest_path(g, row[0], row[1], 'weight') path_length = len(path) except: pass # shortest path row.insert(-1, path_length) # jaccard row.insert(-1, thisjaccard) # preferential row.insert(-1, thispreferential) # rai row.insert(-1, thisrai) current += 1 original_columns_titles = list(column_names) original_columns_titles.insert(-1, "shortest_path_count") original_columns_titles.insert(-1, "jaccard") original_columns_titles.insert(-1, "preferential") original_columns_titles.insert(-1, "rai") data.insert(0, original_columns_titles) ut.write_list_csv(save_to, data)
def main(): # Load config load_config() for monitor_info in settings.MONITOR_INFOS: try: # Get topic list topic_list = get_topic_list(monitor_info['board_url']) # Get new topic list new_topic_list = get_new_topic_list(topic_list, monitor_info['board_url']) # Get spam topics topic_to_delete = [] for topic in new_topic_list: if is_title_match(topic['title']) or is_topic_content_match(topic['url']): topic_to_delete.append(topic) log('Spam <%s> detected.' % topic['title']) # Delete spam topics if len(topic_to_delete) > 0: admin = Admin.login( monitor_info['login_username'], monitor_info['login_password'], monitor_info['board_url'] ) if admin is not None: for topic in topic_to_delete: admin.delete_topic(topic['url']) admin.clean() except Exception, e: log(unicode(traceback.format_exc())) continue
def feed(self, data): try: HTMLParser.feed(self, data) return self._topic_list except Exception, e: log(unicode(traceback.format_exc())) return None
def repositories_from_nodes(cls, nodes): log('repositories_from_nodes') log_dict(nodes) for node in nodes: n = node['node'] r = cls(n) yield r
def choose(): profiles = [] content = utility.decode(connect.load_site(utility.profile_url)) match = json.loads(content)['profiles'] for item in match: profile = { 'name': item['firstName'], 'token': item['guid'], 'is_kid': item['experience'] == 'jfk' } profiles.append(profile) if len(match) > 0: dialog = xbmcgui.Dialog() nr = dialog.select(utility.get_string(30103), [profile['name'] for profile in profiles]) if nr >= 0: selected_profile = profiles[nr] else: selected_profile = profiles[0] connect.load_site(utility.profile_switch_url + selected_profile['token']) utility.set_setting('selected_profile', selected_profile['token']) utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false') utility.set_setting('profile_name', selected_profile['name']) connect.save_session() else: utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
def cd_summary_if_not_there(): if(not os.path.isdir(BASE_DIR+"/Summary")): log("Please run build_file_structure before doing anything else!") if(os.getcwd()==BASE_DIR+"/Summary"): pass else: os.chdir(BASE_DIR+"/Summary")
def get_v3(cls, query, force=False): if not force and cls._exist(query): c = cls._get(query) r = json.loads(c.response) return r else: base = 'https://api.github.com' url = '{}{}'.format(base, query) log('get v3 url', url) headers = {'Authorization': 'bearer {}'.format(secret.token)} r = requests.get(url=url, headers=headers) rate_limit = int(r.headers['X-RateLimit-Limit']) rate_reset = int(r.headers['X-RateLimit-Reset']) rate_remaing = int(r.headers['X-RateLimit-Remaining']) log('rate limit <{}> rate remaing <{}>'.format(rate_limit, rate_remaing)) now = int(time.time()) log('rate will reset in <{}>'.format(now - rate_reset)) if r.status_code == 200: log('get v3 r', r) j = r.json() cls._set(query, r.text) return j elif rate_remaing == 0: log('no rate remaing') # 保险起见多睡 5 s time.sleep(now - rate_limit + 5) else: message = 'url {} get error code {}'.format(url, r.status_code) raise HTTPError(message, response=r)
def vdf_parse(steam_config_file, config): """Parse a Steam config file and return the contents as a dict.""" line = " " while line: try: line = steam_config_file.readline() except UnicodeDecodeError: log( "Error while reading Steam VDF file {}. Returning {}".format( steam_config_file, config), xbmc.LOGERROR) return config if not line or line.strip() == "}": return config while not line.strip().endswith("\""): nextline = steam_config_file.readline() if not nextline: break line = line[:-1] + nextline line_elements = line.strip().split("\"") if len(line_elements) == 3: key = line_elements[1] steam_config_file.readline() # skip '{' config[key] = vdf_parse(steam_config_file, {}) else: try: config[line_elements[1]] = line_elements[3] except IndexError: log('Malformed config file: {}'.format(line), xbmc.LOGERROR) return config
def get_text_area(tree, name): """ Returns dictionary with id, value, description """ log('get_text_area', str(name)) try: label = tree.xpath("//label[@for='%s']" % name)[0].text # label inside formatting element, e.g. <span> if label is None: label = tree.xpath("//label[@for='%s']" % name)[0][0].text # log('label', label) # log('textarea', str(tree.xpath("//textarea[@id='%s']" % name)[0].value)) element = tree.xpath("//textarea[@id='%s']" % name)[0] # log('element.name', element.name) # log('element.value', element.value) ret = dict( id=element.name, value=element.value, description=label, ) # log("get_simple_input ret=", ret) return ret except IndexError: exit_on_rc_error("Element not found", name)
def master(): global master_pid, pids, my_id, socket log("I am the new master with id = " + str(my_id)) while (1): if (master_pid == pids[my_id]): socket.send_string("alive " + str(my_id) + " " + str(pids[my_id])) time.sleep(1)
def make_out_of_package(positive_count, source_dict, source_dict_keys_set, sink_dict, sink_dict_keys_set): ut.log("generate out of package pair features...") # positive_count = len(sample_source_pair_list) out_of_package_count = 0 out_of_package_count_target = positive_count original_train_pair = ut.read_as_list(ut.ORIGINAL_TRAIN_FILE, "\t") source_count = len(original_train_pair) calc = pre_calculate.calculator(source_dict, source_dict_keys_set, sink_dict, sink_dict_keys_set) out_of_package_pairs = list() while out_of_package_count < out_of_package_count_target: row_idx = random.randint(0, source_count - 1) row = original_train_pair[row_idx] if len(row) < 3: continue sink_idx = random.randint(1, len(row) - 1) source = row[0] sink = row[sink_idx] this_pair = calc._calculate_pair_features(source, sink, True) this_pair.extend([99999, 0, 0, 0]) out_of_package_pairs.append(this_pair) out_of_package_count += 1 if out_of_package_count % 1000 == 0: ut.log("{}/{}".format(out_of_package_count, out_of_package_count_target)) return out_of_package_pairs
def make_sink_dict(source_file, to_file, sep=','): """ generate, sorted and save test features into a binary data file :param source_ids: :param source_file: :param to_file: :return: """ ut.log("begin to make sink dict from file {} and save to file {}".format(source_file, to_file)) source_dict = ut.read_as_dict(source_file,sep) follow_id_dict = dict() for start, sink_list in source_dict.items(): for sink in sink_list: if sink in follow_id_dict: follow_id_dict[sink].append(start) else: follow_id_dict[sink] = [start] with open(to_file, 'w') as f: for key, value in follow_id_dict.items(): f.write(key) f.write(",") f.write(",".join(value)) f.write("\n") print("Totally {} different features.".format(follow_id_dict.__len__()))
def load_workout_data(workload_id): """ Requests the workload for the given ID. Precondition: SSO established Returns HTML tree """ log("load_workload_data", "start") # just for for testing # return html.parse(open('workout.html', 'rt')).getroot() url = "https://app.velohero.com/workouts/edit/{}".format(workload_id) log("url", str(url)) r = requests.post(url, headers={ 'user-agent': my_user_agent, }, data={ 'sso': sso_id, }) if r.status_code != 200: exit_on_rc_error("HTTP error {}. Status code".format(url), r.status_code) return html.fromstring(r.text)
def dfs(u_name, config, tables, graph): u = tables[u_name] log(f"enter {u_name}") for edge in graph[u_name]: v_name = edge['to'] if config['tables'][v_name]['depth'] <= config['tables'][u_name][ 'depth']: continue v = dfs(v_name, config, tables, graph) key = edge['key'] type_ = edge['type'] if config['time_col'] not in u and config['time_col'] in v: log(f"join {u_name} <--{type_}--nt {v_name}") u = join(u, v, v_name, key, type_) elif config['time_col'] in u and config['time_col'] in v: log(f"join {u_name} <--{type_}--t {v_name}") u = temporal_join(u, v, v_name, key, config['time_col'], config, type_) else: log(f"join {u_name} <--{type_}--nt {v_name}") u = join(u, v, v_name, key, type_) del v log(f"leave {u_name}") return u
def train_model(model, train_file, cross_valid_n = 10): ut.log("begin to train model...") sample_with_feature = ut.read_as_list(train_file) kf = KFold(cross_valid_n, True) X_list = list() y_list = list() for line in sample_with_feature[1:]: features = list(map(converToFloatIfPossible, line[2:-1])) X_list.append(features) y_list.append(line[-1]) X = np.array(X_list) y = np.array(y_list) test_result = list() for train_index, test_index in kf.split(X): X_train, X_test = X[train_index], X[test_index] y_train, y_test = y[train_index], y[test_index] model.fit(X_train, y_train) score = model.score(X_test, y_test) test_result.append(score) ut.log("Test #{} => Score: {}".format(len(test_result) , score)) return model
def registerExtenderCallbacks(self, callbacks): """ Burp initialisation function. Gets called when the extension is loaded and is in charge of building the UI. Args: callbacks: contains a burp callbacks object, as documented here https://portswigger.net/burp/extender/api/burp/IBurpCallbacks.html """ utility.setupLogging() utility.log("Loaded Benteveo Toolbox v0.2.2") state = State() # Endpoint table models are in charge of storing and disiplaying information in tables. state.endpointTableModel = EndpointTableModel(state, callbacks) state.requestTableModel = RequestTableModel(state, callbacks) state.replacementRuleTableModel = ReplacementRuleTableModel() # ToolboxUI handles building the Swing UI. ui = ToolboxUI() splitpane = ui.buildUi(state, callbacks) # Burp callbacks, to handle interactions with Burp. callbacks.addSuiteTab(Tab(splitpane)) callbacks.registerHttpListener(HttpListener(state, callbacks)) callbacks.setExtensionName("Benteveo Toolbox") callbacks.registerExtensionStateListener(ExtensionStateListener(state)) # Periodically check for new issues and report to slack. issueChecker = IssueChecker(state, callbacks) state.timer = Timer() state.timer.scheduleAtFixedRate(issueChecker, 1000, 1000)
def load_equipments(): """ Requests the settings for the given user. Precondition: SSO established Returns HTML tree """ log("load_equipments", "start") # just for for testing # return html.parse(open('velo_hero_equipments.html', 'rt')).getroot() url = "https://app.velohero.com/equipment/list" log("url", str(url)) r = requests.post(url, headers={ 'user-agent': my_user_agent, }, data={ 'sso': sso_id, }) if r.status_code != 200: exit_on_rc_error("HTTP error {}. Status code".format(url), r.status_code) return html.fromstring(r.text)
def delete_load(): storage = Storage() file = storage.get_stage_path() log("file_name", file) remove(file)
def save_load(load): storage = Storage() file = storage.get_stage_path() log("file_name", file) filehandler = file.open('wb') pickle.dump(load, filehandler)
def show_map(): p = path.join(tempfile.gettempdir(), "heroscript_map.html") utility.log("Temp html", p) with open(p, "w") as file: file.write(Map().get()) # print("See your default browser.".format(p)) webbrowser.open(file.name)
def choose(): profiles = [] content = utility.decode(connect.load_site(utility.profile_url)) match = re.compile( '"experience":"(.+?)".+?guid":"(.+?)".+?profileName":"(.+?)"', re.DOTALL).findall(content) for is_kid, token, name in match: profile = { 'name': utility.unescape(name), 'token': token, 'is_kid': is_kid == 'jfk' } profiles.append(profile) if len(match) > 0: dialog = xbmcgui.Dialog() nr = dialog.select(utility.get_string(30103), [profile['name'] for profile in profiles]) if nr >= 0: selected_profile = profiles[nr] else: selected_profile = profiles[0] connect.load_site(utility.profile_switch_url + selected_profile['token']) utility.set_setting('selected_profile', selected_profile['token']) utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false') utility.set_setting('profile_name', selected_profile['name']) connect.save_session() get_my_list_change_authorisation() else: utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
def get_selected_id(select_dict, value): """ Exits script, if value is invalid. Exits in error case :param select_dict: Dictionary which describes the data.py :param value: id or description :return: id or, in initial case, empty string """ if value.isdigit(): key = 'id' log('res is digit', value) else: key = 'description' try: res_list = [ v for v in select_dict['values'] if value.lower() in v[key].lower() ] if len(res_list) > 1: print("ERROR") print("%s '%s' is non-unique, found %s canidates:" % (select_dict['description'], value, len(res_list))) for res in res_list: print(" * %s (%s)" % (res['description'], res['id'])) exit_on_rc_error("Please set a unique value for ", select_dict['description']) res = res_list[0]['id'] log("Found for %s" % (select_dict['description']), res_list[0]) return res except IndexError: exit_on_rc_error("Unknown value", value)
def plot_pseudo_value(z1, z2, header): plt.scatter(z1, z2) ofile = header + "_pseudo.png" plt.savefig(ofile) plt.clf() utility.log("# " + ofile + " min=" + str(min(min(z1), min(z2))) + " max=" + str(max(max(z1), max(z2))))
def _execute_archive(preparation, load): dest = path.join(preparation['dest_dir'], Path(load.file_name).name) if preparation['ftp']: try: with FTP(host=preparation['host'], user=preparation['username'], passwd=preparation['password']) as connection: with open(load.file_name, 'rb') as f: connection.storlines(f"STOR {dest}", f) human_dest = f"{preparation['host']}/{dest}" except all_errors as e: utility.exit_on_error(f"Archiving failed: {e}") os.remove(load.file_name) else: utility.log("os.replace from {} to".format(load.file_name), preparation['dest_dir']) dest = path.join(preparation['dest_dir'], Path(load.file_name).name) shutil.move(load.file_name, dest) human_dest = dest load.set_archived_to(dest) delete_load() print("Archived to: '{}'".format(human_dest))
def addon(): dialog = xbmcgui.Dialog() if dialog.yesno(utility.addon_name + ':', utility.get_string(30307)): try: xbmcvfs.rmdir(utility.data_dir(), force=True) utility.log('Addon userdata folder deleted.') utility.notification(utility.get_string(30308)) except Exception: pass
def cookies(): if xbmcvfs.exists(utility.cookie_file()): xbmcvfs.delete(utility.cookie_file()) utility.log('Cookie file deleted.') utility.notification(30301) if xbmcvfs.exists(utility.session_file()): xbmcvfs.delete(utility.session_file()) utility.log('Session file deleted.') utility.notification(30302)
def get_package_repository_url(self,origin): try: r = requests.post(self.server_adress,origin,timeout=REQUEST_TIMEOUT) if r.status_code == 200: return r.text elif r.status_code == 404: log("file not found in the repository") except requests.exceptions.RequestException as e: log("Connection error to repository server, "+self.server_adress+": "+str(e)) return None
def remove_dependency(self, dependencyName): installRelPath = self.installedDependencies.get_installation_path(dependencyName) installLocation = utility.joinPaths(self.dependencies_directory, installRelPath) if os.path.exists(installLocation): try: shutil.rmtree(installLocation) except Exception: raise Exception("Error, can't remove {s}, ensure that you have prermissions and the program is not already running".format(s=installLocation)) else: utility.log("directory {s} does not exist, this should happen only if you have deleted the directory manually, please report the problem otherwise".format(s=installLocation)) self.installedDependencies.remove_dependency(dependencyName)
def login(): login_progress = xbmcgui.DialogProgress() login_progress.create('Netflix', utility.get_string(30200) + '...') utility.progress_window(login_progress, 25, utility.get_string(30201)) connect.session.cookies.clear() content = utility.decode(connect.load_site(utility.main_url + 'Login')) if not 'Sorry, Netflix ' in content: match = re.compile('name="authURL" value="(.+?)"', re.DOTALL).findall(content) utility.log('Setting authorization url: ' + match[0]) utility.set_setting('authorization_url', match[0]) match = re.compile('locale: "(.+?)"', re.DOTALL).findall(content) utility.set_setting('language', match[0]) post_data = {'authURL': utility.get_setting('authorization_url'), 'email': utility.get_setting('username'), 'password': utility.get_setting('password'), 'RememberMe': 'on'} utility.progress_window(login_progress, 50, utility.get_string(30202)) content = utility.decode(connect.load_site(utility.main_url + 'Login?locale=' + utility.get_setting('language'), post=post_data)) if 'id="page-LOGIN"' in content: utility.notification(utility.get_string(30303)) return False match = re.compile('"apiUrl":"(.+?)",').findall(content) utility.set_setting('api_url', match[0]) post_data = utility.my_list % utility.get_setting('authorization_url') content = utility.decode(connect.load_site(utility.evaluator(), post=post_data)) matches = json.loads(content)['value'] match = matches['lolomos'].keys() utility.set_setting('root_list', match[0]) match = matches['lists'].keys() utility.set_setting('my_list', match[1]) match = matches['lists'][utility.get_setting('my_list')]['trackIds']['trackId'] utility.set_setting('track_id', unicode(match)) connect.save_session() utility.progress_window(login_progress, 75, utility.get_string(30203)) if not (utility.get_setting('selected_profile') or (utility.get_setting('single_profile') == 'true')): profiles.choose() elif not (utility.get_setting('single_profile') == 'true') and (utility.get_setting('show_profiles') == 'true'): profiles.choose() elif not ((utility.get_setting('single_profile') and utility.get_setting('show_profiles')) == 'true'): profiles.load() #if not utility.get_setting('is_kid') == 'true': #match = re.compile('"version":{"app":"(.+?)"').findall(content) #utility.set_setting('lolomos', match[0]) #3a5922fa-a4a9-41d8-a08c-9e84c2d32be4_ROOT if login_progress: if not utility.progress_window(login_progress, 100, utility.get_string(30204)): return False xbmc.sleep(500) login_progress.close() return True else: utility.notification(utility.get_string(30300)) if login_progress: login_progress.close() return False
def getDOM(self): '''Get a DOM for this page ''' if self.dom is None: parser = SimpleDOMParser() try: parser.parseString(self.body) except Exception: log('HTTPResponse.getDOM'+`(self.url, self.code, self.message, self.headers)`, self.body) raise self.dom = parser.getDOM() return self.dom
def is_topic_content_match(topic_url): log(unicode('Fetching %s' % topic_url)) topic_content = get_topic_content(topic_url) if topic_content is not None: for filter in settings.CONFIG['filters']: topic_content_regex = re.compile(filter) if topic_content_regex.match(topic_content) is not None: return True else: continue return False else: return False
def __init__(self, master, app, frame): """Create the window.""" self.master = master self.app = app self.frame = frame self.world = self.app.simulation.world self.add_buttons() self.add_other_widgets() self.add_map() log(">> Creating tiles") self.create_tiles() log(">> Painting tiles") self.paint_tiles()
def load_site(url, post=None): utility.log('Loading url: ' + url) try: if post: response = session.post(url, data=post) else: response = session.get(url) except AttributeError: utility.log('Session is missing', loglevel=xbmc.LOGERROR) utility.notification(utility.get_string(30301)) new_session() save_session() if post: response = session.post(url, data=post) else: response = session.get(url) return response.content
def login(self, username, password, board_url): try: curl = pycurl.Curl() curl.setopt(pycurl.URL, str(settings.LOGIN_POINT)) # Ignore SSL. curl.setopt(pycurl.SSL_VERIFYPEER, False) # Follow redirection. curl.setopt(pycurl.FOLLOWLOCATION, True) # Set user agent curl.setopt(pycurl.USERAGENT, settings.USER_AGENT) # POST curl.setopt(pycurl.POST, 1) post_params = [ ('username', username.encode('gbk')), ('password', password.encode('gbk')), ('tpl', 'tb'), ] curl.setopt(pycurl.POSTFIELDS, urllib.urlencode(post_params)) # Set cookie jar curl.setopt(pycurl.COOKIEJAR, Admin.COOKIE_PATH) # Set content buffer content = StringIO.StringIO() curl.setopt(pycurl.WRITEFUNCTION, content.write) # Set header buffer header = StringIO.StringIO() curl.setopt(pycurl.HEADERFUNCTION, header.write) curl.perform() # Visit board page to get related cookies curl.setopt(pycurl.URL, str(board_url)) curl.perform() return Admin() except Exception, e: log(unicode(traceback.format_exc())) return None
def choose(): profiles = [] content = utility.decode(connect.load_site(utility.profile_url)) match = json.loads(content)['profiles'] for item in match: profile = {'name': item['firstName'], 'token': item['guid'], 'is_kid': item['experience'] == 'jfk'} profiles.append(profile) if len(match) > 0: dialog = xbmcgui.Dialog() nr = dialog.select(utility.get_string(30103), [profile['name'] for profile in profiles]) if nr >= 0: selected_profile = profiles[nr] else: selected_profile = profiles[0] connect.load_site(utility.profile_switch_url + selected_profile['token']) utility.set_setting('selected_profile', selected_profile['token']) utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false') utility.set_setting('profile_name', selected_profile['name']) connect.save_session() else: utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
def install_dependency(name, version, dependencyManager, registryClient, repositoryClient): try: packageHandler = registryClient.get_package_details(name) except Exception as e: utility.log(str(e)) return False if not packageHandler.check_version_existence(version): utility.log("package {p} version {v} is not in the ppm registry".format(p=name, v=version)) return False url = packageHandler.get_package_url(version) # check for repository url if repositoryClient: repository_url = repositoryClient.get_package_repository_url(url) if repository_url: url = repository_url parentDirectoryPath = packageHandler.get_package_parentdir(version) directoryName = packageHandler.get_package_dirname(version) installDirectoryRelPath = utility.joinPaths(parentDirectoryPath, directoryName) try: dependencyManager.install_dependency(name, version, url, installDirectoryRelPath) return True except Exception as e: utility.log(str(e)) return False
def choose(): profiles = [] content = utility.decode(connect.load_site(utility.profile_url)) match = re.compile('"experience":"(.+?)".+?guid":"(.+?)".+?firstName":"(.+?)"', re.DOTALL).findall(content) for is_kid, token, name in match: profile = {'name': utility.unescape(name), 'token': token, 'is_kid': is_kid == 'jfk'} profiles.append(profile) if len(match) > 0: dialog = xbmcgui.Dialog() nr = dialog.select(utility.get_string(30103), [profile['name'] for profile in profiles]) if nr >= 0: selected_profile = profiles[nr] else: selected_profile = profiles[0] connect.load_site(utility.profile_switch_url + selected_profile['token']) utility.set_setting('selected_profile', selected_profile['token']) utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false') utility.set_setting('profile_name', selected_profile['name']) connect.save_session() get_my_list_change_authorisation() else: utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
def choose(): profiles = [] content = utility.decode(connect.load_site(utility.profile_url)) match = re.compile('"experience":"(.+?)".+?guid":"(.+?)".+?profileName":"(.+?)"', re.DOTALL).findall(content) for is_kid, token, name in match: profile = {"name": utility.unescape(name), "token": token, "is_kid": is_kid == "jfk"} profiles.append(profile) if len(match) > 0: dialog = xbmcgui.Dialog() nr = dialog.select(utility.get_string(30103), [profile["name"] for profile in profiles]) if nr >= 0: selected_profile = profiles[nr] else: selected_profile = profiles[0] connect.load_site(utility.profile_switch_url + selected_profile["token"]) utility.set_setting("selected_profile", selected_profile["token"]) utility.set_setting("is_kid", "true" if selected_profile["is_kid"] else "false") utility.set_setting("profile_name", selected_profile["name"]) connect.save_session() get_my_list_change_authorisation() else: utility.log("Choose profile: no profiles were found!", loglevel=xbmc.LOGERROR)
def __init__(self, master): """Create the app.""" self.master = master # create the simulation object utility.log_welcome() log("> Creating simulation") self.simulation = Simulation() # create the app log("> Creating UI") master.wm_title("Eden") self.frame = Frame(master) self.frame.grid() # create the ui self.ui = UI(self.master, self, self.frame) self.create_key_bindings() self.running = False self.time = 0
def create_cells(self): """Create the cells. Cells are the spatial units of the world and are stored in a list. """ self.cells = [] degrees_per_cell = 360.0/float(settings.world_cell_circumference) for y in range(settings.world_cell_circumference/2 + 1): latitude = degrees_per_cell*y if latitude in [0, 180]: self.cells.append(Cell(longitude=0.0, latitude=latitude)) else: rad = math.sin(math.radians(latitude))*settings.world_radius circ = 2*math.pi*rad cells = int(round(circ/float(settings.cell_width))) for x in range(cells): longitude = (360.0/float(cells))*x self.cells.append(Cell(longitude=longitude, latitude=latitude)) log(">> Assigning cells neighbors") for a in range(len(self.cells)): cell = self.cells[a] for b in range(a+1, len(self.cells)): c = self.cells[b] if math.acos( max( min(math.cos(math.radians(cell.latitude)) * math.cos(math.radians(c.latitude)) + math.sin(math.radians(cell.latitude)) * math.sin(math.radians(c.latitude)) * math.cos(abs(math.radians(cell.longitude) - math.radians(c.longitude))), 1.0), -1.0)) < 1.3*math.radians(degrees_per_cell): cell.neighbors.append(c) c.neighbors.append(cell)
def __init__(self): """Build a world.""" log(">> Creating cells") self.create_cells() log(">> Distorting terrain") self.create_land() self.create_terrain() self.normalize_terrain() log(">> Creating oceans") self.create_oceans()
def cmd_download(args): """ downloading one or more packages without monitoring them""" downloadDirectory = utility.joinPaths(os.getcwd(), args.directory) packages = [('@' in p and p.split('@')) or [p,"latest"] for p in args.packages] utility.ensure_directory(downloadDirectory) registryClient = get_registry_client() if not registryClient: raise Exception("registry server is not set, please set it using set-registry-server command") repositoryClient = get_repository_client() for name, version in packages: try: package_handler = registryClient.get_package_details(name) except Exception as e: utility.log(str(e)) continue if version == 'latest': version = get_latest_version(package_handler.get_package_versions()) if version == '0.0': utility.log("Package {p} is not in the ppm registry".format(p=name)) continue else: version = str(StrictVersion(version)) if not package_handler.check_version_existence(version): utility.log("Package {p} is not in the ppm registry".format(p=name)) continue url = package_handler.get_package_url(version) # check for repository url if repositoryClient: repository_url = repositoryClient.get_package_repository_url(url) if repository_url: url = repository_url utility.download_file(url, downloadDirectory)
def login(): login_progress = xbmcgui.DialogProgress() login_progress.create('Netflix', utility.get_string(30200) + '...') utility.progress_window(login_progress, 25, utility.get_string(30201)) connect.session.cookies.clear() content = utility.decode(connect.load_site(utility.main_url + '/Login')) match = re.compile('"locale":"(.+?)"', re.DOTALL | re.IGNORECASE).findall(content) if match and not utility.get_setting('language'): utility.log('Setting language: ' + match[0]) utility.set_setting('language', match[0]) if not 'Sorry, Netflix ' in content: match = re.compile('id="signout".+?authURL=(.+?)"', re.DOTALL).findall(content) if match: utility.log('Setting authorization url: ' + match[0]) utility.set_setting('authorization_url', match[0]) if 'id="page-LOGIN"' in content: match = re.compile('name="authURL" value="(.+?)"', re.DOTALL).findall(content) utility.log('Setting authorization url: ' + match[0]) utility.set_setting('authorization_url', match[0]) post_data = {'authURL': match[0], 'email': utility.get_setting('username'), 'password': utility.get_setting('password'), 'RememberMe': 'on'} utility.progress_window(login_progress, 50, utility.get_string(30202)) content = utility.decode(connect.load_site(utility.main_url + '/Login?locale=' + utility.get_setting('language'), post=post_data)) if 'id="page-LOGIN"' in content: utility.notification(utility.get_string(30303)) return False match = re.compile('"locale":"(.+?)"', re.DOTALL | re.IGNORECASE).findall(content) if match and not utility.get_setting('language'): utility.log('Setting language: ' + match[0]) utility.set_setting('language', match[0]) match = re.compile('"country":"(.+?)"', re.DOTALL | re.IGNORECASE).findall(content) if match: utility.log('Setting country code: ' + match[0]) utility.set_setting('country_code', match[0]) connect.save_session() utility.progress_window(login_progress, 75, utility.get_string(30203)) if not (utility.get_setting('selected_profile') or (utility.get_setting('single_profile') == 'true')): profiles.choose() elif not (utility.get_setting('single_profile') == 'true') and (utility.get_setting('show_profiles') == 'true'): profiles.choose() elif not ( (utility.get_setting('single_profile') == 'true') and ( utility.get_setting('show_profiles') == 'true')): profiles.load() else: profiles.get_my_list_change_authorisation() if not utility.get_setting('is_kid') == 'true': content = utility.decode(connect.load_site(utility.main_url + '/browse')) match = re.compile('"version":{"app":"(.+?)"').findall(content) netflix_application, netflix_id = match[0].split('-') utility.set_setting('netflix_application', netflix_application) utility.set_setting('netflix_id', netflix_id) if login_progress: if not utility.progress_window(login_progress, 100, utility.get_string(30204)): return False xbmc.sleep(500) login_progress.close() return True else: utility.notification(utility.get_string(30300)) if login_progress: login_progress.close() return False
def video(video_id, title, thumb_url, is_episode, hide_movies, video_type, url): added = False director = '' genre = '' playcount = 0 video_details = get.video_info(video_id) match = json.loads(video_details)['value']['videos'][video_id] if not title: title = match['title'] year = match['releaseYear'] if not thumb_url: try: thumb_url = match['boxarts']['_665x375']['jpg']['url'] except Exception: try: thumb_url = match['boxarts']['_342x192']['jpg']['url'] except Exception: thumb_url = utility.addon_fanart() mpaa = match['maturity']['rating']['value'] duration = match['runtime'] offset = match['bookmarkPosition'] try: if (duration > 0 and float(offset) / float(duration)) >= 0.9: playcount = 1 except Exception: pass type = match['summary']['type'] if type == 'movie': video_type_temp = type else: video_type_temp = 'tv' if is_episode: type = 'episode' else: type = 'tvshow' duration = '' if utility.get_setting('use_tmdb') == 'true': year_temp = year title_temp = title if ' - ' in title_temp: title_temp = title_temp[title_temp.index(' - '):] filename = video_id + '.jpg' filename_none = video_id + '.none' cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename) cover_file_none = xbmc.translatePath(utility.cover_cache_dir() + filename_none) if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)): utility.log('Downloading cover art. type: %s, video_id: %s, title: %s, year: %s' % (video_type_temp, video_id, title_temp, year_temp)) get.cover(video_type_temp, video_id, title_temp, year_temp) description = match['details']['synopsis'] try: director = match['details']['directors'][0]['name'] except Exception: pass try: genre = match['details']['genres'][0]['name'] except Exception: pass rating = match['userRating']['average'] next_mode = 'play_video_main' if utility.get_setting('browse_tv_shows') == 'true' and type == 'tvshow': next_mode = 'list_seasons' if '/my-list' in url and video_type_temp == video_type: add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, playcount, remove=True) added = True elif type == 'movie' and hide_movies: pass elif video_type_temp == video_type or video_type == 'both': add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, playcount) added = True return added
def delete_topic(self, topic_url): try: page_source = get_html(topic_url, Admin.COOKIE_PATH).encode('utf8') tbs = re.search('tbs\:\"(.+)\"', page_source).groups()[0] kw = re.search('forum_name\:\"(.+?)\"', page_source).groups()[0] fid = re.search('fid\:\'(.+?)\'', page_source).groups()[0] tid = re.search('tid\:\'(.+?)\'', page_source).groups()[0] post_params = [ ('ie', 'utf-8'), ('tbs', tbs), ('kw', kw), ('fid', fid), ('tid', tid), ] curl = pycurl.Curl() curl.setopt(pycurl.URL, settings.TOPIC_DELETE_POINT) # Set referer curl.setopt(pycurl.REFERER, str(topic_url)) # Ignore SSL. curl.setopt(pycurl.SSL_VERIFYPEER, False) # Follow redirection. curl.setopt(pycurl.FOLLOWLOCATION, True) # Set user agent curl.setopt(pycurl.USERAGENT, settings.USER_AGENT) # POST curl.setopt(pycurl.POST, 1) curl.setopt(pycurl.POSTFIELDS, urllib.urlencode(post_params)) # Set custom header custom_header = [ 'X-Requested-With: XMLHttpRequest', 'DNT: 1', 'Accept: application/json, text/javascript, */*; q=0.01', 'Accept-Language: en-us,en;q=0.5', 'Accept-Encoding: gzip, deflate', 'Pragma: no-cache', 'Cache-Control: no-cache', 'HeaderEnd: CRLF', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', ] curl.setopt(pycurl.HTTPHEADER, custom_header) # Set cookie file curl.setopt(pycurl.COOKIEFILE , Admin.COOKIE_PATH) # Set content buffer content = StringIO.StringIO() curl.setopt(pycurl.WRITEFUNCTION, content.write) # Set header buffer header = StringIO.StringIO() curl.setopt(pycurl.HEADERFUNCTION, header.write) curl.perform() except Exception, e: log(unicode(traceback.format_exc())) return
utility.Msg("Fingerprinting completed.", LOG.UPDATE) # We've got the host fingerprinted, now kick off the # exploitation engine for the service utility.Msg("Loading auxiliary for '%s'..." % fingerengine.service, LOG.DEBUG) # execute the auxiliary engine auxengine(fingerengine) if __name__ == "__main__": utility.header() options = parse(sys.argv[1:]) utility.Msg("Started at %s" % (utility.timestamp())) # log the CLI args utility.log(' '.join(sys.argv)) try: prerun(options) if options.ip or options.input_list: run(options) postrun(options) except KeyboardInterrupt: pass utility.Msg("Finished at %s" % (utility.timestamp()))
def sync_dependencies(requiredDeps, installedDependencies, registryClient, repositoryClient, dependencyManager, flags): """synchronizing installed dependencies with requiredDeps, include installing,updating,downgrading and removing dependencies, in accordance to flags, Args: requiredDeps: array containing required dependencies for the project, in the format [{depName:version},{depName2,version}] installedDependencies: currently installed dependencies registryClient: client used for requesting a package details from the registry repositoryClient: client used for checking for a package repository url DependencyManager: responsible for dependency installation (or remove) flags: operations to be performed (can be update, install, downgrade, remove or any combintation of them) """ utility.log("synchronizing dependencies") utility.ensure_directory(DEPSINSTALL_DIR_PATH) required_dependencies_names = requiredDeps.get_dependencies_names() for depName in required_dependencies_names: utility.log("Processing {d}".format(d=depName), 1) # get current installed version (or set version to 0.0 for new dependencies) if installedDependencies.is_installed(depName): installedVersion = installedDependencies.get_installed_version(depName) else: installedVersion = str(StrictVersion('0.0')) # get and normalize required version requiredVersion = requiredDeps.get_dependency_version(depName) requiredVersion = str(StrictVersion(requiredVersion)) if StrictVersion(requiredVersion) == StrictVersion(installedVersion): utility.log("version {v} already installed".format(v=installedVersion)) elif StrictVersion(requiredVersion) < StrictVersion(installedVersion): if flags.downgrade: if install_dependency(depName, requiredVersion, dependencyManager, registryClient, repositoryClient): utility.log("{p} version {v} installed successfuly".format(p=depName, v=requiredVersion)) else: utility.log("{p} installation failed".format(p=depName)) else: utility.log("Required version {v1} < Installed version {v2}, No action taken (downgrade flag is not set)".format(v1=requiredVersion, v2=installedVersion)) else: if (flags.update and StrictVersion(installedVersion) > StrictVersion('0.0')) or (flags.install and StrictVersion(installedVersion) == StrictVersion('0.0')): if install_dependency(depName, requiredVersion, dependencyManager, registryClient, repositoryClient): utility.log("{p} version {v} installed successfuly".format(p=depName, v=requiredVersion)) else: utility.log("{p} installation failed".format(p=depName)) else: utility.log("Required version {v1} > Installed version {v2}, No action taken (update flag is not set)".format(v1=requiredVersion, v2=installedVersion)) # unident log messages utility.log("", -1) dependenciesToRemove = [item for item, version in installedDependencies.get_dependencies_list().items() if item not in required_dependencies_names] if dependenciesToRemove: utility.log("Installed dependencies that are not needed anymore : " + ",".join(dependenciesToRemove)) if not flags.remove: utility.log("ommiting uneeded dependencies (remove flag is not set)") else: for dependencyName in dependenciesToRemove: utility.log("removing {d}".format(d=dependencyName)) dependencyManager.remove_dependency(dependencyName) generate_environment(installedDependencies.get_dependencies_list(), registryClient, os.path.basename(DEPSINSTALL_DIR_PATH), GENERATED_ENVIRONMENT_PATH) utility.log("synchronization operation finished")
def __init__(self): """Create the simulation.""" log("> Creating world") self.create_world() log("> Creating sun") self.create_sun()
def videos(url, video_type, run_as_widget=False): loading_progress = None if not run_as_widget: loading_progress = xbmcgui.DialogProgress() loading_progress.create('Netflix', utility.get_string(30205) + '...') utility.progress_window(loading_progress, 0, '...') xbmcplugin.setContent(plugin_handle, 'movies') if not xbmcvfs.exists(utility.session_file()): login.login() ''' the next part is necessary during the changing phase. Otherwise data are not available. ''' if 'recently-added' in url: postdata = utility.recently_added % utility.get_setting('authorization_url') content = utility.decode(connect.load_site(utility.evaluator(), post=postdata)) else: content = utility.decode(connect.load_site(url)) if not 'id="page-LOGIN"' in content or url == 'recently-added': if utility.get_setting('single_profile') == 'true' and 'id="page-ProfilesGate"' in content: profiles.force_choose() else: if '<div id="queue"' in content: content = content[content.find('<div id="queue"'):] if not 'recently-added' in url: content = utility.clean_content(content) match = None if not match: match = re.compile('"\$type":"leaf",.*?"id":([0-9]+)', re.DOTALL).findall(content) print '1: ' + str(match) if not match: match = re.compile('<a href="\/watch\/([0-9]+)', re.DOTALL).findall(content) print '2: ' + str(match) if not match: match = re.compile('<span id="dbs(.+?)_.+?alt=".+?"', re.DOTALL).findall(content) print '3: ' + str(match) if not match: match = re.compile('<span class="title.*?"><a id="b(.+?)_', re.DOTALL).findall(content) print '4: ' + str(match) if not match: match = re.compile('"boxart":".+?","titleId":(.+?),', re.DOTALL).findall(content) print '5: ' + str(match) if not match: match = re.compile('WiPlayer\?movieid=([0-9]+?)&', re.DOTALL).findall(content) print '6: ' + str(match) if 'recently-added' in url: matches = json.loads(content)['value']['videos'] for video_id in matches: match.append(unicode(video_id)) print '7: ' + str(match) print len(match) i = 1 for video_id in match: if int(video_id) > 10000000 or 'recently-added' in url: if not run_as_widget: utility.progress_window(loading_progress, i * 100 / len(match), '...') video(video_id, '', '', False, False, video_type, url) i += 1 match1 = re.compile('&pn=(.+?)&', re.DOTALL).findall(url) match2 = re.compile('&from=(.+?)&', re.DOTALL).findall(url) match_api_root = re.compile('"API_ROOT":"(.+?)"', re.DOTALL).findall(content) match_api_base = re.compile('"API_BASE_URL":"(.+?)"', re.DOTALL).findall(content) match_identifier = re.compile('"BUILD_IDENTIFIER":"(.+?)"', re.DOTALL).findall(content) if 'agid=' in url and match_api_root and match_api_base and match_identifier: genre_id = url[url.find('agid=') + 5:] add.directory(utility.get_string(30110), match_api_root[0] + match_api_base[0] + '/' + match_identifier[ 0] + '/wigenre?genreId=' + genre_id + '&full=false&from=51&to=100&_retry=0', 'list_videos', '', video_type) elif match1: current_page = match1[0] next_page = str(int(current_page) + 1) add.directory(utility.get_string(30110), url.replace('&pn=' + current_page + '&', '&pn=' + next_page + '&'), 'list_videos', '', video_type) elif match2: current_from = match2[0] next_from = str(int(current_from) + 50) current_to = str(int(current_from) + 49) next_to = str(int(current_from) + 99) add.directory(utility.get_string(30110), url.replace('&from=' + current_from + '&', '&from=' + next_from + '&').replace( '&to=' + current_to + '&', '&to=' + next_to + '&'), 'list_videos', '', video_type) if utility.get_setting('force_view') == 'true' and not run_as_widget: xbmc.executebuiltin('Container.SetViewMode(' + utility.get_setting('view_id_videos') + ')') xbmcplugin.endOfDirectory(plugin_handle) else: delete.cookies() utility.log('User is not logged in.', loglevel=xbmc.LOGERROR) utility.notification(utility.get_string(30303))
def log(self, message, content): '''Log a message to the logfile ''' log(message, content, 'logfile.'+self.server)