def add_task(args): args = parse_login_command_line(args, ['input'], ['torrent'], alias={'i': 'input'}, help=lixian_help.add) assert len(args) or args.input client = XunleiClient(args.username, args.password, args.cookies) links = [] links.extend(args) if args.input: with open(args.input) as x: links.extend(line.strip() for line in x.readlines() if line.strip()) if not args.torrent: print 'Adding below tasks:' for link in links: print link client.add_batch_tasks(links) print 'All tasks added. Checking status...' tasks = client.read_all_tasks() for link in links: found = filter_tasks(tasks, 'original_url', link) if found: print found[0]['status_text'], link else: print 'unknown', link else: tasks = find_torrents_task_to_download(client, links) assert len(tasks) == len(links) print 'All tasks added:' for link, task in zip(links, tasks): print task['status_text'], link
def add_task(args): args = parse_login_command_line(args, ['input'], ['torrent'], alias={'i':'input'}, help=lixian_help.add) assert len(args) or args.input client = XunleiClient(args.username, args.password, args.cookies) links = [] links.extend(args) if args.input: with open(args.input) as x: links.extend(line.strip() for line in x.readlines() if line.strip()) if not args.torrent: print 'Adding below tasks:' for link in links: print link client.add_batch_tasks(map(to_utf_8, links)) for link in links: # add_batch_tasks doesn't work for bt task, add bt task one by one... if link.startswith('bt://') or link.startswith('magnet:'): client.add_task(link) print 'All tasks added. Checking status...' tasks = client.read_all_tasks() for link in links: found = filter_tasks(tasks, 'original_url', to_utf_8(link)) if found: print found[0]['id'], found[0]['status_text'], link else: print 'unknown', link else: tasks = find_torrents_task_to_download(client, links) assert len(tasks) == len(links) print 'All tasks added:' for link, task in zip(links, tasks): print task['id'], task['status_text'], link
def readd_task(args): if args.deleted: status = 'deleted' elif args.expired: status = 'expired' else: raise NotImplementedError('Please use --expired or --deleted') client = XunleiClient(args.username, args.password, args.cookies) if status == 'expired' and args.all: return client.readd_all_expired_tasks() to_readd = lixian_query.search_tasks(client, args) non_bt = [] bt = [] if not to_readd: return print "Below files are going to be re-added:" for x in to_readd: print x['name'].encode(default_encoding) if x['type'] == 'bt': bt.append((x['bt_hash'], x['id'])) else: non_bt.append((x['original_url'], x['id'])) if non_bt: urls, ids = zip(*non_bt) client.add_batch_tasks(urls, ids) for hash, id in bt: client.add_torrent_task_by_info_hash2(hash, id)
def readd_task(args): args = parse_login_command_line(args, [], ['deleted', 'expired'], help=lixian_help.readd) client = XunleiClient(args.username, args.password, args.cookies) if args.deleted: status = 'deleted' elif args.expired: status = 'expired' else: raise NotImplementedError('Please use --expired or --deleted') to_readd = search_tasks(client, args, status=status) non_bt = [] bt = [] if not to_readd: return print "Below files are going to be re-added:" for x in to_readd: print x['name'].encode(default_encoding) if x['type'] == 'bt': bt.append((x['bt_hash'], x['id'])) else: non_bt.append((x['original_url'], x['id'])) if non_bt: urls, ids = zip(*non_bt) client.add_batch_tasks(urls, ids) for hash, id in bt: client.add_torrent_task_by_info_hash2(hash, id)
def readd_task(args): if args.deleted: status = "deleted" elif args.expired: status = "expired" else: raise NotImplementedError("Please use --expired or --deleted") client = XunleiClient(args.username, args.password, args.cookies) if status == "expired" and args.all: return client.readd_all_expired_tasks() to_readd = search_tasks(client, args, status=status) non_bt = [] bt = [] if not to_readd: return print "Below files are going to be re-added:" for x in to_readd: print x["name"].encode(default_encoding) if x["type"] == "bt": bt.append((x["bt_hash"], x["id"])) else: non_bt.append((x["original_url"], x["id"])) if non_bt: urls, ids = zip(*non_bt) client.add_batch_tasks(urls, ids) for hash, id in bt: client.add_torrent_task_by_info_hash2(hash, id)
def add_task(args): args = parse_login_command_line(args, ['input'], ['torrent'], alias={'i':'input'}) assert len(args) or args.input client = XunleiClient(args.username, args.password, args.cookies) links = [] links.extend(args) if args.input: with open(args.input) as x: links.extend(line.strip() for line in x.readlines() if line.strip()) if not args.torrent: print 'Adding below tasks:' for link in links: print link client.add_batch_tasks(links) print 'All tasks added. Checking status...' tasks = client.read_all_tasks() for link in links: found = filter_tasks(tasks, 'original_url', link) if found: print found[0]['status_text'], link else: print 'unknown', link else: tasks = find_torrents_task_to_download(client, links) assert len(tasks) == len(links) print 'All tasks added:' for link, task in zip(links, tasks): print task['status_text'], link
def add_task(args): args = parse_login_command_line( args, ["input"], ["torrent"], alias={"i": "input", "bt": "torrent"}, help=lixian_help.add ) assert len(args) or args.input client = XunleiClient(args.username, args.password, args.cookies) links = [] links.extend(args) if args.input: with open(args.input) as x: links.extend(line.strip() for line in x.readlines() if line.strip()) if not args.torrent: print "Adding below tasks:" for link in links: print link client.add_batch_tasks(map(to_utf_8, links)) for link in links: # add_batch_tasks doesn't work for bt task, add bt task one by one... if link.startswith("bt://") or link.startswith("magnet:"): client.add_task(link) print "All tasks added. Checking status..." tasks = client.read_all_tasks() for link in links: found = filter_tasks(tasks, "original_url", to_utf_8(link)) if found: print found[0]["id"], found[0]["status_text"], link else: print "unknown", link else: tasks = find_torrents_task_to_download(client, links) assert len(tasks) == len(links) print "All tasks added:" for link, task in zip(links, tasks): print task["id"], task["status_text"], link