Skip to content

Latest commit

 

History

History
126 lines (121 loc) · 4.6 KB

research.org

File metadata and controls

126 lines (121 loc) · 4.6 KB

Loafer Research

How to Use

King Binary

This binary will get your ip and start an http server which is used to forward requests to mpv to control the socket

  • run binary
  • open mpv
  • host index.html that it makes
  • connect to index hosted and send commands

Loafer Notes

  • Refactor Crate to have:
    • Example binaries of how to use the library
  • Finish Type State Validation
    • Request::Get struct variant
    • Request::Post
    • Rest of HTTP Options
  • Look @ good http parsers in go / other languages and see how they do it(get inspired)

King

  • Use Rust to Host HTTP server( maybe axum )
  • Or install renders in the .config/loaf-king directory
  • Use a logger in rust
  • Use ~/.config/loaf-king for configs( Port, Log Mode, Database, SSL?)
  • Database for last watched anime in given directories to resume from
  • Make binary play files in linear order while checking the last watched
  • Add back button (makes the seek value negative)
  • Add skip button to go to end of the video
  • DualSense support

Scope

Build Socket to Connect To MPV IPC IPC should exposed

  • Skip / Forward
  • Add to queue of videos

HTML frontend

  • To skip / control
  • Add videos to queue and control playback

MPV architecture

Embeddable C API

C API that control over playback (libmpv) https://github.com/mpv-player/mpv/blob/master/libmpv/client.h Rust Bindings Option is Available with libmpv-rs

C Plugins

here Not really sure how this differs from libmpv, apparently it uses libmpv Potential use case for Zig here if C Plugin route is taken I can also write rust code to compile to .so file here and be used as a plugin

Lua / JS Scripting API

I believe these use libmpv as the backend so I could just use that instead

HTTP Server

Loafer needs an rest server and a frontend/ui to trigger ipc events. Simplest approach is a website hosted on an http server with an API endpoint(currently also http)

HTTP Parsing

The **REST** server needs to parse HTTP data to make sure this is valid The approach I am taking is using a buffer reader to read lines But this made me realize the actual lines need to be parsed, raising concerns

  • regex is hacky and shameful
  • string functions is morally wrong

So is the only solution lexical analysis? 2 Solutions are Lexical Analysis and State Machines Look @ some http crates to see how they do it

Chatgpt Notes

Current Design

The current design tries to take advantage of some of these features. It does a terrible job at it, and in the end is a glorified string checker. The code isn’t made to be touched by anyone including myself. Currently the steps to run this program are:

  1. Get the ip address from `iproute2`
  2. use this ip to render the html template( sending forms to proper address )
  3. start http api server
  4. host the rendered template
  5. Start mpv with “`bash
    mpv episode.mkv --input-ipc-server=/tmp/loafer.sock
        

How to improvise

Combine the two http servers

Currently as described there are 2 HTTP Servers needed

  • One for Hosting the UI(form to communicate to Control Center(tool that sends messages to mpv))
  • One for parsing the ui and sending the data to msg mpv

The code for the 1st parser is currently being hosted by python3 -m http.server -b 0.0.0.0 8080. Combine this python process into the rust main code(either by launching with process::Command or by real http server rust)