├── .gitignore ├── LICENSE.md ├── README.md ├── setup.cfg ├── setup.py └── xunleishare ├── __init__.py ├── __main__.py └── xunleishare.py /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | dist/ 3 | xunleishare.egg-info/ 4 | *.pyc 5 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2015 GitHub Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Xunlei Share 2 | 3 | [![PyPI version](https://badge.fury.io/py/xunleishare.svg)](https://badge.fury.io/py/xunleishare) 4 | [![Code Health](https://landscape.io/github/Chion82/xunlei_share/master/landscape.svg?style=flat)](https://landscape.io/github/Chion82/xunlei_share/master) 5 | ![python](https://img.shields.io/badge/python-2.7-green.svg) 6 | ![license](https://img.shields.io/badge/license-MIT-brightgreen.svg) 7 | 8 | XunleiShare is a command-line interface tool to directly get download links on Xunlei Lixian servers with the help from the maintainer's Xunlei VIP account. You don't have to acquire a Xunlei VIP account. 9 | 10 | Backend server : https://github.com/Chion82/ThunderHack.git 11 | 12 | XunleiShare是一个CLI下的迅雷离线下载地址获取工具,可将原下载链接直接转换为迅雷离线地址并输出为Aria2下载命令。 本工具基于分享原则,由维护者提供大容量会员离线空间,因此你无需购买迅雷会员。 13 | 14 | ##Installation 15 | 16 | ``` 17 | $ sudo pip install xunleishare 18 | ``` 19 | 20 | ##Usage 21 | 22 | ``` 23 | $ xunleishare "DOWNLOAD_LINK" 24 | ``` 25 | Then execute the generated ```xunlei_output``` shell. 26 | 27 | or 28 | 29 | ``` 30 | $ xunleishare "DOWNLOAD_LINK" -o "OUTPUT_SHELL_FILE" 31 | ``` 32 | 33 | Add switch ```-a``` if you want to download all files simultaneously. 34 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | setup( 3 | name = 'xunleishare', 4 | packages = ['xunleishare'], 5 | entry_points={ 6 | 'console_scripts': [ 7 | 'xunleishare = xunleishare.xunleishare:main', 8 | ], 9 | }, 10 | install_requires=['requests' ,'six', 'Pillow'], 11 | version = '0.1.4', 12 | description = 'Based on the idea of sharing, XunleiShare is a command-line interface tool to directly get download links on Xunlei Lixian servers with the help of the maintainer\'s Xunlei VIP account. You do not have to acquire a VIP.', 13 | author = 'Chion82', 14 | license='MIT', 15 | author_email = 'sdspeedonion@gmail.com', 16 | url = 'https://github.com/Chion82/xunlei_share', 17 | keywords = ['xunlei', 'xunleishare', 'thunder'], 18 | classifiers = [ 19 | 'Development Status :: 3 - Alpha', 20 | 'Programming Language :: Python :: 2', 21 | 'Programming Language :: Python :: 2.6', 22 | 'Programming Language :: Python :: 2.7', 23 | ] 24 | ) 25 | -------------------------------------------------------------------------------- /xunleishare/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chion82/xunlei_share/5e528936ede4a1ea77e54365373ec7f6383a5df0/xunleishare/__init__.py -------------------------------------------------------------------------------- /xunleishare/__main__.py: -------------------------------------------------------------------------------- 1 | from .xunleishare import main 2 | 3 | if __name__ == '__main__': 4 | main() 5 | -------------------------------------------------------------------------------- /xunleishare/xunleishare.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | import requests, argparse, os 4 | from PIL import Image 5 | 6 | class XunleiShare(object): 7 | 8 | def __init__(self): 9 | self.get_host() 10 | 11 | def get_host(self): 12 | request_result = requests.get('https://raw.githubusercontent.com/Chion82/Chion82.github.io/master/server_host') 13 | self.__host = request_result.text.replace('\n','') 14 | 15 | def get_verify_code(self): 16 | request_result = requests.get(self.__host + '/api/verify_code') 17 | self.__verify_key = request_result.headers.get('Verify-Key') 18 | with open('verify_code.jpg', 'wb+') as file: 19 | file.write(request_result.content) 20 | img = Image.open('verify_code.jpg') 21 | img.show() 22 | 23 | def get_gdrive_id(self): 24 | request_json = requests.get(self.__host + '/api/gdriveid').json() 25 | self.__gdrive_id = request_json['gdriveid'] 26 | return self.__gdrive_id 27 | 28 | def commit_magnet_task(self, magnet_link, verify_code): 29 | request_json = requests.post(self.__host + '/api/commit_magnet.do', data={'magnet_link':magnet_link, 'verify_code': verify_code, 'verify_key': self.__verify_key}).json() 30 | return request_json 31 | 32 | def commit_normal_task(self, download_link, verify_code): 33 | request_json = requests.post(self.__host + '/api/commit_normal_task.do', data={'link':download_link, 'verify_code': verify_code, 'verify_key': self.__verify_key}).json() 34 | return request_json 35 | 36 | def query_task(self, task_id): 37 | request_json = requests.get(self.__host + '/api/task/' + task_id).json() 38 | return request_json 39 | 40 | 41 | def main(): 42 | parser = argparse.ArgumentParser() 43 | parser.add_argument('link', type=str, help='The download link') 44 | parser.add_argument('-o', '--output', help='The output shell script which contains the Aria2 download commands') 45 | parser.add_argument('-a', '--async', action='store_true', help='Download in asynchronous mode. If specified, each generated aria2c command is followed by an "&"') 46 | args = parser.parse_args() 47 | 48 | xunlei = XunleiShare() 49 | gdrive_id = xunlei.get_gdrive_id() 50 | 51 | xunlei.get_verify_code() 52 | 53 | print('输入验证码:') 54 | print('Please enter verify code:') 55 | verify_code = raw_input() 56 | os.remove('verify_code.jpg') 57 | 58 | if (args.link.find('magnet:?') != -1): 59 | commit_result_json = xunlei.commit_magnet_task(args.link, verify_code) 60 | else: 61 | commit_result_json = xunlei.commit_normal_task(args.link, verify_code) 62 | 63 | if (commit_result_json['status'] != 'OK'): 64 | print('提交任务失败,请重试') 65 | print('Failed to commit download task. Please retry.') 66 | if 'error' in commit_result_json: 67 | if 'msg' in commit_result_json['error']: 68 | print('ERR_MSG=%s' % commit_result_json['error']['msg']) 69 | else: 70 | print('ERR_MSG=%s' % commit_result_json['error']) 71 | exit() 72 | 73 | task_query_result_json = xunlei.query_task(commit_result_json['task_id']) 74 | 75 | if (task_query_result_json['status'] == 'Task Not Finished'): 76 | print('任务未完成,进度:' + str(task_query_result_json['progress'])) 77 | print('Download task unfinished. Progress: ' + str(task_query_result_json['progress'])) 78 | exit() 79 | 80 | if (task_query_result_json['status'] != 'OK'): 81 | print('未知错误') 82 | print('Unknown error.') 83 | exit() 84 | 85 | commands = '#!/bin/sh\n' 86 | for file_info in task_query_result_json['records']: 87 | commands = commands + ('aria2c -c -s10 -x10 --header "Cookie: gdriveid=%s;" -o "%s" "%s" %s\n' % (gdrive_id, file_info['title'], file_info['downurl'], '&' if args.async else '')) 88 | 89 | if (args.output): 90 | output_file = args.output 91 | else: 92 | output_file = 'xunlei_output' 93 | 94 | import six 95 | f = open(output_file, 'w+') 96 | if six.PY3: 97 | f.write(commands) 98 | else: 99 | f.write(commands.encode('utf8')) 100 | f.close() 101 | 102 | import subprocess 103 | subprocess.call(['chmod', '755', output_file]) 104 | 105 | print('Aria2命令已输出至 %s ' % output_file) 106 | print('Aria2 commands are generated into %s ' % output_file) 107 | --------------------------------------------------------------------------------