videoanywhere / playwithmpv

A server to support playing videos with mpv.
MIT License
41 stars 2 forks source link

传递给MPV的参数没有使用“ ”包围导致MPV报错 #4

Closed Ai-desu-2333 closed 2 years ago

Ai-desu-2333 commented 2 years ago

在windows下首次使用时出现了与 #3 相同的问题, 按照原issue提供的方法将\site-packages\playwithmpv\server.py中的os.environ['HOME']更改为os.environ['USERPROFILE']之后发现MPV提示路径错误,查看输出后发现程序传递给MPV的--playlist参数没有使用 " "包围,而我的系统用户名中带有空格,便发生了问题。

超菜的解决方法:将\site-packages\playwithmpv\server.py中的 mpv_cmd = ' '.join([args['dir'], mpv_httpd_header, '--playlist=' + playlist_file ]) 修改为 mpv_cmd = ' '.join([args['dir'], mpv_httpd_header, '--playlist=' + '"' + playlist_file + '"' ]) (其实也可以把USERPROFILE修改为其他不包含空格路径的变量)

以下为关键输出内容:(用户名使用"A B"代替)

C:\Users\A B>"C:\Users\A B\AppData\Roaming\Python\Python38\Scripts\playwithmpv.exe"
 * Serving Flask app 'playwithmpv.server' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:50000/ (Press CTRL+C to quit)
127.0.0.1 - - [15/Mar/2022 02:29:33] "OPTIONS / HTTP/1.1" 200 -
mpv --http-header-fields="referer:https://www.bilibili.com/","user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0" --playlist=C:\Users\A B\_tmp_playlist.m3u
video_title.flv
[file] Cannot open file 'C:\Users\A': No such file or directory
Failed to open C:\Users\A.
Error reading playlist 'C:\Users\A'
Exiting... (Fatal error)
curlfoxs commented 2 years ago

commit https://github.com/videoanywhere/playwithmpv/commit/34dca5ee55ee2bac3e217949ade733705d2d7a67 已修复