Exemplo n.º 1
0
def export_aria2_conf(args):
    client = XunleiClient(args.username, args.password, args.cookies)
    import lixian_tasks

    tasks = lixian_tasks.search_tasks(client, args, status=(args.completed and "completed" or "all"))
    files = []
    for task in tasks:
        if task["type"] == "bt":
            subs, skipped, single_file = lixian_tasks.expand_bt_sub_tasks(client, task)
            if not subs:
                continue
            if single_file:
                files.append((subs[0]["xunlei_url"], subs[0]["name"], None))
            else:
                for f in subs:
                    import os.path

                    files.append((f["xunlei_url"], f["name"], task["name"]))
        else:
            files.append((task["xunlei_url"], task["name"], None))
    output = ""
    for url, name, dir in files:
        if type(url) == unicode:
            url = url.encode(default_encoding)
        output += url + "\n"
        output += "  out=" + name.encode(default_encoding) + "\n"
        if dir:
            output += "  dir=" + dir.encode(default_encoding) + "\n"
        output += "  header=Cookie: gdriveid=" + client.get_gdriveid() + "\n"
    return output
Exemplo n.º 2
0
def export_aria2_conf(args):
	client = XunleiClient(args.username, args.password, args.cookies)
	import lixian_tasks
	tasks = lixian_tasks.search_tasks(client, args, status=(args.completed and 'completed' or 'all'))
	files = []
	for task in tasks:
		if task['type'] == 'bt':
			subs, skipped, single_file = lixian_tasks.expand_bt_sub_tasks(client, task)
			if not subs:
				continue
			if single_file:
				files.append((subs[0]['xunlei_url'], subs[0]['name'], None))
			else:
				for f in subs:
					import os.path
					files.append((f['xunlei_url'], f['name'], task['name']))
		else:
			files.append((task['xunlei_url'], task['name'], None))
	output = ''
	for url, name, dir in files:
		if type(url) == unicode:
			url = url.encode(default_encoding)
		output += url + '\n'
		output += '  out=' + name.encode(default_encoding) + '\n'
		if dir:
			output += '  dir=' + dir.encode(default_encoding) + '\n'
		output += '  header=Cookie: gdriveid=' + client.get_gdriveid() + '\n'
	return output
Exemplo n.º 3
0
def export_aria2(args):
	import lixian_cli
	args = lixian_cli.parse_login_command_line(args)
	from lixian import XunleiClient
	client = XunleiClient(args.username, args.password, args.cookies)
	import lixian_tasks
	tasks = lixian_tasks.search_tasks(client, args, status=(args.completed and 'completed' or 'all'))
	files = []
	for task in tasks:
		if task['type'] == 'bt':
			subs, skipped, single_file = lixian_tasks.expand_bt_sub_tasks(client, task)
			if not subs:
				continue
			if single_file:
				files.append((subs[0]['xunlei_url'], subs[0]['name'], None))
			else:
				for f in subs:
					import os.path
					files.append((f['xunlei_url'], f['name'], task['name']))
		else:
			files.append((task['xunlei_url'], task['name'], None))
	for url, name, dir in files:
		print url
		from lixian_encoding import default_encoding
		print '  out=' + name.encode(default_encoding)
		if dir:
			print '  dir=' + dir.encode(default_encoding)
		print '  header=Cookie: gdriveid=' + client.get_gdriveid()
