rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.log.debug('acct_mgr: check_password() -- Can\'t locate "%s"' % str(filename))
self.log.debug('acct_mgr: check_password() -- ' 'Can\'t locate "%s"' % filename)
def check_password(self, user, password): filename = self.filename if not os.path.exists(filename): self.log.debug('acct_mgr: check_password() -- Can\'t locate "%s"' % str(filename)) return False user = user.encode('utf-8') password = password.encode('utf-8') prefix = self.prefix(user) fd = file(filename) try: for line in fd: if line.startswith(prefix): return self._check_userline(user, password, line[len(prefix):].rstrip('\n')) finally: fd.close() return None
fd = file(filename)
def check_password(self, user, password): filename = self.filename if not os.path.exists(filename): self.log.debug('acct_mgr: check_password() -- Can\'t locate "%s"' % str(filename)) return False user = user.encode('utf-8') password = password.encode('utf-8') prefix = self.prefix(user) fd = file(filename) try: for line in fd: if line.startswith(prefix): return self._check_userline(user, password, line[len(prefix):].rstrip('\n')) finally: fd.close() return None
for line in fd:
f = open(filename, 'Ur') for line in f:
def check_password(self, user, password): filename = self.filename if not os.path.exists(filename): self.log.debug('acct_mgr: check_password() -- Can\'t locate "%s"' % str(filename)) return False user = user.encode('utf-8') password = password.encode('utf-8') prefix = self.prefix(user) fd = file(filename) try: for line in fd: if line.startswith(prefix): return self._check_userline(user, password, line[len(prefix):].rstrip('\n')) finally: fd.close() return None
fd.close()
f.close()
def check_password(self, user, password): filename = self.filename if not os.path.exists(filename): self.log.debug('acct_mgr: check_password() -- Can\'t locate "%s"' % str(filename)) return False user = user.encode('utf-8') password = password.encode('utf-8') prefix = self.prefix(user) fd = file(filename) try: for line in fd: if line.startswith(prefix): return self._check_userline(user, password, line[len(prefix):].rstrip('\n')) finally: fd.close() return None
"""If `userline` is empty the line starting with `prefix` is removed from the user file. Otherwise the line starting with `prefix` is updated to `userline`. If no line starts with `prefix` the `userline` is appended to the file.
"""Add or remove user and change password. If `userline` is empty, the line starting with `prefix` is removed from the user file. Otherwise the line starting with `prefix` is updated to `userline`. If no line starts with `prefix`, the `userline` is appended to the file.
def _update_file(self, prefix, userline): """If `userline` is empty the line starting with `prefix` is removed from the user file. Otherwise the line starting with `prefix` is updated to `userline`. If no line starts with `prefix` the `userline` is appended to the file.
filename = self.filename
filename = str(self.filename)
def _update_file(self, prefix, userline): """If `userline` is empty the line starting with `prefix` is removed from the user file. Otherwise the line starting with `prefix` is updated to `userline`. If no line starts with `prefix` the `userline` is appended to the file.
for line in fileinput.input(str(filename), inplace=True): if line.startswith(prefix): if not matched and userline: print userline matched = True elif line.endswith('\n'): print line, else: print line
eol = '\n' f = open(filename, 'Ur') lines = f.readlines() newlines = f.newlines if newlines is not None: if isinstance(newlines, str): newlines = [f.newlines] elif isinstance(newlines, tuple): newlines = list(f.newlines) if '\n' not in newlines: if '\r\n' in newlines: eol = '\r\n' elif '\r' in newlines: eol = '\r' if len(lines) > 0: for line in lines: if line.startswith(prefix): if not matched and userline: new_lines.append(userline + eol) matched = True elif line.endswith('\n'): if eol == '\n': new_lines.append(line) else: new_lines.append(line.rstrip('\n') + eol) else: new_lines.append(line + eol)
def _update_file(self, prefix, userline): """If `userline` is empty the line starting with `prefix` is removed from the user file. Otherwise the line starting with `prefix` is updated to `userline`. If no line starts with `prefix` the `userline` is appended to the file.
if not matched and userline: f = open(filename, 'a') try: print >>f, userline finally:
finally: if isinstance(f, file):
def _update_file(self, prefix, userline): """If `userline` is empty the line starting with `prefix` is removed from the user file. Otherwise the line starting with `prefix` is updated to `userline`. If no line starts with `prefix` the `userline` is appended to the file.
f = open(filename)
f = open(filename, 'Ur')
def _get_users(self, filename): f = open(filename) for line in f: user = line.split(':', 1)[0] if user: yield user.decode('utf-8')
req.args.get('force_passwd_change', false))
req.args.get('force_passwd_change', False))
def _do_config(self, req): stores = StoreOrder(stores=self.account_manager.stores, list=self.account_manager.password_store) if req.method == 'POST': _setorder(req, stores) self.config.set('account-manager', 'password_store', ','.join(stores.get_enabled_store_names())) for store in stores.get_all_stores(): for attr, option in _getoptions(store): newvalue = req.args.get('%s.%s' % (store.__class__.__name__, attr)) self.log.debug("%s.%s: %s" % (store.__class__.__name__, attr, newvalue)) if newvalue is not None: self.config.set(option.section, option.name, newvalue) self.config.save() self.config.set('account-manager', 'force_passwd_change', req.args.get('force_passwd_change', false)) self.config.set('account-manager', 'persistent_sessions', req.args.get('persistent_sessions', false)) self.config.set('account-manager', 'verify_email', req.args.get('verify_email', false)) self.config.save() sections = [] for store in self.account_manager.stores: options = [] for attr, option in _getoptions(store): opt_val = option.__get__(store, store) opt_val = isinstance(opt_val, Component) and \ opt_val.__class__.__name__ or opt_val options.append( {'label': attr, 'name': '%s.%s' % (store.__class__.__name__, attr), 'value': opt_val, }) continue sections.append( {'name': store.__class__.__name__, 'classname': store.__class__.__name__, 'order': stores[store], 'options' : options, }) continue sections = sorted(sections, key=lambda i: i['name']) numstores = range(0, stores.numstores() + 1) data = { 'sections': sections, 'numstores': numstores, 'force_passwd_change': self.account_manager.force_passwd_change, 'persistent_sessions': self.account_manager.persistent_sessions, 'verify_email': self.account_manager.verify_email, } return 'admin_accountsconfig.html', data
req.args.get('persistent_sessions', false))
req.args.get('persistent_sessions', False))
def _do_config(self, req): stores = StoreOrder(stores=self.account_manager.stores, list=self.account_manager.password_store) if req.method == 'POST': _setorder(req, stores) self.config.set('account-manager', 'password_store', ','.join(stores.get_enabled_store_names())) for store in stores.get_all_stores(): for attr, option in _getoptions(store): newvalue = req.args.get('%s.%s' % (store.__class__.__name__, attr)) self.log.debug("%s.%s: %s" % (store.__class__.__name__, attr, newvalue)) if newvalue is not None: self.config.set(option.section, option.name, newvalue) self.config.save() self.config.set('account-manager', 'force_passwd_change', req.args.get('force_passwd_change', false)) self.config.set('account-manager', 'persistent_sessions', req.args.get('persistent_sessions', false)) self.config.set('account-manager', 'verify_email', req.args.get('verify_email', false)) self.config.save() sections = [] for store in self.account_manager.stores: options = [] for attr, option in _getoptions(store): opt_val = option.__get__(store, store) opt_val = isinstance(opt_val, Component) and \ opt_val.__class__.__name__ or opt_val options.append( {'label': attr, 'name': '%s.%s' % (store.__class__.__name__, attr), 'value': opt_val, }) continue sections.append( {'name': store.__class__.__name__, 'classname': store.__class__.__name__, 'order': stores[store], 'options' : options, }) continue sections = sorted(sections, key=lambda i: i['name']) numstores = range(0, stores.numstores() + 1) data = { 'sections': sections, 'numstores': numstores, 'force_passwd_change': self.account_manager.force_passwd_change, 'persistent_sessions': self.account_manager.persistent_sessions, 'verify_email': self.account_manager.verify_email, } return 'admin_accountsconfig.html', data
req.args.get('verify_email', false))
req.args.get('verify_email', False))
def _do_config(self, req): stores = StoreOrder(stores=self.account_manager.stores, list=self.account_manager.password_store) if req.method == 'POST': _setorder(req, stores) self.config.set('account-manager', 'password_store', ','.join(stores.get_enabled_store_names())) for store in stores.get_all_stores(): for attr, option in _getoptions(store): newvalue = req.args.get('%s.%s' % (store.__class__.__name__, attr)) self.log.debug("%s.%s: %s" % (store.__class__.__name__, attr, newvalue)) if newvalue is not None: self.config.set(option.section, option.name, newvalue) self.config.save() self.config.set('account-manager', 'force_passwd_change', req.args.get('force_passwd_change', false)) self.config.set('account-manager', 'persistent_sessions', req.args.get('persistent_sessions', false)) self.config.set('account-manager', 'verify_email', req.args.get('verify_email', false)) self.config.save() sections = [] for store in self.account_manager.stores: options = [] for attr, option in _getoptions(store): opt_val = option.__get__(store, store) opt_val = isinstance(opt_val, Component) and \ opt_val.__class__.__name__ or opt_val options.append( {'label': attr, 'name': '%s.%s' % (store.__class__.__name__, attr), 'value': opt_val, }) continue sections.append( {'name': store.__class__.__name__, 'classname': store.__class__.__name__, 'order': stores[store], 'options' : options, }) continue sections = sorted(sections, key=lambda i: i['name']) numstores = range(0, stores.numstores() + 1) data = { 'sections': sections, 'numstores': numstores, 'force_passwd_change': self.account_manager.force_passwd_change, 'persistent_sessions': self.account_manager.persistent_sessions, 'verify_email': self.account_manager.verify_email, } return 'admin_accountsconfig.html', data
referrer = self._referer(req) or req.abs_href()
referrer = self._referer(req) if referrer is None or \ referrer.startswith(str(req.abs_href()) + '/login'): referrer = req.abs_href()
def process_request(self, req): if req.path_info.startswith('/login') and req.authname == 'anonymous': referrer = self._referer(req) or req.abs_href() data = { 'referer': referrer, 'reset_password_enabled': AccountModule(self.env).reset_password_enabled, 'persistent_sessions': AccountManager(self.env).persistent_sessions } if req.method == 'POST': data['login_error'] = _("Invalid username or password") return 'login.html', data, None return auth.LoginModule.process_request(self, req)
v = long(hexlify(urandom(4)), 16)
v = long(hexlify(urandom(6)), 16)
def salt(): s = '' v = long(hexlify(urandom(4)), 16) itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' for i in range(8): s += itoa64[v & 0x3f]; v >>= 6 return s
req.redirect(self.env.abs_href())
self._redirect_back(req)
def _do_login(self, req): if not req.remote_user: req.redirect(self.env.abs_href()) res = auth.LoginModule._do_login(self, req) if req.args.get('rememberme', '0') == '1': # Set the session to expire in 30 days (and not when to browser is # closed - what is the default). req.outcookie['trac_auth']['expires'] = 86400 * 30 # This cookie is used to indicate that the user is actually using # the "Remember me" feature. This is necessary for # '_get_name_for_cookie()'. req.outcookie['trac_auth_session'] = 1 req.outcookie['trac_auth_session']['path'] = req.base_path or '/' req.outcookie['trac_auth_session']['expires'] = 86400 * 30 return res
def _redirect_back(self, req): """Redirect the user back to the URL she came from.""" referer = self._referer(req) if referer and not referer.startswith(req.base_url): referer = None req.redirect(referer or self.env.abs_href()) def _referer(self, req): return req.args.get('referer') or req.get_header('Referer')
def _remote_user(self, req): user = req.args.get('user') password = req.args.get('password') if not user or not password: return None if AccountManager(self.env).check_password(user, password): return user return None
True, doc="Forge the user to change "
True, doc="Force the user to change "
def user_email_verification_requested(self, user, token): """User verification requested """
if re.search(r"Waiting time before each download begins", self.html[1]) is not None:
if re.search(r"Waiting time before each download begins", self.html[1]) != None:
def download_html(self): for i in range(5): self.html[0] = self.load(self.pyfile.url) try: url_captcha_html = re.search('(http://www.{,3}\.megaupload\.com/gencap.php\?.*\.gif)', self.html[0]).group(1) except: continue
adress,
password, address,
def white(string): return "\033[1;37m" + string + "\033[0m"
passwort
def white(string): return "\033[1;37m" + string + "\033[0m"
self.log.info(_("Netload: waiting for captcha %d s." % t - time()))
self.log.info(_("Netload: waiting for captcha %d s.") % (t- time()))
def download_html(self): self.log.debug("Netload: Entering download_html") page = self.load(self.url) t = time() + 30
__version__ = "2.0"
__version__ = "0.2"
def getInfo(urls): ids = "" names = "" p = re.compile(RapidshareCom.__pattern__) for url in urls: r = p.search(url) if r.group("name"): ids+= ","+r.group("id") names+= ","+r.group("name") elif r.group("name_new"): ids+= ","+r.group("id_new") names+= ","+r.group("name_new") url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=%s&filenames=%s" % (ids[1:], names[1:]) api = getURL(url) result = [] i = 0 for res in api.split(): tmp = res.split(",") if tmp[4] in ("0", "4", "5"): status = 1 elif tmp[4] == "1": status = 2 else: status = 3 result.append( (tmp[1], tmp[2], status, urls[i]) ) i += 1 yield result
__pattern__ = r"http://hotfile.com/dl/"
__pattern__ = r"http://(www.)?hotfile\.com/dl/\d+/[0-9a-zA-Z]+/"
def getInfo(urls): api_url_base = "http://api.hotfile.com/" for chunk in chunks(urls, 90): api_param_file = {"action":"checklinks","links": ",".join(chunk),"fields":"id,status,name,size"} #api only supports old style links src = getURL(api_url_base, post=api_param_file) result = [] for i, res in enumerate(src.split("\n")): if not res: continue fields = res.split(",") if fields[1] in ("1", "2"): status = 2 elif fields[1]: status = 1 result.append((fields[2], int(fields[3]), status, chunk[i])) yield result
file_url = re.search(r'a href="(http://hotfile\.com/get/\S*?)"', self.html[1]).group(1)
file_url = re.search(r'a href="(http://hotfile\.com/get/\S*)"', self.html[1]).group(1)
def freeDownload(self): form_content = re.search(r"<form style=.*(\n<.*>\s*)*?\n<tr>", self.html[0]).group(0) form_posts = re.findall(r"<input\stype=hidden\sname=(\S*)\svalue=(\S*)>", form_content) self.html[1] = self.load(self.pyfile.url, post=form_posts, cookies=True) re_captcha = ReCaptcha(self) challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", self.html[1]) if challenge: challenge, result = re_captcha.challenge(challenge.group(1)) url = re.search(r'<form action="(/dl/[^"]+)', self.html[1] ) self.html[1] = self.load("http://hotfile.com"+url.group(1), post={"action": "checkcaptcha", "recaptcha_challenge_field" : challenge, "recaptcha_response_field": result}) if "Wrong Code. Please try again." in self.html[1]: self.freeDownload() return file_url = re.search(r'a href="(http://hotfile\.com/get/\S*?)"', self.html[1]).group(1) self.download(file_url)
time_data = data["options"]["time"][0]
def selectAccount(self): """ returns an valid account name and data""" usable = [] for user,data in self.accounts.iteritems(): if not data["valid"]: continue
xmlconfig = XMLConfigParser(join(abspath(dirname(__file__)),"module","config","core.xml"), join(abspath(dirname(__file__)),"module","config","core_default.xml"))
xmlconfig = XMLConfigParser(join(abspath(dirname(__file__)),"module","config","core.xml"))
def white(string): return "\033[1;37m" + string + "\033[0m"
def __init__(self, parent): Hoster.__init__(self, parent) self.parent = parent
def setup(self): self.multiDL = False def process(self, pyfile):
def __init__(self, parent): Hoster.__init__(self, parent) self.parent = parent self.html = [None, None, None] self.want_reconnect = False self.multi_dl = False self.api_data = None self.init_ocr() self.read_config() if self.config['premium']: self.multi_dl = True else: self.multi_dl = False
self.want_reconnect = False self.multi_dl = False self.api_data = None self.init_ocr() self.read_config() if self.config['premium']: self.multi_dl = True else: self.multi_dl = False def prepare(self, thread): pyfile = self.parent self.req.clear_cookies() self.want_reconnect = False
self.url = pyfile.url self.prepare() self.pyfile.setStatus("downloading") self.proceed(self.url) def prepare(self):
def __init__(self, parent): Hoster.__init__(self, parent) self.parent = parent self.html = [None, None, None] self.want_reconnect = False self.multi_dl = False self.api_data = None self.init_ocr() self.read_config() if self.config['premium']: self.multi_dl = True else: self.multi_dl = False
pyfile.status.filename = self.get_file_name()
self.pyfile.name = self.get_file_name()
def prepare(self, thread): pyfile = self.parent self.req.clear_cookies() self.want_reconnect = False
if self.config['premium']: self.logger.info("Netload: Use Premium Account") pyfile.status.url = self.parent.url return True while not pyfile.status.url: self.download_html() self.get_wait_time() pyfile.status.waituntil = self.time_plus_wait pyfile.status.want_reconnect = self.want_reconnect thread.wait(self.parent) pyfile.status.url = self.get_file_url()
self.download_html() self.setWait(self.get_wait_time()) self.log.info("Netload: waiting %d seconds" % self.get_wait_time()) self.pyfile.setStatus("waiting") sleep(self.get_wait_time()) self.url = self.get_file_url()
def prepare(self, thread): pyfile = self.parent self.req.clear_cookies() self.want_reconnect = False
return False
self.offline()
def prepare(self, thread): pyfile = self.parent self.req.clear_cookies() self.want_reconnect = False
url = self.parent.url
url = self.url
def download_api_data(self): url = self.parent.url id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") match = id_regex.search(url) if match: apiurl = "http://netload.in/share/fileinfos2.php" src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)}) self.api_data = {} if src == "unknown_server_data": self.api_data = False self.html[0] = self.req.load(self.parent.url, cookies=False) elif not src == "unknown file_data": lines = src.split(";") self.api_data["exists"] = True self.api_data["fileid"] = lines[0] self.api_data["filename"] = lines[1] self.api_data["size"] = lines[2] #@TODO formatting? (ex: '2.07 KB') self.api_data["status"] = lines[3] self.api_data["checksum"] = lines[4].strip() else: self.api_data["exists"] = False
src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)})
src = self.load(apiurl, cookies=False, get={"file_id": match.group(1)})
def download_api_data(self): url = self.parent.url id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") match = id_regex.search(url) if match: apiurl = "http://netload.in/share/fileinfos2.php" src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)}) self.api_data = {} if src == "unknown_server_data": self.api_data = False self.html[0] = self.req.load(self.parent.url, cookies=False) elif not src == "unknown file_data": lines = src.split(";") self.api_data["exists"] = True self.api_data["fileid"] = lines[0] self.api_data["filename"] = lines[1] self.api_data["size"] = lines[2] #@TODO formatting? (ex: '2.07 KB') self.api_data["status"] = lines[3] self.api_data["checksum"] = lines[4].strip() else: self.api_data["exists"] = False
self.html[0] = self.req.load(self.parent.url, cookies=False)
self.html[0] = self.load(self.url, cookies=False)
def download_api_data(self): url = self.parent.url id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") match = id_regex.search(url) if match: apiurl = "http://netload.in/share/fileinfos2.php" src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)}) self.api_data = {} if src == "unknown_server_data": self.api_data = False self.html[0] = self.req.load(self.parent.url, cookies=False) elif not src == "unknown file_data": lines = src.split(";") self.api_data["exists"] = True self.api_data["fileid"] = lines[0] self.api_data["filename"] = lines[1] self.api_data["size"] = lines[2] #@TODO formatting? (ex: '2.07 KB') self.api_data["status"] = lines[3] self.api_data["checksum"] = lines[4].strip() else: self.api_data["exists"] = False
self.html[0] = self.req.load(self.parent.url, cookies=True)
self.html[0] = self.load(self.url, cookies=True)
def download_html(self): self.html[0] = self.req.load(self.parent.url, cookies=True) url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[0]).group(1).replace("amp;", "") for i in range(6): self.html[1] = self.req.load(url_captcha_html, cookies=True) try: captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) except: url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[1]).group(1).replace("amp;", "") self.html[1] = self.req.load(url_captcha_html, cookies=True) captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)
for i in range(6): self.html[1] = self.req.load(url_captcha_html, cookies=True) try: captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) except: url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[1]).group(1).replace("amp;", "") self.html[1] = self.req.load(url_captcha_html, cookies=True) captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)
m = re.search(r"countdown\((\d+),'change\(\)'\);", url_captcha_html) if m: wait_time = int(m.group(1)) self.log.info("Netload: waiting %d seconds." % wait_time) sleep(wait_time)
def download_html(self): self.html[0] = self.req.load(self.parent.url, cookies=True) url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[0]).group(1).replace("amp;", "") for i in range(6): self.html[1] = self.req.load(url_captcha_html, cookies=True) try: captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) except: url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[1]).group(1).replace("amp;", "") self.html[1] = self.req.load(url_captcha_html, cookies=True) captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)
file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', self.html[1]).group(1) captcha_image = tempfile.NamedTemporaryFile(suffix=".png").name self.req.download(captcha_url, captcha_image, cookies=True) captcha = self.ocr.get_captcha(captcha_image) os.remove(captcha_image) self.logger.debug("Captcha %s: %s" % (i, captcha)) sleep(5) self.html[2] = self.req.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, cookies=True)
self.html[1] = self.load(url_captcha_html, cookies=True) try: captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) except: url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[1]).group(1).replace("amp;", "") self.html[1] = self.load(url_captcha_html, cookies=True) captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)
def download_html(self): self.html[0] = self.req.load(self.parent.url, cookies=True) url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[0]).group(1).replace("amp;", "") for i in range(6): self.html[1] = self.req.load(url_captcha_html, cookies=True) try: captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) except: url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[1]).group(1).replace("amp;", "") self.html[1] = self.req.load(url_captcha_html, cookies=True) captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)
if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None: return True
file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', self.html[1]).group(1)
def download_html(self): self.html[0] = self.req.load(self.parent.url, cookies=True) url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[0]).group(1).replace("amp;", "") for i in range(6): self.html[1] = self.req.load(url_captcha_html, cookies=True) try: captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) except: url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[1]).group(1).replace("amp;", "") self.html[1] = self.req.load(url_captcha_html, cookies=True) captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)
raise Exception("Captcha not decrypted")
captcha = self.decryptCaptcha(captcha_url) sleep(5) self.html[2] = self.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, cookies=True) if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None: return True fail("Captcha not decrypted")
def download_html(self): self.html[0] = self.req.load(self.parent.url, cookies=True) url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[0]).group(1).replace("amp;", "") for i in range(6): self.html[1] = self.req.load(url_captcha_html, cookies=True) try: captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) except: url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&amp;.*&amp;captcha=1)', self.html[1]).group(1).replace("amp;", "") self.html[1] = self.req.load(url_captcha_html, cookies=True) captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)
if re.search(r"We had a reqeust with the IP", self.html[2]):
if re.search(r"We had a request with the IP", self.html[2]):
def get_wait_time(self): if re.search(r"We had a reqeust with the IP", self.html[2]): wait_minutes = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 6000 self.want_reconnect = True self.time_plus_wait = time() + wait_minutes * 60 return wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 100 self.time_plus_wait = time() + wait_seconds
self.want_reconnect = True self.time_plus_wait = time() + wait_minutes * 60 return
self.wantReconnect = True return wait_minutes * 60
def get_wait_time(self): if re.search(r"We had a reqeust with the IP", self.html[2]): wait_minutes = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 6000 self.want_reconnect = True self.time_plus_wait = time() + wait_minutes * 60 return wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 100 self.time_plus_wait = time() + wait_seconds
self.time_plus_wait = time() + wait_seconds
return wait_seconds
def get_wait_time(self): if re.search(r"We had a reqeust with the IP", self.html[2]): wait_minutes = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 6000 self.want_reconnect = True self.time_plus_wait = time() + wait_minutes * 60 return wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 100 self.time_plus_wait = time() + wait_seconds
return self.parent.url
return self.url
def get_file_name(self): if self.api_data and self.api_data["filename"]: return self.api_data["filename"] elif self.html[0]: file_name_pattern = '\t\t\t(.+)<span style="color: #8d8d8d;">' file_name_search = re.search(file_name_pattern, self.html[0]) if file_name_search: return file_name_search.group(1) return self.parent.url
def proceed(self, url, location): if self.config['premium']: self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True) self.req.download(url, location, cookies=True)
def proceed(self, url): self.download(url, cookies=True)
def proceed(self, url, location): if self.config['premium']: self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True) self.req.download(url, location, cookies=True)
download = "http://%(host)s/cgi-bin/rsapi.cgi?sub=download_v1&editparentlocation=1&bin=1&fileid=%(id)s&filename=%(name)s&dlauth=%(auth)s dl = self.download(download)
tmp = " download = "http://%(host)s/cgi-bin/rsapi.cgi?sub=download_v1&editparentlocation=1&bin=1&fileid=%(id)s&filename=%(name)s&dlauth=%(auth)s" % self.dl_dict dl = self.download(download, ref=False)
def handleFree(self):
self.no_download = True
def postCheck(self, dl):
sleep(5)
self.offset += 5
def postCheck(self, dl):
self.html[1] = self.load(self.pyfile.url)
self.html[1] = self.load(self.pyfile.url,ref=False) print self.html[1] sleep(1)
def freeWait(self): """downloads html with the important informations """ self.html[1] = self.load(self.pyfile.url) self.no_download = True
result = self.load(prepare)
result = self.load(prepare, ref=False)
def freeWait(self): """downloads html with the important informations """ self.html[1] = self.load(self.pyfile.url) self.no_download = True
self.setWait(int(data[2])+5+self.offset)
self.setWait(int(data[2])+2+self.offset)
def freeWait(self): """downloads html with the important informations """ self.html[1] = self.load(self.pyfile.url) self.no_download = True
thread.start_new_thread(proxy, (ip, self.port, 9666))
thread.start_new_thread(proxy, (self, ip, self.port, 9666))
def coreReady(self): self.port = int(self.core.config['webinterface']['port']) if self.core.config['webinterface']['activated']: try:
def proxy(*settings): thread.start_new_thread(server, settings)
def proxy(self, *settings): thread.start_new_thread(server, (self,)+settings)
def proxy(*settings): thread.start_new_thread(server, settings) lock = thread.allocate_lock() lock.acquire() lock.acquire()
def server(*settings):
def server(self, *settings):
def server(*settings): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) dock_socket.bind((settings[0], settings[2])) dock_socket.listen(5) while True: client_socket = dock_socket.accept()[0] server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.connect(("127.0.0.1", settings[1])) thread.start_new_thread(forward, (client_socket, server_socket)) thread.start_new_thread(forward, (server_socket, client_socket)) except: pass finally: thread.start_new_thread(server, settings)
pass finally: thread.start_new_thread(server, settings)
thread.start_new_thread(server, (self,)+settings)
def server(*settings): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) dock_socket.bind((settings[0], settings[2])) dock_socket.listen(5) while True: client_socket = dock_socket.accept()[0] server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.connect(("127.0.0.1", settings[1])) thread.start_new_thread(forward, (client_socket, server_socket)) thread.start_new_thread(forward, (server_socket, client_socket)) except: pass finally: thread.start_new_thread(server, settings)
from random import randint jid = randint(0,1000) print "Get file for downloading, id:", jid
def getJob(self, occ): """get suitable job""" #@TODO clean mess #@TODO improve selection of valid jobs from random import randint jid = randint(0,1000) print "Get file for downloading, id:", jid if self.jobCache.has_key(occ): if self.jobCache[occ]: id = self.jobCache[occ].pop() if id == "empty": pyfile = None self.jobCache[occ].append("empty") else: pyfile = self.getFile(id) else: jobs = self.db.getJob(occ) jobs.reverse() if not jobs: self.jobCache[occ].append("empty") pyfile = None else: self.jobCache[occ].extend(jobs) pyfile = self.getFile(self.jobCache[occ].pop()) else: self.jobCache = {} #better not caching to much jobs = self.db.getJob(occ) jobs.reverse() self.jobCache[occ] = jobs if not jobs: self.jobCache[occ].append("empty") pyfile = None pyfile = self.getFile(self.jobCache[occ].pop()) #@TODO: maybe the new job has to be approved... #pyfile = self.getFile(self.jobCache[occ].pop()) print jid, "going to download:", pyfile return pyfile
pyfile = self.getFile(self.jobCache[occ].pop())
else: pyfile = self.getFile(self.jobCache[occ].pop())
def getJob(self, occ): """get suitable job""" #@TODO clean mess #@TODO improve selection of valid jobs from random import randint jid = randint(0,1000) print "Get file for downloading, id:", jid if self.jobCache.has_key(occ): if self.jobCache[occ]: id = self.jobCache[occ].pop() if id == "empty": pyfile = None self.jobCache[occ].append("empty") else: pyfile = self.getFile(id) else: jobs = self.db.getJob(occ) jobs.reverse() if not jobs: self.jobCache[occ].append("empty") pyfile = None else: self.jobCache[occ].extend(jobs) pyfile = self.getFile(self.jobCache[occ].pop()) else: self.jobCache = {} #better not caching to much jobs = self.db.getJob(occ) jobs.reverse() self.jobCache[occ] = jobs if not jobs: self.jobCache[occ].append("empty") pyfile = None pyfile = self.getFile(self.jobCache[occ].pop()) #@TODO: maybe the new job has to be approved... #pyfile = self.getFile(self.jobCache[occ].pop()) print jid, "going to download:", pyfile return pyfile
print jid, "going to download:", pyfile
def getJob(self, occ): """get suitable job""" #@TODO clean mess #@TODO improve selection of valid jobs from random import randint jid = randint(0,1000) print "Get file for downloading, id:", jid if self.jobCache.has_key(occ): if self.jobCache[occ]: id = self.jobCache[occ].pop() if id == "empty": pyfile = None self.jobCache[occ].append("empty") else: pyfile = self.getFile(id) else: jobs = self.db.getJob(occ) jobs.reverse() if not jobs: self.jobCache[occ].append("empty") pyfile = None else: self.jobCache[occ].extend(jobs) pyfile = self.getFile(self.jobCache[occ].pop()) else: self.jobCache = {} #better not caching to much jobs = self.db.getJob(occ) jobs.reverse() self.jobCache[occ] = jobs if not jobs: self.jobCache[occ].append("empty") pyfile = None pyfile = self.getFile(self.jobCache[occ].pop()) #@TODO: maybe the new job has to be approved... #pyfile = self.getFile(self.jobCache[occ].pop()) print jid, "going to download:", pyfile return pyfile
pdata["packages"] = map(PyLoadPackageData().set, self.data["packages"]) pdata["queue"] = map(PyLoadPackageData().set, self.data["queue"]) pdata["collector"] = map(PyLoadFileData().set, self.data["collector"])
pdata["packages"] = [PyLoadPackageData().set(x) for x in self.data["packages"]] pdata["queue"] = [PyLoadPackageData().set(x) for x in self.data["queue"]] pdata["collector"] = [PyLoadFileData().set(x) for x in self.data["collector"]]
def save(self): self.lock.acquire() pdata = { "version": LIST_VERSION, "queue": [], "packages": [], "collector": [] }
self.files = map(PyLoadFileData().set, pypack.files)
self.files = [PyLoadFileData().set(x) for x in pypack.files]
def set(self, pypack): self.data = pypack.data self.files = map(PyLoadFileData().set, pypack.files) return self
return self.req.load(url, get, post, ref, cookies, just_header)
res = self.req.load(url, get, post, ref, cookies, just_header) if self.core.debug: from inspect import currentframe frame = currentframe() if not exists(join("tmp", self.__name__)): makedirs(join("tmp", self.__name__)) f = open(join("tmp", self.__name__, "%s_line%s.dump" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)), "wb") f.write(res) f.close() return res
def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False): """ returns the content loaded """ if self.pyfile.abort: raise Abort return self.req.load(url, get, post, ref, cookies, just_header)
self.setWait(wait)
self.setWait(int(wait)+3)
def handleFree(self): if r'<div id="captchaArea" style="display:none;">' in self.html or \ r'/showCaptcha\(\);' in self.html: # we got a captcha id = re.search(r"var reCAPTCHA_publickey='(.*?)';", self.html).group(1) recaptcha = ReCaptcha(self) challenge, code = recaptcha.challenge(id) shortencode = re.search(r'name="recaptcha_shortencode_field" value="(.*?)"', self.html).group(1)
videoHash = re.search(r', "t": "([^"]+)"', self.html).group(1)
videoHash = re.search(r'&t=(.+?)&', self.html).group(1)
def get_file_url(self): """ returns the absolute downloadable filepath """ if self.html == None: self.download_html()
file_name_pattern = r"'VIDEO_TITLE': '(.*)',"
file_name_pattern = r'<span class="" title="(.+?)">'
def get_file_name(self): if self.html == None: self.download_html()
p1 = getpass(qst)
p1 = getpass(qst.encode("utf-8"))
def ask(self, qst, default, answers=[], bool=False, password=False): """produce one line to asking for input""" if answers: info = "("
p2 = getpass(qst)
p2 = getpass(qst.encode("utf-8"))
def ask(self, qst, default, answers=[], bool=False, password=False): """produce one line to asking for input""" if answers: info = "("
size = re.search(r"<span><strong>(.*?) MB</strong>", html).group(1)
size = re.search(r'<span style="float: left;"><strong>(.*?) MB</strong>', html).group(1)
def getInfo(urls): result = [] for url in urls: html = getURL(url) if re.search(r'<h1>File not available</h1>', html): result.append((url, 0, 1, url)) continue size = re.search(r"<span><strong>(.*?) MB</strong>", html).group(1) size = int(float(size)*1024*1024) name = re.search('<h1>(.*?)<br/></h1>', html).group(1) result.append((name, size, 2, url)) yield result
file_url = urllib.unquote(file_url_search.replace("nnn", "aaa").replace("unlg", "v").replace("serwus", "zippyshare"))
file_url = urllib.unquote(file_url_search.replace("nnn", "aaa").replace("cxc", "www").replace("unlg", "v").replace("konaworld", "zippyshare"))
def get_file_url(self): """ returns the absolute downloadable filepath """ file_url_pattern = r"var \w* = '(http%.*?)';" file_url_search = re.search(file_url_pattern, self.html).group(1) file_url = urllib.unquote(file_url_search.replace("nnn", "aaa").replace("unlg", "v").replace("serwus", "zippyshare")) return file_url
f.write(res.encode("utf8"))
try: res = res.encode("utf8") except: pass f.write(res)
def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, no_post_encode=False, raw_cookies={}): """ returns the content loaded """ if self.pyfile.abort: raise Abort
print _("%s: OK" % name)
print _("%s: OK") % name
def print_dep(self, name, value): """Print Status of dependency""" if value: print _("%s: OK" % name) else: print _("%s: missing" % name)
print _("%s: missing" % name)
print _("%s: missing") % name
def print_dep(self, name, value): """Print Status of dependency""" if value: print _("%s: OK" % name) else: print _("%s: missing" % name)
reconn = Popen(self.core.config['reconnect']['method'], bufsize=-1)
reconn = Popen(self.core.config['reconnect']['method'], bufsize=-1, shell=True)
def tryReconnect(self): """checks if reconnect needed"""
self.config["general"]["username"] = self.ask(_("Username"), "User") self.config["general"]["password"] = self.ask("", "", password=True)
self.config["remote"]["username"] = self.ask(_("Username"), "User") self.config["remote"]["password"] = self.ask("", "", password=True)
def conf_basic(self): print "" print _("## Basic Setup ##")
self.ask(_("Username"), "User") self.ask("", "", password=True)
print _("Setting new username and password") print "" self.config["remote"]["username"] = self.ask(_("Username"), "User") self.config["remote"]["password"] = self.ask("", "", password=True)
def set_user(self):
for x in self.cache.itervalues():
cache = self.cache.values() for x in cache:
def getPackageData(self, id): """returns dict with package information""" pack = self.getPackage(id) if not pack: return None pack = pack.toDict()[id] data = self.db.getPackageData(id) tmplist = [] for x in self.cache.itervalues(): if int(x.toDbDict()[x.id]["package"]) == int(id): tmplist.append((str(x.id), x.toDbDict()[x.id])) data.update(tmplist) pack["links"] = data return pack
i = 0 for item in occ:
for i, item in enumerate(occ):
def getJob(self, occ): """return pyfile instance, which is suitable for download and dont use a occupied plugin""" cmd = "(" i = 0 for item in occ: if i != 0: cmd += ", " cmd += "'%s'" % item cmd += ")" cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=1 AND l.plugin NOT IN %s AND l.status IN (2,3,6,14) ORDER BY p.priority DESC, p.packageorder ASC, l.linkorder ASC LIMIT 5" % cmd self.c.execute(cmd) # very bad!
abort = False
self.abort = False
def abortDownload(self): """abort pyfile if possible""" while self.id in self.m.core.threadManager.processingIds(): self.abort = True if self.plugin and self.plugin.req: self.plugin.req.abort = True sleep(0.1) abort = False if self.plugin and self.plugin.req: self.plugin.req.abort = False
n = n.strip() n = re.sub(r"^([:]?)(.*?)([:]?)$", r'\2', n)
def handleSeason(self, url): src = self.getSJSrc(url) soup = BeautifulSoup(src) post = soup.find("div", attrs={"class": "post-content"}) ps = post.findAll("p") hosterPattern = re.compile("^http://download\.serienjunkies\.org/f-.*?/([rcfultns]{2})_.*?\.html$") preferredHoster = self.getConfig("preferredHoster").split(",") self.log.debug("Preferred hoster: %s" % ", ".join(preferredHoster)) groups = {} gid = -1 seasonName = unescape(soup.find("a", attrs={"rel":"bookmark"}).string) for p in ps: if re.search("<strong>Dauer|<strong>Sprache|<strong>Format", str(p)): var = p.findAll("strong") opts = {"Dauer": "", "Uploader": "", "Sprache": "", "Format": "", u"Größe": ""} for v in var: n = unescape(v.string) val = v.nextSibling val = val.encode("utf-8") val = unescape(val) val = val.replace("|", "").strip() n = n.strip() n = re.sub(r"^([:]?)(.*?)([:]?)$", r'\2', n) val = val.strip() val = re.sub(r"^([:]?)(.*?)([:]?)$", r'\2', val) opts[n.strip()] = val.strip() gid += 1 groups[gid] = {} groups[gid]["ep"] = [] groups[gid]["opts"] = opts elif re.search("<strong>Download:", str(p)): links1 = p.findAll("a", attrs={"href": hosterPattern}) links2 = p.findAll("a", attrs={"href": re.compile("^http://serienjunkies.org/safe/.*$")}) for link in links1 + links2: groups[gid]["ep"].append(link["href"]) for g in groups.values(): links = [] linklist = g["ep"] package = "%s (%s, %s)" % (seasonName, g["opts"]["Format"], g["opts"]["Sprache"]) linkgroups = {} for link in linklist: key = re.sub("^http://download\.serienjunkies\.org/f-.*?/(.{2})_", "", link) if not linkgroups.has_key(key): linkgroups[key] = [] linkgroups[key].append(link) for group in linkgroups.values(): for pHoster in preferredHoster: hmatch = False for link in group: m = hosterPattern.match(link) if m: if pHoster == self.hosterMap[m.group(1)]: links.append(link) hmatch = True break if hmatch: break self.packages.append((package, links, package))
if link.startswith("[") and link.endswith("]\n"):
if link.startswith("[") and link.endswith("]"):
def proceed(self, linkList, location): txt = open(linkList, 'r') links = txt.readlines() packages = {"Parsed links":[],} curPack = "Parsed links" for link in links: if link != "\n": link = link.strip() if link.startswith(";"): continue if link.startswith("[") and link.endswith("]\n"): # new package curPack = link[1:-2] packages[curPack] = [] continue packages[curPack].append(link.replace("\n", "")) txt.close() # empty Parsed links fix if len(packages["Parsed links"]) < 1: del packages["Parsed links"]
if self.account: self.log.debug("Netload: Use Premium Account") return True
def prepare(self): self.download_api_data() if self.file_exists(): self.pyfile.name = self.get_file_name()
if re.search(r"We had a request with the IP", self.html[2]):
if re.search(r"We had a reqeust with the IP", self.html[2]):
def get_wait_time(self): if re.search(r"We had a request with the IP", self.html[2]): wait_minutes = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 6000 self.wantReconnect = True return wait_minutes * 60 wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 100 return wait_seconds
@lock
def getCompleteData(self, queue=1): """gets a complete data representation"""
@lock
def addPackage(self, name, folder, queue=0): """adds a package, default to link collector""" lastID = self.db.addPackage(name, folder, queue) p = self.db.getPackage(lastID) e = InsertEvent("pack", lastID, p.order, "collector" if not queue else "queue") self.core.pullManager.addEvent(e) return lastID
@lock
def deletePackage(self, id): """delete package and all contained links""" p = self.getPackage(id) e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") pyfiles = self.cache.values() for pyfile in pyfiles: if pyfile.packageid == id: pyfile.abortDownload() pyfile.release()
@lock
def getQueueCount(self): """number of files that have to be processed""" pass
for pyfile in self.cache.itervalues():
pyfiles = self.cache.values() for pyfile in pyfiles:
def restartPackage(self, id): """restart package""" for pyfile in self.cache.itervalues(): if pyfile.packageid == id: self.restartFile(pyfile.id) self.db.restartPackage(id) e = UpdateEvent("pack", id, "collector" if not self.getPackage(id).queue else "queue") self.core.pullManager.addEvent(e)
@lock
def restartPackage(self, id): """restart package""" for pyfile in self.cache.itervalues(): if pyfile.packageid == id: self.restartFile(pyfile.id) self.db.restartPackage(id) e = UpdateEvent("pack", id, "collector" if not self.getPackage(id).queue else "queue") self.core.pullManager.addEvent(e)
self.cache[id].abortDownload()
def restartFile(self, id): """ restart file""" if self.cache.has_key(id): self.cache[id].abortDownload() self.cache[id].status = 3 self.cache[id].name = self.cache[id].url self.cache[id].error = "" self.cache[id].sync() else: self.db.restartFile(id) e = UpdateEvent("file", id, "collector" if not self.getFile(id).package().queue else "queue") self.core.pullManager.addEvent(e)
self.cache[id].sync() else: self.db.restartFile(id)
self.cache[id].abortDownload() self.db.restartFile(id)
def restartFile(self, id): """ restart file""" if self.cache.has_key(id): self.cache[id].abortDownload() self.cache[id].status = 3 self.cache[id].name = self.cache[id].url self.cache[id].error = "" self.cache[id].sync() else: self.db.restartFile(id) e = UpdateEvent("file", id, "collector" if not self.getFile(id).package().queue else "queue") self.core.pullManager.addEvent(e)
@lock
def restartFile(self, id): """ restart file""" if self.cache.has_key(id): self.cache[id].abortDownload() self.cache[id].status = 3 self.cache[id].name = self.cache[id].url self.cache[id].error = "" self.cache[id].sync() else: self.db.restartFile(id) e = UpdateEvent("file", id, "collector" if not self.getFile(id).package().queue else "queue") self.core.pullManager.addEvent(e)
@lock
def setPackageLocation(self, id, queue): """push package to queue""" pack = self.db.getPackage(id) e = RemoveEvent("pack", id, "collector" if not pack.queue else "queue") self.core.pullManager.addEvent(e) self.db.clearPackageOrder(pack) pack = self.db.getPackage(id) pack.queue = queue self.db.updatePackage(pack) self.db.reorderPackage(pack, -1, True) self.db.commit() self.releasePackage(id) pack = self.getPackage(id) e = InsertEvent("pack", id, pack.order, "collector" if not pack.queue else "queue") self.core.pullManager.addEvent(e)
@lock
def reorderPackage(self, id, position): p = self.db.getPackage(id) e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") self.core.pullManager.addEvent(e) self.db.reorderPackage(p, position) self.db.commit() e = ReloadAllEvent("collector" if not p.queue else "queue") self.core.pullManager.addEvent(e)
self.m.cache[int(id)] = self
def __init__(self, manager, id, url, name, size, status, error, pluginname, package, order): self.m = manager self.m.cache[int(id)] = self self.id = int(id) self.url = url self.name = name self.size = size self.status = status self.pluginname = pluginname self.packageid = package #should not be used, use package() instead self.error = error self.order = order # database information ends here self.plugin = None self.waitUntil = 0 # time() + time to wait # status attributes self.active = False #obsolete? self.abort = False self.reconnected = False
file_name = re.search("<strong>Name: </strong>(.*)</font><br />", self.html).group(1)
file_name = re.search("<strong>Name: </strong>(.+?)</font>", self.html).group(1)
def get_file_name(self): if self.html == None: self.download_html() if not self.want_reconnect: file_name = re.search("<strong>Name: </strong>(.*)</font><br />", self.html).group(1) return file_name else: return self.parent.url
content = f.readline(1) version = content.split(":")[1].strip() if content else ""
content = f.readlines() version = content[0].split(":")[1].strip() if content else "" f.close()
def loadAccounts(self): """loads all accounts available""" if not exists("accounts.conf"): f = open("accounts.conf", "wb") f.write("version: " + str(ACC_VERSION)) f.close() f = open("accounts.conf", "rb") content = f.readline(1) version = content.split(":")[1].strip() if content else ""
f.close()
def loadAccounts(self): """loads all accounts available""" if not exists("accounts.conf"): f = open("accounts.conf", "wb") f.write("version: " + str(ACC_VERSION)) f.close() f = open("accounts.conf", "rb") content = f.readline(1) version = content.split(":")[1].strip() if content else ""
for line in content:
for line in content[1:]:
def loadAccounts(self): """loads all accounts available""" if not exists("accounts.conf"): f = open("accounts.conf", "wb") f.write("version: " + str(ACC_VERSION)) f.close() f = open("accounts.conf", "rb") content = f.readline(1) version = content.split(":")[1].strip() if content else ""
return re.search(file_name_pattern, self.html).group(1).replace("&amp;", "&") + '.flv'
return re.search(file_name_pattern, self.html).group(1).replace("&amp;", "&").replace("/","") + '.flv'
def get_file_name(self): if self.html == None: self.download_html()
if self.api_data["size"] > info["trafficleft"]:
if self.api_data["size"]/1024 > info["trafficleft"]:
def prepare(self, thread): self.want_reconnect = False tries = 0
if not src and n < 3:
if not src and n <= 3:
def download_api_data(self, n=0): url = self.url id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") match = id_regex.search(url) if match: apiurl = "http://netload.in/share/fileinfos2.php" src = self.load(apiurl, cookies=False, get={"file_id": match.group(1)}).strip() if not src and n < 3: sleep(0.2) self.download_api_data(n+1) return else: self.fail(_("No API Data was send"))
else:
elif not src:
def download_api_data(self, n=0): url = self.url id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") match = id_regex.search(url) if match: apiurl = "http://netload.in/share/fileinfos2.php" src = self.load(apiurl, cookies=False, get={"file_id": match.group(1)}).strip() if not src and n < 3: sleep(0.2) self.download_api_data(n+1) return else: self.fail(_("No API Data was send"))