def login(self, browser, account): url = "https://www.bigfile.to/login.php" browser.visit(url) if not browser.is_text_present('Forgot Password'): print('Already logged in at BigFile.to') return True globalvar.getElement(browser, 'name', 'userName').fill(account['username']) globalvar.getElement(browser, 'name', 'userPassword').fill(account['password']) # Find and click the 'search' button button = globalvar.getElement(browser, 'id', 'loginFormSubmit') # Interact with elements button.click() globalvar.sleep(10, 20) if browser.url == "https://www.bigfile.to/indexboard.php" or browser.url == "https://www.bigfile.to/uploadremote.php": print("Logged in on to Bigfile") return True else: print("Bigfile login failed") return False
def login(self, browser, account): url = "http://www.anime-sharing.com/forum/login.php?do=login" browser.visit(url) globalvar.sleep(3, 5) if browser.is_text_present('My Profile') and browser.is_text_present( 'yuuichi_sagara'): print('Already logged in') return if browser.url == 'http://www.anime-sharing.com/forum/index.php': globalvar.getElement( browser, 'xpath', '//input[@class="fixed_header_login_button"]').first.click() globalvar.sleep(3, 5) globalvar.getElement(browser, 'id', 'vb_login_username').fill(account['username']) globalvar.getElement(browser, 'id', 'vb_login_password').fill(account['password']) globalvar.getElement( browser, 'xpath', '//div[@class="blockfoot actionbuttons"]//input[@value="Log in"]' ).first.click() globalvar.sleep(3, 5)
def submit(self, browser): while True: buttons = globalvar.getElement(browser, 'name', 'sbutton') for button in buttons: print('Finding and clicking the submit button') if button['value'] == 'Submit New Thread': button.click() globalvar.sleep(30, 60) if browser.is_text_present( 'This forum requires that you wait 3600 seconds'): print('Post was to soon, must wait 3600 seconds') nr = random.randint(12, 20) for i in range(0, nr): print('sleep {0} of {1}'.format(i + 1, nr)) globalvar.sleep(100) break else: print('Post was submitted') globalvar.sleep(60, 120) return True
def editEntryAndGetPost(self, browser, entry, entryType, images, bigfileUrls, rapidUrls): url = "http://hcapital.tk/?show=edit&id={0}&type={1}".format( entry, entryType) browser.visit(url) globalvar.sleep(2, 4) bigfileUrlsText = '\n'.join(bigfileUrls[0]) globalvar.getElement(browser, 'id', 'biglinks').first.fill(bigfileUrlsText) if len(rapidUrls) > 1: browser.check('other') globalvar.sleep(2, 4) for i in range(1, len(rapidUrls)): rapidUrlText = '\n'.join(rapidUrls[i]) bigfileUrlsText = '\n'.join(bigfileUrls[i]) text = rapidUrlText + '\n-\n' + bigfileUrlsText textfieldId = 'other{0}links'.format(i) globalvar.getElement(browser, 'id', textfieldId).first.fill(text) globalvar.getElement(browser, 'name', 'sharing').first.fill(images) globalvar.getElement(browser, 'id', 'submit').first.click() globalvar.sleep(2, 4) clipHolder = pyperclip.paste() globalvar.getElement(browser, 'id', 'copy_button').first.click() post = pyperclip.paste() pyperclip.copy(clipHolder) globalvar.sleep(2, 4) post = post.replace(' ', ' ') return post
def download(self, browser, urls, account): self.login(browser, account) for url in urls: browser.visit(url) globalvar.sleep(4, 5) while not globalvar.getElement(browser, 'css', '.btn.btn-download'): browser.visit(url) globalvar.getElement(browser, 'css', '.btn.btn-download').click() globalvar.sleep(10, 20)
def getFilename(self, browser, url): browser.visit(url) globalvar.sleep(2, 4) linkName = globalvar.getElement(browser, 'xpath', '//div[@class="in"]//a').first.text filename = linkName.split('.')[0] return filename
def login(self, browser, account): # Go to the rapidgator homepage url = 'http://katfile.com' browser.visit(url) if browser.is_text_present('Login'): url = 'http://katfile.com/login.html' browser.visit(url) login_field = globalvar.getElement(browser, 'name', 'login') login_field[0].fill(account['username']) password_field = globalvar.getElement(browser, 'name', 'password') password_field[0].fill(account['password']) submit_button = globalvar.getElement(browser, 'name', 'submit') submit_button.first.click()
def getImagesHcapital(self, browser): imgUrls = [] elements = browser.find_by_xpath( '//div[@id="single_image_rows"]//img[@id="img"]') for element in elements: imgUrls.append(element['src']) cover = globalvar.getElement(browser, 'xpath', '//img[@id="cover"]').first imgUrls.append(cover['src']) return imgUrls
def getRapidgatorUrls(self, browser, entry): url = "http://hcapital.tk/?show=edit&id={0}".format(entry) browser.visit(url) rapidUrls = [] rapidValue = globalvar.getElement(browser, 'id', 'rapidlinks').value urls = rapidValue.split('\n') for url in urls: if len(rapidUrls) == 0: rapidUrls.append([]) if url == '': continue rapidUrls[0].append(url) for i in range(1, 9): fieldId = 'other{0}links'.format(i) textfield = globalvar.getElement(browser, 'id', fieldId) textfieldValue = textfield.value urls = textfieldValue.split('\n') if len(urls) > 0 and urls[0] != '': rapidUrls.append([]) for url in urls: if url == '-' or url == '': break rapidUrls[i].append(url) return rapidUrls
def uploadImages(self, browser, images): url = "http://i.want.tf/to/" globalvar.sleep(3, 5) browser.visit(url) button = globalvar.getElement(browser, 'id', 'select-remote') # Interact with elements button.click() globalvar.sleep(3, 5) if browser.is_text_present( 'enter the images URLs you would like to upload', 20): for image in images: globalvar.getElement(browser, 'id', 'url').fill(image) globalvar.sleep(2, 5) button = globalvar.getElement(browser, 'id', 'upload-button') button.click() sleep = (len(images) * 10 + 11) times = 0 while browser.is_text_not_present('Just uploaded '): globalvar.sleep(1) times += 1 if times > sleep: import sys sys.exit() globalvar.sleep(2) if len(images) == 1: url = browser.url splitted = url.split('/') field_name = 'direct-link-{0}'.format(splitted[-1]) textarea = globalvar.getElement(browser, 'id', field_name) else: textarea = globalvar.getElement(browser, 'id', 'direct-links') urls = textarea.value return urls
def createPost(self, browser, post, entryType, account): self.login(browser, account) if entryType == 'ova': urlnr = '36' else: urlnr = '38' url = "http://www.anime-sharing.com/forum/newthread.php?do=newthread&f=" + urlnr browser.visit(url) globalvar.sleep(5, 10) dropdown = globalvar.getElement(browser, 'id', "prefixfield").first dropdown.select('japanese') globalvar.sleep(3, 5) postParts = post.split("?!|]") subject = postParts[1] message = postParts[2] tags = postParts[0] splittedTags = tags.split(',') if len(splittedTags[-1]) > 30: splittedTags[-1] = splittedTags[-1][:30] tags = ', '.join(splittedTags) globalvar.getElement(browser, 'id', 'subject').first.fill(subject) globalvar.sleep(1, 5) textfields = globalvar.getElement(browser, 'css', 'textarea') for textfield in textfields: if textfield['class'] == 'cke_source cke_enable_context_menu': textfield.fill(message) globalvar.getElement(browser, 'id', 'tagpopup_ctrl').first.fill(tags)
def login(self, browser, account): # Go to the rapidgator homepage url = 'https://rapidgator.net' browser.visit(url) # get all links on the page elements = globalvar.getElement(browser, 'tag', 'a') # check if an profile related link excists. If so: The logging in can be stopped for element in elements: if element['innerHTML'].strip(' ') == 'My account': print('Already logged in on to rapidgator.net') return # click on the login link globalvar.getElement(browser, 'xpath', '/html/body/div[1]/div[1]/div[2]/ul/li[1]/a').click() globalvar.sleep(4, 5) # fill the login data with the yuuichi sagara account information login_field = globalvar.getElement(browser, 'id', 'LoginForm_email') if login_field['value'] == '': login_field.fill(account['mail']) else: # if something already has been inserted it is probably account info from a logged in account. # Meaning the logging in can be stopped print('already logged in') return password_field = globalvar.getElement(browser, 'id', 'LoginForm_password') password_field.fill(account['password']) # click the submit link to finalize the login link = globalvar.getElement(browser, 'xpath', '//*[@id="registration"]/ul/li[7]/a[1]') link.click() globalvar.sleep(4, 6)
def upload(self, browser, files, account): #upload all given files to BigFile and return the file urls urls = [] print('files will now be uploaded to BigFile.to') for f in files: while True: self.login(browser, account) url = "https://www.bigfile.to/index.php" browser.visit(url) upload_textfield = browser.driver.find_element_by_id('uploadFiles1') upload_files = browser.driver.find_element_by_id('fakeUploadFiles1') upload_textfield.send_keys(f) upload_files.send_keys(f) globalvar.getElement(browser, 'xpath', '//div[@class="checkbox"]//input').first.click() browser.execute_script("copyFileName();") browser.driver.find_element_by_id('uploadButton').click() globalvar.sleep(10, 20) cont = False uploading = 0 while browser.is_text_not_present('Upload Successful'): globalvar.sleep(10, 20) uploading += 1 print('Uploading...') if uploading == 40: print('upload failed') cont = True break if cont: continue print('Finished uploading') link_field = globalvar.getElement(browser, 'id', 'shareLinks') field_value = link_field.value url = field_value.split('\n') if len(url) > 0 and url[-1] == '': del url[-1] if len(url) > 0 and url[0] != '' and url[0] != 'undefined': urls.append(url[0]) print('uploaded: {0}'.format(urls[-1])) break return urls
def upload(self, browser, files, account): self.login(browser, account) url = 'http://katfile.com/?op=upload' browser.visit(url) for f in files: browser.driver.find_element_by_id('file_0').send_keys(f) globalvar.sleep(10) filename_fields = globalvar.getElement( browser, 'xpath', '//table[@id="files_list"]//font[@class="xfname"]') delete_btns = globalvar.getElement( browser, 'xpath', '//table[@id="files_list"]//img') filenames = [] for i in range(0, len(delete_btns)): filename = filename_fields[i]['innerHTML'] if filename not in filenames: filenames.append(filename) else: delete_btns[i].click() upload_btn = globalvar.getElement( browser, 'xpath', '//*[@id="upload_controls"]/input[1]') upload_btn.click() times = 0 while browser.is_text_not_present('Files Uploaded'): times += 1 globalvar.sleep(10) print('uploading {0}'.format(times)) if times >= 100: active_window = globalvar.get_active_window_title() posX = self.m.position()[0] posY = self.m.position()[1] command = 'wmctrl -a KatFile -' os.system(command) self.k.press_key('Return') self.k.release_key('Return') for i in range(0, 20): self.m.click(500 + (i * 20), 425) self.m.move(posX, posY) if active_window != '': command = 'wmctrl -a {0}'.format(active_window) os.system(command) if account['username'] == 'yuuichi': return 0 elif account['username'] == 'yuuichisagara': return -1 textarea = globalvar.getElement( browser, 'xpath', '//*[@id="container"]/div/div[2]/div/div[1]/textarea') url_text = textarea.value urls = url_text.split('\n') for url in urls: print(url) if urls[-1] == '': del urls[-1] return urls
def main(self, browser, entry): rapidgatorAccount = getAccount.getAccount('rapidgator', 1) bigfileAccount = getAccount.getAccount('bigfile') katfileAccount = getAccount.getAccount('katfile') url = 'http://hcapital.tk/?show=entry&id={0}'.format(entry) browser.visit(url) title = globalvar.getElement(browser, 'id', 'info_title')['innerHTML'] if 'Vol. ' in title: entryType = 'ova' else: entryType = 'game' #get image urls from hcapital imgUrls = hcapital.getImagesHcapital(browser) print('Getting the images succeeded') # get the rapidgator links rapidUrls = hcapital.getRapidgatorUrls(browser, entry) print('Getting the rapidgator urls succeeded') hostingUrls = [] if len(rapidUrls[0]) == 0: hostingUrls.append([]) for i in range(0, len(rapidUrls)): # get the name all the files have to be like go_on = False filename = 'Back to previous page' while filename == 'Back to previous page': if len(rapidUrls) > 0 and len(rapidUrls[i]) > 0: filename = hcapital.getFilename(browser, rapidUrls[i][0]) else: go_on = True break if go_on == True: continue print('The filename of this entry is: "{0}"'.format(filename)) print('Downloading files') rapidgator.download(browser, rapidUrls[i], rapidgatorAccount) downloading = 0 while globalvar.checkDownloadStatus(filename) != len(rapidUrls[i]): globalvar.sleep(200) downloading += 1 if downloading == 20: print('Downloading failed') globalvar.removeFiles(filename) rapidgator.download(browser, rapidUrls[i], rapidgatorAccount) print('downloading...') print('Files downloaded') files = globalvar.getFilesFromFolder(filename) while True: if self.hosting == 'katfile': urls = katfile.upload(browser, files, katfileAccount) if urls == 0: katfile.logout(browser) katfileAccount = getAccount.getAccount('katfile2') continue elif urls == -1: self.hosting = 'bigfile' continue else: hostingUrls.append(urls) else: hostingUrls.append( bigfile.upload(browser, files, bigfileAccount)) if len(hostingUrls[i]) != len(rapidUrls[i]): print( 'Uploaded file amount doesn\'t match with the expected amount' ) print('bigfile: {0} files, Rapidgator: {1} files'.format( len(hostingUrls[i]), len(rapidUrls[i]))) del hostingUrls[-1] else: break print('removing files from download folder') globalvar.removeFiles(filename) print('Uploading images so they can be used for the post') images = animeSharing.uploadImages(browser, imgUrls) print('Getting the post data') post = hcapital.editEntryAndGetPost(browser, entry, entryType, images, hostingUrls, rapidUrls) globalvar.sleep(3, 5) print('Creating the post on anime-sharing') animeSharing.createPost(browser, post, entryType, animeSharingAccount) return 0