def export_aria2_conf(args):
    client = XunleiClient(args.username, args.password, args.cookies)
    import lixian_tasks
    tasks = lixian_tasks.search_tasks(client,
                                      args,
                                      status=(args.completed and 'completed'
                                              or 'all'))
    files = []
    for task in tasks:
        if task['type'] == 'bt':
            subs, skipped, single_file = lixian_tasks.expand_bt_sub_tasks(
                client, task)
            if not subs:
                continue
            if single_file:
                files.append((subs[0]['xunlei_url'], subs[0]['name'], None))
            else:
                for f in subs:
                    import os.path
                    files.append((f['xunlei_url'], f['name'], task['name']))
        else:
            files.append((task['xunlei_url'], task['name'], None))
    output = ''
    for url, name, dir in files:
        if type(url) == unicode:
            url = url.encode(default_encoding)
        output += url + '\n'
        output += '  out=' + name.encode(default_encoding) + '\n'
        if dir:
            output += '  dir=' + dir.encode(default_encoding) + '\n'
        output += '  header=Cookie: gdriveid=' + client.get_gdriveid() + '\n'
    return output
Exemplo n.º 5
0
def lixian_info(args):
    client = XunleiClient(args.username, args.password, args.cookies, login=False)
    if args.id:
        print client.get_username()
    else:
        print 'id:', client.get_username()
        print 'internalid:', client.get_userid()
        print 'gdriveid:', client.get_gdriveid() or ''
Exemplo n.º 6
0
def lixian_info(args):
	client = XunleiClient(args.username, args.password, args.cookies, login=False)
	if args.id:
		print client.get_username()
	else:
		print 'id:', client.get_username()
		print 'internalid:', client.get_userid()
		print 'gdriveid:', client.get_gdriveid() or ''
Exemplo n.º 7
0
def lixian_info(args):
    args = parse_login_command_line(args, help=lixian_help.info)
    client = XunleiClient(args.username,
                          args.password,
                          args.cookies,
                          login=False)
    print 'id:', client.get_username()
    print 'internalid:', client.get_userid()
    print 'gdriveid:', client.get_gdriveid() or ''
Exemplo n.º 8
0
def lixian_info(args):
	args = parse_login_command_line(args, [], ['id'], alias={'i':'id'}, help=lixian_help.info)
	client = XunleiClient(args.username, args.password, args.cookies, login=False)
	if args.id:
		print client.get_username()
	else:
		print 'id:', client.get_username()
		print 'internalid:', client.get_userid()
		print 'gdriveid:', client.get_gdriveid() or ''
Exemplo n.º 9
0
def execute_args(args):
	download = {'wget':wget_download, 'urllib2':urllib2_download}[args.tool]

	if args.links:
		assert len(args.links) == 1
		url = args.links[0]
	else:
		url = args.link
	assert url or args.task_id or args.task_name

	client = XunleiClient(args.username, args.password, args.cookies)
	client.set_page_size(100)
	tasks = client.read_all_completed()
	if url:
		matched = filter(lambda t: t['original_url'] == url, tasks)
		if matched:
			task = matched[0]
		else:
			# if the task doesn't exist yet, add it
			# TODO: check space, check queue, delete after download done, add loggings
			client.add_task(url)
			tasks = client.read_all_completed()
			task = filter(lambda t: t['original_url'] == url, tasks)[0]
	elif args.task_name:
		task = filter(lambda t: t['name'].find(args.task_name) != -1, tasks)[0]
	elif args.task_id:
		task = filter(lambda t: t['id'] == args.task_id, tasks)[0]
	else:
		raise NotImplementedError()

	download_url = str(task['xunlei_url'])
	filename = args.output or task['name'].encode(sys.getfilesystemencoding())
	referer = str(client.get_referer())
	gdriveid = str(client.get_gdriveid())

	download(client, download_url, filename)
Exemplo n.º 10
0
def lixian_info(args):
    args = parse_login_command_line(args, help=lixian_help.info)
    client = XunleiClient(args.username, args.password, args.cookies, login=False)
    print "id:", client.get_username()
    print "internalid:", client.get_userid()
    print "gdriveid:", client.get_gdriveid() or ""
Exemplo n.º 11
0
def lixian_info(args):
	args = parse_login_command_line(args)
	client = XunleiClient(args.username, args.password, args.cookies, login=False)
	print 'id:', client.get_username()
	print 'internalid:', client.get_userid()
	print 'gdriveid:', client.get_gdriveid()