├── .replit ├── 2023-03-18172219.png ├── README.md ├── fix.sh ├── install.sh ├── main.py ├── ppmmiNj.jpg └── replit.nix /.replit: -------------------------------------------------------------------------------- 1 | # The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing 2 | run = "python3 main.py" 3 | 4 | # The primary language of the repl. There can be others, though! 5 | language = "python3" 6 | entrypoint = "main.py" 7 | # A list of globs that specify which files and directories should 8 | # be hidden in the workspace. 9 | hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"] 10 | 11 | # Specifies which nix channel to use when building the environment. 12 | [nix] 13 | channel = "stable-21_11" 14 | 15 | # The command to start the interpreter. 16 | [interpreter] 17 | [interpreter.command] 18 | args = [ 19 | "stderred", 20 | "--", 21 | "prybar-python3", 22 | "-q", 23 | "--ps1", 24 | "\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ", 25 | "-i", 26 | ] 27 | env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" } 28 | 29 | [env] 30 | VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv" 31 | PATH = "${VIRTUAL_ENV}/bin" 32 | PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.8/site-packages" 33 | REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/" 34 | MPLBACKEND = "TkAgg" 35 | POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry" 36 | 37 | # Enable unit tests. This is only supported for a few languages. 38 | [unitTest] 39 | language = "python3" 40 | 41 | # Add a debugger! 42 | [debugger] 43 | support = true 44 | 45 | # How to start the debugger. 46 | [debugger.interactive] 47 | transport = "localhost:0" 48 | startCommand = ["dap-python", "main.py"] 49 | 50 | # How to communicate with the debugger. 51 | [debugger.interactive.integratedAdapter] 52 | dapTcpAddress = "localhost:0" 53 | 54 | # How to tell the debugger to start a debugging session. 55 | [debugger.interactive.initializeMessage] 56 | command = "initialize" 57 | type = "request" 58 | 59 | [debugger.interactive.initializeMessage.arguments] 60 | adapterID = "debugpy" 61 | clientID = "replit" 62 | clientName = "replit.com" 63 | columnsStartAt1 = true 64 | linesStartAt1 = true 65 | locale = "en-us" 66 | pathFormat = "path" 67 | supportsInvalidatedEvent = true 68 | supportsProgressReporting = true 69 | supportsRunInTerminalRequest = true 70 | supportsVariablePaging = true 71 | supportsVariableType = true 72 | 73 | # How to tell the debugger to start the debuggee application. 74 | [debugger.interactive.launchMessage] 75 | command = "attach" 76 | type = "request" 77 | 78 | [debugger.interactive.launchMessage.arguments] 79 | logging = {} 80 | 81 | # Configures the packager. 82 | [packager] 83 | language = "python3" 84 | ignoredPackages = ["unit_tests"] 85 | 86 | [packager.features] 87 | enabledForHosting = false 88 | # Enable searching packages from the sidebar. 89 | packageSearch = true 90 | # Enable guessing what packages are needed from the code. 91 | guessImports = true 92 | 93 | # These are the files that need to be preserved when this 94 | # language template is used as the base language template 95 | # for Python repos imported from GitHub 96 | [gitHubImport] 97 | requiredFiles = [".replit", "replit.nix", ".config", "venv"] 98 | 99 | [languages] 100 | 101 | [languages.python3] 102 | pattern = "**/*.py" 103 | 104 | [languages.python3.languageServer] 105 | start = "pylsp" 106 | -------------------------------------------------------------------------------- /2023-03-18172219.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sxbai/drpy-on-replit/caef0c7076064f02b364dbf58e627cc9383d8bc0/2023-03-18172219.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | drpy logo 4 | 5 |

6 | 7 |

Drpy部署于Replit,️一个Web服务器将Web和x5电影网站转换为CMS API数据。作者:道长&蓝莓

8 | 9 |

