Code Monkey home page Code Monkey logo

Comments (11)

open-dynaMIX avatar open-dynaMIX commented on August 27, 2024 1

Hey @francwalter

Yes, this is possible, but not available from the frontend yet. There are the loadfile- and the collections-endpoints and they are listed in the list of endpoints here.
Here some work has been started to make this available from the frontend.

from simple-mpv-webui.

francwalter avatar francwalter commented on August 27, 2024

Could you give me an example for the collections api?
I tried a GET Request with:

http://192.168.0.161:8080/api/collections/C:/Users/f/Desktop/Filme

But this seems unknown. Backslash, also double, the same.
I put that path in the main.lua in the collections variable and i can get it with:

http://192.168.0.161:8080/api/collections/

But how can i use my path to play a movie?
In the help it's not clear enough for me.
Thanks.

from simple-mpv-webui.

open-dynaMIX avatar open-dynaMIX commented on August 27, 2024

No need to edit the main.lua just add it to the mpv config or pass it as CLI arg as described in the docs.

Everything that needs configuration can be configured from outside the main.lua. This way you can easily just pull new changes, without the need of resolving any conflicts.

The path needs to be URL-encoded in the URI. You can use an online URL encoder for this. So the URL would look like this: http://192.168.0.161:8080/api/collections/C%3A%2FUsers%2Ff%2FDesktop%2FFilme.

from simple-mpv-webui.

francwalter avatar francwalter commented on August 27, 2024

The path needs to be URL-encoded in the URI. You can use an online URL encoder for this. So the URL would look like this: http://192.168.0.161:8080/api/collections/C%3A%2FUsers%2Ff%2FDesktop%2FFilme.

But I get with that URL:

Error: Requested URL /api/collections/C%3A%2FUsers%2Ff%2FDesktop%2FFilme not found

and just with http://192.168.0.161:8080/api/collections/ I get the successful response:

[{"path":"c:\\Users\\f\\Desktop\\Filme","is-directory":true}]

as I have still (for the moment) that path hardcoded in collections in main.lua - what am I doing wrong?

from simple-mpv-webui.

francwalter avatar francwalter commented on August 27, 2024

But this works:

http://192.168.0.161:8080/api/loadfile/c%3A%2FUsers%2Ff%2FDesktop%2FFilme%2Fdonald.mkv/replace

So I must have some misunderstand about the collections, I guess.
What I thought is, that I could retrieve a list of files and folders in the path I send.
With:

http://192.168.0.161:8080/api/collections/here-comes-my-url-encoded-path

I thought that the response should be the content of that path.
Possible?

from simple-mpv-webui.

francwalter avatar francwalter commented on August 27, 2024

http://192.168.0.161:8080/api/collections/C:/Users/f/Desktop/Filme

My error was the slash instead of backslash!
So with %5C instead of %2F
In line 688 of main.lua (and in every other line where that always same "Error: Requested URL..." is thrown) I changed the code as debug measurement (I dont know other in lua) to:

      if not is_path_in_collection(fs_path) or not is_dir(fs_path) then
        return response(404, "plain", "fcw: Z688: Error: Requested URL /"..request.raw_path.." not found. fs_path: "..fs_path, {})
      end

So I could see, what the exact value of fs_path was, that there was wrongly slashes (%2F) instead of backslashes (%5C):

fcw: Z688: Error: Requested URL /api/collections/C%3A%2FUsers%2Ff%2FDesktop%2FFilme not found. fs_path: C:/Users/f/Desktop/Filme

The very same path must be in collections and as parameter as a directory (if ... is_dir(fs_path)).
It must be in exact same spelling, case-sensitive, despite Windows unawareness of cases. It took me a while to find the error when I had C:... in the collections (hardcoded) but put c:... in my parameter of the GET Request.
The code could be a bit optimized here ;)
Also the output (json) is a bit strange: all paths are with double backslash, e.g.:

0 |  
path | "c:\\Temp\\BE"
is-directory | true
1 |  
path | "c:\\Temp\\ePub"
is-directory | true
2 |  
path | "c:\\Temp\\Bericht"
is-directory | true
3 |  
path | "c:\\Temp\\WordPress Themes"
is-directory | true

But it is working in the end :)

What is still unclear: how can I set the option "collections" not just hardcoded?
I will scrutinize it further...

from simple-mpv-webui.

francwalter avatar francwalter commented on August 27, 2024

No need to edit the main.lua just add it to the mpv config or pass it as CLI arg as described in the docs.

I tried to put that collections into the mpv.conf:

webui-collections="C:\\Users\\f\\Desktop\\Filme"

but now I get an error on mpv start:

Error parsing option webui-collections (option not found)
C:\Users\f\AppData\Roaming/mpv/mpv.conf:147: setting option webui-collections='C:\\Users\\f\\Desktop\\Filme' failed.

Everything that needs configuration can be configured from outside the main.lua. This way you can easily just pull new changes, without the need of resolving any conflicts.

So where can I put that collections?
BTW: I can live with hardcoding it ;)

from simple-mpv-webui.

open-dynaMIX avatar open-dynaMIX commented on August 27, 2024

Hey @francwalter
Sorry for not getting back to you sooner!

The whole handling of paths is the only part that has special handling for windows. Windows support is really on a best effort basis, as I don't have a windows system. Sometimes I mess with it in a virtual machine, but it doesn't spark joy at all, so I mostly avoid it.

How to proceed: Please open a new issue, exactly describing the problem with path handling in windows as well as the requirements to get it fixed. I'm willing to implement any changes needed to meet those requirements. Or - even better - maybe some other person steps up that likes to work in windows and opens a PR.

from simple-mpv-webui.

francwalter avatar francwalter commented on August 27, 2024

Thank a lot!
In v3.0.0 you already fixed that issue with case-sensitive paths, that helped a lot!
The rest could be programming on my side (e.g. in Tasker).
For opening files in the browser indeed it would need programming in main.lua and the static web folder.

For the issue with the hardcoded path (in collections var.) I should then open a new issue, because this variable would be overwritten in any update, if coming ;)
If there is no update, then it could be indeed hard coded easily.

Thank!

from simple-mpv-webui.

talzahr avatar talzahr commented on August 27, 2024

I would like to see this as well.

However, I'm pretty happy with a simple workaround I use at the moment.

On my Windows install, I just have a batch file in my g:\videos directory that loops through all recursive directories and generates a playlist.txt file. So, for example g:\videos\Ascendance of a Bookworm will have a playlist of all episodes in order, as long as I keep videos organized. Then just start mpv from that directory with --playlist=playlist.txt

The batch to generate playlists.

@echo off
set videoFormats=*.mkv *.mp4

call :treeProcess
goto :eof

:treeProcess
dir /O:N /B %videoFormats% > playlist.txt
echo Parsing %CD%
for /D %%d in (*) do (
    cd %%d
    call :treeProcess
    cd ..
)
exit /b

Then just copy a simple mpv wrapper script to every directory in videos with a for /D %%d in (*) loop

Far from elegant, but works well enough for me to skip through vids of a show I'm watching.

from simple-mpv-webui.

open-dynaMIX avatar open-dynaMIX commented on August 27, 2024

Implemented in #427

from simple-mpv-webui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.