Created
March 8, 2019 01:57
-
-
Save AdrienHorgnies/c4572f365480b0e7a39fc32ac977e100 to your computer and use it in GitHub Desktop.
find magnets and add them to transmission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from selenium import webdriver | |
import time | |
from subprocess import run | |
def get_magnets(url): | |
browser = webdriver.Chrome() | |
browser.get(url) | |
display_all_items(browser) | |
return [node.get_attribute('href') for node in | |
browser.find_elements_by_xpath('.//div[contains(@class, "link-720p")]//a[@title="Magnet Link"]')] | |
def display_all_items(browser): | |
while len(browser.find_elements_by_xpath('.//*[@id="01"]')) == 0: | |
more_button = browser.find_element_by_class_name('more-button') | |
more_button.click() | |
time.sleep(1) | |
def dl_items(magnets): | |
run(['transmission-daemon']) | |
for magnet in magnets: | |
run(['transmission-remote', '-a', magnet]) | |
def main(): | |
parser = argparse.ArgumentParser(description='Find magnet links and add them to transmission') | |
parser.add_argument('url') | |
args = parser.parse_args() | |
magnets = get_magnets(args.url) | |
dl_items(magnets) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment