def __init__(self): self.post_params = urllib.urlencode({ 'login_username': environment.get('rutracker_login'), 'login_password': base64.b64decode(environment.get('rutracker_password_base64')), 'login': '******' }) self.cookie = self.__set_cookies__() self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookie)) urllib2.install_opener(self.opener) self.authorized = False
def download_torrent(self, name, topic_id, to_rewrite): filename = filter(lambda x: x.isalpha() or x.isdigit(), name) filename_path = environment.get('downloaded_torrents_location') + filename + '.torrent' if (not os.path.exists(filename_path)) or to_rewrite: try: self.__authorise__() except: raise CannotAuthorize("RuTracker.org") with open(filename_path, 'wb') as torrent_file: print 'Downloading ' + filename_path web_file = self.opener.open('http://dl.rutracker.org/forum/dl.php?' + topic_id, self.post_params) torrent_file.write(web_file.read()) torrent_file.close() print 'Downloaded' else: raise AlreadyDownloaded(filename_path) return filename_path
def set_up_dropbox(): dbx = dropbox.Dropbox(environment.get('dropbox_OAuth2_key')) dbx.users_get_current_account() return dbx
def run_qbittorrent(torrent_files_list): command_string = environment.get('qBittorrent_location') + ' --daemon --webui-port=8081 ' command_string += " ".join(torrent_files_list) return subprocess.Popen(shlex.split(command_string))