def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if 'fileInfo filename' in line: name = line.split('<strong>')[1].split('</strong>')[0] elif 'fileInfo filesize' in line: it.next() tmp = it.next().split('class="size">')[1].split("<")[0] if "KB" in tmp: size = int(round(float(tmp.split("KB")[0]))) unit = "KB" elif "MB" in tmp: size = float(tmp.split("MB")[0]) if int(round(size)) > 0: size = int(round(size)) unit = "MB" else: size = int(round(1024 * size)) unit = "KB" elif "GB" in tmp: size = int(round(float(tmp.split("GB")[0]))) unit = "GB" except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: url = url.split("&")[0] it = URLOpen().open(url) for line in it: if '<div class="fileInfo">' in line: name = it.next().split("</strong>")[0].split(">")[-1].strip() it.next() tmp = it.next().split("</strong>")[0].split(">")[-1].strip() if cons.UNIT_KB in tmp: unit = cons.UNIT_KB size = int(float(tmp.split(cons.UNIT_KB)[0])) elif cons.UNIT_MB in tmp: unit = cons.UNIT_MB size = int(float(tmp.split(cons.UNIT_MB)[0])) elif cons.UNIT_GB in tmp: unit = cons.UNIT_GB size = int(float(tmp.split(cons.UNIT_GB)[0])) except Exception, e: name = None size = -1 logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None size_found = 0 try: it = URLOpen().open(url) for line in it: if 'File Name:' in line: name = it.next().split('>')[1].split('<')[0] if 'File Size:' in line: tmp = line.split('>')[3].split('<')[0] if "KB" in tmp: size = int(round(float(tmp.split("KB")[0]))) unit = "KB" elif "MB" in tmp: size = float(tmp.split("MB")[0]) if int(round(size)) > 0: size = int(round(size)) unit = "MB" else: size = int(round(1024 * size)) unit = "KB" elif "GB" in tmp: size = int(round(float(tmp.split("GB")[0]))) unit = "GB" except Exception, e: name = None size = -1 logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if 'Filename:' in line: name = line.split(">")[1].split("<")[0] line = it.next() size_and_units = [] size_and_units = line.split(":")[1].split("<")[0].lstrip().rstrip().split(" ") size = float(size_and_units[0]) unit = size_and_units[1].upper() if 'B' == unit: size = size / 1024 unit = "KB" break # Oron responds to unknown files as HTTP 404s followed by a redirect except urllib2.HTTPError as http_error: if http_error.code != 404: logger.warning("Oron::check_links: Received unexpected HTTP error code: %s" % http_error.code) return None, -1, None except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if 'Filename:' in line: name = line.split(">")[1].split("<")[0] line = it.next() size_and_units = [] size_and_units = line.split(":")[1].split( "<")[0].lstrip().rstrip().split(" ") size = float(size_and_units[0]) unit = size_and_units[1].upper() if 'B' == unit: size = size / 1024 unit = "KB" break # Oron responds to unknown files as HTTP 404s followed by a redirect except urllib2.HTTPError as http_error: if http_error.code != 404: logger.warning( "Oron::check_links: Received unexpected HTTP error code: %s" % http_error.code) return None, -1, None except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if '/img/manager/mime/' in line: if ("generic" in line) or ("audio" in line) or ("archive" in line): tmp = line.split('/>')[1].split("</h1>")[0] if "video" in line: tmp = line.split('</a>')[1].split("<")[0] tmp = tmp.replace(" ", "") tmp = tmp.replace("​", "") name = tmp.replace("​", "") elif '<div id="info" class="metadata">' in line: tmp = it.next() tmp = tmp.split("<span>")[1].split("file")[0].strip() size = int(round(float(tmp.split(" ")[0]))) unit = tmp.split(" ")[1].upper() elif 'Retry Download' in line: name = line.split('href="')[1].split('"')[0].split( "/").pop() except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if '/img/manager/mime/' in line: if ("generic" in line) or ("audio" in line) or ("archive" in line): tmp = line.split('/>')[1].split("</h1>")[0] if "video" in line: tmp = line.split('</a>')[1].split("<")[0] tmp = tmp.replace(" ","") tmp = tmp.replace("​","") name = tmp.replace("​","") elif '<div id="info" class="metadata">' in line: tmp = it.next() tmp = tmp.split("<span>")[1].split("file")[0].strip() size = int(round(float(tmp.split(" ")[0]))) unit = tmp.split(" ")[1].upper() elif 'Retry Download' in line: name = line.split('href="')[1].split('"')[0].split("/").pop() except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if '<span class="txtorange">' in line: tmp = it.next() name = tmp.split("<")[0].strip() tmp = tmp.split(">(")[1].split(")")[0] if "KB" in tmp: size = int(round(float(tmp.split("KB")[0]))) unit = "KB" elif "MB" in tmp: size = float(tmp.split("MB")[0]) if int(round(size)) > 0: size = int(round(size)) unit = "MB" else: size = int(round(1024 * size)) unit = "KB" elif "GB" in tmp: size = int(round(float(tmp.split("GB")[0]))) unit = "GB" except urllib2.HTTPError: pass except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if '"panel file_download"' in line: it.next() name = it.next().split(">")[1].split("<")[0] it.next() tmp = it.next().split("<strong>")[1].split("<")[0] unit = tmp[-2:] #Fix me : GB bug if unit == "GB": size = int(1024 * float(tmp[:-2])) unit = "MB" else: size = int(round(float(tmp[:-2]))) if size > 1024: if unit == "KB": size = size / 1024 unit = "MB" break except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None try: it = URLOpen().open(url) for line in it: if '"panel file_download"' in line: it.next() name = it.next().split(">")[1].split("<")[0] it.next() tmp = it.next().split("<strong>")[1].split("<")[0] unit = tmp[-2:] #Fix me : GB bug if unit == "GB": size = int(1024*float(tmp[:-2])) unit = "MB" else: size = int(round(float(tmp[:-2]))) if size > 1024: if unit == "KB": size = size / 1024 unit = "MB" break except Exception, e: logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None size_found = 0 try: it = URLOpen().open(url) for line in it: if '#383737' in line: name = it.next().split('>')[1].split('<')[0].strip() tmp = it.next().split('>')[1].split('<')[0].strip() unit = tmp[-2:] size = int(round(float(tmp[:-2]))) if size > 1024: if unit == "KB": size = size / 1024 unit = "MB" break except Exception, e: name = None size = -1 logger.exception("%s :%s" % (url, e))
def check_links(self, url): """""" name = None size = -1 unit = None size_found = 0 try: it = URLOpen().open(url) for line in it: if '<div class="info">' in line: name = it.next().split('="')[1].split('">')[0].strip() tmp = it.next().split('>')[2].split('<')[0].strip() unit = tmp[-2:] size = int(round(float(tmp[:-2].replace(" ","")))) if size > 1024: if unit == "KB": size = size / 1024 unit = "MB" break except Exception, e: name = None size = -1 logger.exception("%s :%s" % (url, e))