Example #1
0
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)
Example #2
0
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)
Example #3
0
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)