10 | GitHub release 11 | GitHub last commit 12 | 13 |
14 | 博客 15 | 文档 16 | QQ群 17 | Telegram 频道 18 |

19 | 20 | ------------------------------ 21 | # 使用说明 22 | 欢迎Fork本项目,drpy-on-replit 23 | 24 | - 环境选择 `Python Flask ReplAuth` 25 | ![](https://raw.iqiq.io/sxbai/drpy-on-replit/master/2023-03-18172219.png) 26 | - 一键搭建脚本 27 | ``` 28 | bash <(curl -s https://raw.githubusercontent.com/sxbai/drpy-on-replit/master/install.sh) 29 | ``` 30 | -------------------------------------------------------------------------------- /fix.sh: -------------------------------------------------------------------------------- 1 | echo "drpy修复脚本" 2 | echo "脚本作者:舒夏" 3 | echo "GitHub开源地址:https://github.com/sxbai/drpy-on-replit" 4 | pip install flask_migrate 5 | pip install flask==2.2.2 6 | pip install flask-sqlalchemy==2.5.1 7 | pip install SQLAlchemy==1.4.41 8 | echo "恭喜修复drpy完成" 9 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | echo "drpy一键搭建脚本" 2 | echo "脚本作者:舒夏" 3 | echo "GitHub开源地址:https://github.com/sxbai/drpy-on-replit" 4 | rm -rf public/ && rm -rf templates/ 5 | nix-env -iA nixpkgs.wget 6 | mkdir build 7 | cd build 8 | wget -O .replit https://github.com/sxbai/drpy-on-replit/raw/master/.replit 9 | wget -O replit.nix https://github.com/sxbai/drpy-on-replit/raw/master/replit.nix 10 | cd .. 11 | wget -O main.py https://github.com/sxbai/drpy-on-replit/raw/master/main.py 12 | wget https://github.com/sxbai/drpy-on-replit/raw/master/fix.sh 13 | wget https://github.com/hjdhnx/dr_py/archive/refs/heads/main.zip 14 | nix-env -iA nixpkgs.unzip 15 | unzip main.zip && mv dr_py-main/* . 16 | cp -r build/.replit . && cp -r build/replit.nix . 17 | pip install -r requirements.txt 18 | echo "恭喜搭建完成" 19 | echo "点击Run立即运行项目" 20 | rm -rf dr_py-main/ && rm -rf build/ 21 | rm -rf main.zip && rm -rf README.md 22 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : app.py 4 | # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ 5 | # Date : 2022/9/6 6 | 7 | from flask.app import Flask 8 | from flask_migrate import Migrate 9 | from base import config 10 | from base.database import db 11 | from utils.log import logger 12 | from utils.system import get_wlan_info, getHost 13 | from controllers import * 14 | from js.rules import getRuleLists 15 | import sys 16 | 17 | 18 | def create_flask_app(): 19 | app = Flask(__name__, static_folder='static', static_url_path='/static') 20 | app.config.from_object(config) # 单独的配置文件里写了,这里就不用弄json中文显示了 21 | app.register_blueprint(home.home, url_prefix='') 22 | app.register_blueprint(admin.admin, url_prefix='/admin') 23 | app.register_blueprint(vod.vod, url_prefix='') 24 | app.register_blueprint(cls.cls, url_prefix='/cls') 25 | app.register_blueprint(layui.layui, url_prefix='/layui') 26 | app.register_blueprint(parse.parse, url_prefix='/parse') 27 | # app.register_blueprint(web.web, url_prefix='/web',template_folder='templates/cmsV10/mxpro/html/index/') 28 | app.register_blueprint(web.web, url_prefix='/web') 29 | app.logger.name = "drLogger" 30 | # lsg = service.storage_service() 31 | logger.info(f"默认解析地址:{app.config.get('PLAY_URL')}") 32 | # logger.info(f"自定义播放解析地址:{lsg.getItem('PLAY_URL')}") 33 | logger.info(f'当前操作系统{sys.platform}') 34 | rule_list = getRuleLists() 35 | wlan_info, _ = get_wlan_info() 36 | logger.info(rule_list) 37 | logger.info( 38 | f'局域网: {getHost(1, app.config.get("HTTP_PORT"))}/index\n本地: {getHost(0, app.config.get("HTTP_PORT"))}/index\nwlan_info:{wlan_info}') 39 | db.init_app(app) 40 | db.app = app 41 | db.create_all(app=app) 42 | return app 43 | 44 | 45 | app = create_flask_app() 46 | migrate = Migrate(app, db) 47 | max_version = (3, 11) # 小于3.11的版本(3.6-3.10) 48 | max_version_str = ".".join([str(i) for i in max_version]) 49 | now_python_ver = ".".join([str(i) for i in sys.version_info[:3]]) 50 | no_error = True 51 | if sys.version_info < max_version: 52 | try: 53 | from gevent.pywsgi import WSGIServer 54 | 55 | # from gevent import monkey 56 | # monkey.patch_all() # 多线程,只能放在最开头,import其它包之前 57 | 58 | from gevent import monkey 59 | 60 | monkey.patch_socket() # 开启socket异步 61 | print(f'当前python版本{now_python_ver}为{max_version_str}及以下,支持gevent') 62 | 63 | except Exception as e: 64 | print(f'gevent使用过程中发生了错误:{e}') 65 | no_error = False 66 | else: 67 | print(f'当前python版本{now_python_ver}为{max_version_str}及以上,不支持gevent') 68 | 69 | if __name__ == "__main__": 70 | http_port = int(app.config.get('HTTP_PORT', 5705)) 71 | http_host = app.config.get('HTTP_HOST', '0.0.0.0') 72 | threaded = app.config.get('THREAD') 73 | GEVENT = app.config.get('GEVENT') 74 | print(GEVENT) 75 | if threaded is None: 76 | threaded = True 77 | if GEVENT is None: 78 | debug = False 79 | # https://www.zhihu.com/question/64096559 80 | print(f'threaded:{threaded},GEVENT:{GEVENT}') 81 | # if sys.version_info < (3, 9) and not sys.platform.startswith('win'): 82 | use_gevent = sys.version_info < max_version # 是否使用协程 83 | is_debug = (not GEVENT) and sys.platform.startswith('win') # windows开调试模式 84 | print(f'开启调试模式:{is_debug}') 85 | if use_gevent and no_error and not is_debug: 86 | # server = WSGIServer(('0.0.0.0', 5705), app, handler_class=WebSocketHandler,log=app.logger) 87 | # server = WSGIServer(('0.0.0.0', 5705), app, handler_class=WebSocketHandler,log=None) 88 | server = WSGIServer((http_host, http_port), app, log=logger) 89 | server.serve_forever() 90 | else: 91 | app.run(debug=False, host=http_host, port=http_port, threaded=threaded) 92 | -------------------------------------------------------------------------------- /ppmmiNj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sxbai/drpy-on-replit/caef0c7076064f02b364dbf58e627cc9383d8bc0/ppmmiNj.jpg -------------------------------------------------------------------------------- /replit.nix: -------------------------------------------------------------------------------- 1 | { pkgs }: { 2 | deps = [ 3 | pkgs.wget 4 | pkgs.unzip 5 | pkgs.zip 6 | pkgs.python38Full 7 | ]; 8 | env = { 9 | PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ 10 | # Needed for pandas / numpy 11 | pkgs.stdenv.cc.cc.lib 12 | pkgs.zlib 13 | # Needed for pygame 14 | pkgs.glib 15 | # Needed for matplotlib 16 | pkgs.xorg.libX11 17 | ]; 18 | PYTHONBIN = "${pkgs.python38Full}/bin/python3.8"; 19 | LANG = "en_US.UTF-8"; 20 | }; 21 | } --------------------------------------------------------------------------------